Mercurial > pidgin.yaz
comparison console/libgnt/gntcolors.c @ 14301:9df5dd999402
[gaim-migrate @ 16991]
The color configurations should work now.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 23 Aug 2006 02:34:40 +0000 |
parents | ea5193c23171 |
children | a8632e4bd849 |
comparison
equal
deleted
inserted
replaced
14300:b8697618399a | 14301:9df5dd999402 |
---|---|
21 color_content(i, &colors[i].r, | 21 color_content(i, &colors[i].r, |
22 &colors[i].g, &colors[i].b); | 22 &colors[i].g, &colors[i].b); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 static gboolean | |
27 can_use_custom_color() | |
28 { | |
29 return (gnt_style_get_bool(GNT_STYLE_COLOR, FALSE) && can_change_color()); | |
30 } | |
31 | |
26 static void | 32 static void |
27 restore_colors() | 33 restore_colors() |
28 { | 34 { |
29 short i; | 35 short i; |
30 for (i = 0; i < GNT_TOTAL_COLORS; i++) | 36 for (i = 0; i < GNT_TOTAL_COLORS; i++) |
34 } | 40 } |
35 } | 41 } |
36 | 42 |
37 void gnt_init_colors() | 43 void gnt_init_colors() |
38 { | 44 { |
45 static gboolean init = FALSE; | |
46 | |
47 if (init) | |
48 return; | |
49 init = TRUE; | |
50 | |
39 start_color(); | 51 start_color(); |
40 if (gnt_style_get_bool(GNT_STYLE_COLOR, FALSE) && can_change_color()) | 52 use_default_colors(); |
53 | |
54 if (can_use_custom_color()) | |
41 { | 55 { |
42 backup_colors(); | 56 backup_colors(); |
43 | 57 |
44 /* Do some init_color()s */ | 58 /* Do some init_color()s */ |
45 init_color(GNT_COLOR_BLACK, 0, 0, 0); | 59 init_color(GNT_COLOR_BLACK, 0, 0, 0); |
62 init_pair(GNT_COLOR_HIGHLIGHT_D, GNT_COLOR_BLACK, GNT_COLOR_GRAY); | 76 init_pair(GNT_COLOR_HIGHLIGHT_D, GNT_COLOR_BLACK, GNT_COLOR_GRAY); |
63 init_pair(GNT_COLOR_DISABLED, GNT_COLOR_GRAY, GNT_COLOR_WHITE); | 77 init_pair(GNT_COLOR_DISABLED, GNT_COLOR_GRAY, GNT_COLOR_WHITE); |
64 } | 78 } |
65 else | 79 else |
66 { | 80 { |
67 use_default_colors(); | |
68 init_pair(GNT_COLOR_NORMAL, COLOR_BLACK, COLOR_WHITE); | 81 init_pair(GNT_COLOR_NORMAL, COLOR_BLACK, COLOR_WHITE); |
69 init_pair(GNT_COLOR_HIGHLIGHT, COLOR_WHITE, COLOR_BLUE); | 82 init_pair(GNT_COLOR_HIGHLIGHT, COLOR_WHITE, COLOR_BLUE); |
70 init_pair(GNT_COLOR_SHADOW, COLOR_BLACK, COLOR_BLACK); | 83 init_pair(GNT_COLOR_SHADOW, COLOR_BLACK, COLOR_BLACK); |
71 init_pair(GNT_COLOR_TITLE, COLOR_WHITE, COLOR_BLUE); | 84 init_pair(GNT_COLOR_TITLE, COLOR_WHITE, COLOR_BLUE); |
72 init_pair(GNT_COLOR_TITLE_D, COLOR_WHITE, COLOR_BLACK); | 85 init_pair(GNT_COLOR_TITLE_D, COLOR_WHITE, COLOR_BLACK); |
77 } | 90 } |
78 | 91 |
79 void | 92 void |
80 gnt_uninit_colors() | 93 gnt_uninit_colors() |
81 { | 94 { |
82 if (gnt_style_get_bool(GNT_STYLE_COLOR, FALSE) && can_change_color()) | 95 if (can_use_custom_color()) |
83 restore_colors(); | 96 restore_colors(); |
84 } | 97 } |
85 | 98 |
86 static int | 99 static int |
87 get_color(char *key) | 100 get_color(char *key) |
88 { | 101 { |
89 int color; | 102 int color; |
103 gboolean custom = can_use_custom_color(); | |
90 | 104 |
91 key = g_strstrip(key); | 105 key = g_strstrip(key); |
92 | 106 |
93 if (strcmp(key, "black") == 0) | 107 if (strcmp(key, "black") == 0) |
94 color = GNT_COLOR_BLACK; | 108 color = custom ? GNT_COLOR_BLACK : COLOR_BLACK; |
95 else if (strcmp(key, "red") == 0) | 109 else if (strcmp(key, "red") == 0) |
96 color = GNT_COLOR_RED; | 110 color = custom ? GNT_COLOR_RED : COLOR_RED; |
97 else if (strcmp(key, "green") == 0) | 111 else if (strcmp(key, "green") == 0) |
98 color = GNT_COLOR_GREEN; | 112 color = custom ? GNT_COLOR_GREEN : COLOR_GREEN; |
99 else if (strcmp(key, "blue") == 0) | 113 else if (strcmp(key, "blue") == 0) |
100 color = GNT_COLOR_BLUE; | 114 color = custom ? GNT_COLOR_BLUE : COLOR_BLUE; |
101 else if (strcmp(key, "white") == 0) | 115 else if (strcmp(key, "white") == 0) |
102 color = GNT_COLOR_WHITE; | 116 color = custom ? GNT_COLOR_WHITE : COLOR_WHITE; |
103 else if (strcmp(key, "gray") == 0) | 117 else if (strcmp(key, "gray") == 0) |
104 color = GNT_COLOR_GRAY; | 118 color = custom ? GNT_COLOR_GRAY : COLOR_YELLOW; /* eh? */ |
105 else if (strcmp(key, "darkgray") == 0) | 119 else if (strcmp(key, "darkgray") == 0) |
106 color = GNT_COLOR_DARK_GRAY; | 120 color = custom ? GNT_COLOR_DARK_GRAY : COLOR_BLACK; |
121 else if (strcmp(key, "magenta") == 0) | |
122 color = COLOR_MAGENTA; | |
123 else if (strcmp(key, "cyan") == 0) | |
124 color = COLOR_CYAN; | |
107 else | 125 else |
108 color = -1; | 126 color = -1; |
109 return color; | 127 return color; |
110 } | 128 } |
111 | 129 |
120 { | 138 { |
121 g_printerr("GntColors: %s\n", error->message); | 139 g_printerr("GntColors: %s\n", error->message); |
122 g_error_free(error); | 140 g_error_free(error); |
123 error = NULL; | 141 error = NULL; |
124 } | 142 } |
125 else | 143 else if (nkeys) |
126 { | 144 { |
145 gnt_init_colors(); | |
127 while (nkeys--) | 146 while (nkeys--) |
128 { | 147 { |
129 gsize len; | 148 gsize len; |
130 char *key = keys[nkeys]; | 149 char *key = keys[nkeys]; |
131 char **list = g_key_file_get_string_list(kfile, "colors", key, &len, NULL); | 150 char **list = g_key_file_get_string_list(kfile, "colors", key, &len, NULL); |
162 { | 181 { |
163 g_printerr("GntColors: %s\n", error->message); | 182 g_printerr("GntColors: %s\n", error->message); |
164 g_error_free(error); | 183 g_error_free(error); |
165 return; | 184 return; |
166 } | 185 } |
186 else if (nkeys) | |
187 gnt_init_colors(); | |
167 | 188 |
168 while (nkeys--) | 189 while (nkeys--) |
169 { | 190 { |
170 gsize len; | 191 gsize len; |
171 char *key = keys[nkeys]; | 192 char *key = keys[nkeys]; |