00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00031 #include "stdinc.h"
00032
00033 #include "config.h"
00034 #include "gui.h"
00035 #include "gui_internal.h"
00036
00037 GMutex *gui_mtx;
00038 int gui_draw_colors;
00039 int gui_draw_ratio;
00040
00041 void
00042 gui_draw_init_pre(void)
00043 {
00044
00045 initscr();
00046 }
00047
00048 void
00049 gui_draw_init_post(void)
00050 {
00051
00052 gui_mtx = g_mutex_new();
00053
00054 #ifdef PDCURSES
00055 PDC_set_title(APP_NAME);
00056 #endif
00057 nonl();
00058 cbreak();
00059 noecho();
00060 keypad(stdscr, TRUE);
00061 raw();
00062 wnoutrefresh(stdscr);
00063
00064 gui_draw_colors =
00065 config_getopt_bool("gui.color.enabled") && has_colors();
00066 gui_draw_ratio = config_getopt_percentage("gui.ratio");
00067
00068 if (gui_draw_colors) {
00069 start_color();
00070 #ifdef NCURSES_VERSION
00071 use_default_colors();
00072 #endif
00073
00074 init_pair(GUI_COLOR_BAR,
00075 config_getopt_color("gui.color.bar.fg"),
00076 config_getopt_color("gui.color.bar.bg"));
00077 init_pair(GUI_COLOR_BLOCK,
00078 config_getopt_color("gui.color.block.fg"),
00079 config_getopt_color("gui.color.block.bg"));
00080 init_pair(GUI_COLOR_SELECT,
00081 config_getopt_color("gui.color.select.fg"),
00082 config_getopt_color("gui.color.select.bg"));
00083 init_pair(GUI_COLOR_DESELECT,
00084 config_getopt_color("gui.color.deselect.fg"),
00085 config_getopt_color("gui.color.deselect.bg"));
00086 init_pair(GUI_COLOR_MARKED,
00087 config_getopt_color("gui.color.marked.fg"),
00088 config_getopt_color("gui.color.marked.bg"));
00089 }
00090
00091 gui_msgbar_init();
00092 gui_playq_init();
00093 gui_browser_init();
00094 gui_draw_done();
00095 }
00096
00097 void
00098 gui_draw_init_abort(void)
00099 {
00100 endwin();
00101 }
00102
00103 void
00104 gui_draw_destroy(void)
00105 {
00106 gui_lock();
00107 gui_msgbar_destroy();
00108 gui_playq_destroy();
00109 gui_browser_destroy();
00110
00111 endwin();
00112 gui_unlock();
00113 }
00114
00115 void
00116 gui_draw_resize(void)
00117 {
00118 gui_lock();
00119 wnoutrefresh(stdscr);
00120 gui_unlock();
00121 gui_msgbar_resize();
00122 gui_playq_resize();
00123 gui_browser_resize();
00124 gui_draw_done();
00125 }
00126
00127 int
00128 gui_draw_color_number(const char *name)
00129 {
00130 if (strcmp(name, "black") == 0)
00131 return (COLOR_BLACK);
00132 else if (strcmp(name, "red") == 0)
00133 return (COLOR_RED);
00134 else if (strcmp(name, "green") == 0)
00135 return (COLOR_GREEN);
00136 else if (strcmp(name, "yellow") == 0)
00137 return (COLOR_YELLOW);
00138 else if (strcmp(name, "blue") == 0)
00139 return (COLOR_BLUE);
00140 else if (strcmp(name, "magenta") == 0)
00141 return (COLOR_MAGENTA);
00142 else if (strcmp(name, "cyan") == 0)
00143 return (COLOR_CYAN);
00144 else if (strcmp(name, "white") == 0)
00145 return (COLOR_WHITE);
00146 #ifdef NCURSES_VERSION
00147 else if (strcmp(name, "default") == 0)
00148 return (-1);
00149 #endif
00150
00151 return (-2);
00152 }
00153
00154 void
00155 gui_draw_done(void)
00156 {
00157 gui_msgbar_refresh();
00158 gui_lock();
00159 doupdate();
00160 gui_unlock();
00161 }