pidgin/gtkconv.c

branch
trac-17174
changeset 38822
93c0cd117e1d
parent 38699
e7b5011e4728
child 38748
17f8a2a8ccba
child 38913
8ed31ec968af
equal deleted inserted replaced
38821:329cf2453fb8 38822:93c0cd117e1d
61 #include "gtklog.h" 61 #include "gtklog.h"
62 #include "gtkmenutray.h" 62 #include "gtkmenutray.h"
63 #include "gtkpounce.h" 63 #include "gtkpounce.h"
64 #include "gtkprefs.h" 64 #include "gtkprefs.h"
65 #include "gtkprivacy.h" 65 #include "gtkprivacy.h"
66 #include "gtkstyle.h"
66 #include "gtkthemes.h" 67 #include "gtkthemes.h"
67 #include "gtkutils.h" 68 #include "gtkutils.h"
68 #include "pidginstock.h" 69 #include "pidginstock.h"
69 #include "pidgintooltip.h" 70 #include "pidgintooltip.h"
70 71
8174 purple_signal_connect(purple_conversations_get_handle(), "wrote-im-msg", handle, 8175 purple_signal_connect(purple_conversations_get_handle(), "wrote-im-msg", handle,
8175 PURPLE_CALLBACK(wrote_msg_update_unseen_cb), NULL); 8176 PURPLE_CALLBACK(wrote_msg_update_unseen_cb), NULL);
8176 purple_signal_connect(purple_conversations_get_handle(), "wrote-chat-msg", handle, 8177 purple_signal_connect(purple_conversations_get_handle(), "wrote-chat-msg", handle,
8177 PURPLE_CALLBACK(wrote_msg_update_unseen_cb), NULL); 8178 PURPLE_CALLBACK(wrote_msg_update_unseen_cb), NULL);
8178 8179
8179 { 8180 }
8180 /* Set default tab colors */ 8181
8181 GString *str = g_string_new(NULL); 8182 /* Invalidate the first tab color set */
8182 GtkSettings *settings = gtk_settings_get_default(); 8183 static gboolean tab_color_fuse = TRUE;
8183 GtkStyle *parent = gtk_rc_get_style_by_paths(settings, "tab-container.tab-label*", NULL, G_TYPE_NONE), *now; 8184
8184 struct { 8185 static void
8185 const char *stylename; 8186 pidgin_conversations_set_tab_colors(void)
8186 const char *labelname; 8187 {
8187 const char *color; 8188 /* Set default tab colors */
8188 } styles[] = { 8189 GString *str = g_string_new(NULL);
8189 {"pidgin_tab_label_typing_default", "tab-label-typing", "#4e9a06"}, 8190 GtkSettings *settings = gtk_settings_get_default();
8190 {"pidgin_tab_label_typed_default", "tab-label-typed", "#c4a000"}, 8191 GtkStyle *parent = gtk_rc_get_style_by_paths(settings, "tab-container.tab-label*", NULL, G_TYPE_NONE), *now;
8191 {"pidgin_tab_label_attention_default", "tab-label-attention", "#006aff"}, 8192 struct {
8192 {"pidgin_tab_label_unreadchat_default", "tab-label-unreadchat", "#cc0000"}, 8193 const char *stylename;
8193 {"pidgin_tab_label_event_default", "tab-label-event", "#888a85"}, 8194 const char *labelname;
8194 {NULL, NULL, NULL} 8195 const char *color;
8195 }; 8196 } styles[] = {
8196 int iter; 8197 {"pidgin_tab_label_typing_default", "tab-label-typing", "#4e9a06"},
8197 for (iter = 0; styles[iter].stylename; iter++) { 8198 {"pidgin_tab_label_typed_default", "tab-label-typed", "#c4a000"},
8198 now = gtk_rc_get_style_by_paths(settings, styles[iter].labelname, NULL, G_TYPE_NONE); 8199 {"pidgin_tab_label_attention_default", "tab-label-attention", "#006aff"},
8199 if (parent == now || 8200 {"pidgin_tab_label_unreadchat_default", "tab-label-unreadchat", "#cc0000"},
8200 (parent && now && parent->rc_style == now->rc_style)) { 8201 {"pidgin_tab_label_event_default", "tab-label-event", "#888a85"},
8201 g_string_append_printf(str, "style \"%s\" {\n" 8202 {NULL, NULL, NULL}
8202 "fg[ACTIVE] = \"%s\"\n" 8203 };
8203 "}\n" 8204 int iter;
8204 "widget \"*%s\" style \"%s\"\n", 8205
8205 styles[iter].stylename, 8206 if(tab_color_fuse) {
8206 styles[iter].color, 8207 tab_color_fuse = FALSE;
8207 styles[iter].labelname, styles[iter].stylename); 8208 return;
8208 } 8209 }
8209 } 8210
8210 gtk_rc_parse_string(str->str); 8211 for (iter = 0; styles[iter].stylename; iter++) {
8211 g_string_free(str, TRUE); 8212 now = gtk_rc_get_style_by_paths(settings, styles[iter].labelname, NULL, G_TYPE_NONE);
8212 gtk_rc_reset_styles(settings); 8213 if (parent == now ||
8213 } 8214 (parent && now && parent->rc_style == now->rc_style)) {
8215 GdkColor color;
8216 gdk_color_parse(styles[iter].color, &color);
8217 pidgin_style_adjust_contrast(gtk_widget_get_default_style(), &color);
8218
8219 g_string_append_printf(str, "style \"%s\" {\n"
8220 "fg[ACTIVE] = \"%s\"\n"
8221 "}\n"
8222 "widget \"*%s\" style \"%s\"\n",
8223 styles[iter].stylename,
8224 gdk_color_to_string(&color),
8225 styles[iter].labelname, styles[iter].stylename);
8226 }
8227 }
8228 gtk_rc_parse_string(str->str);
8229 g_string_free(str, TRUE);
8230 gtk_rc_reset_styles(settings);
8214 } 8231 }
8215 8232
8216 void 8233 void
8217 pidgin_conversations_uninit(void) 8234 pidgin_conversations_uninit(void)
8218 { 8235 {
9383 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/win32/minimize_new_convs") 9400 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/win32/minimize_new_convs")
9384 && !gtk_get_current_event_state(&state)) 9401 && !gtk_get_current_event_state(&state))
9385 gtk_window_iconify(GTK_WINDOW(win->window)); 9402 gtk_window_iconify(GTK_WINDOW(win->window));
9386 #endif 9403 #endif
9387 9404
9405 /* Fix colours */
9406 pidgin_conversations_set_tab_colors();
9407
9388 return win; 9408 return win;
9389 } 9409 }
9390 9410
9391 void 9411 void
9392 pidgin_conv_window_destroy(PidginWindow *win) 9412 pidgin_conv_window_destroy(PidginWindow *win)
10250 time_t breakout_time; 10270 time_t breakout_time;
10251 10271
10252 gdk_color_parse(DEFAULT_HIGHLIGHT_COLOR, &nick_highlight); 10272 gdk_color_parse(DEFAULT_HIGHLIGHT_COLOR, &nick_highlight);
10253 gdk_color_parse(DEFAULT_SEND_COLOR, &send_color); 10273 gdk_color_parse(DEFAULT_SEND_COLOR, &send_color);
10254 10274
10275 pidgin_style_adjust_contrast(NULL, &nick_highlight);
10276 pidgin_style_adjust_contrast(NULL, &send_color);
10277
10255 srand(background.red + background.green + background.blue + 1); 10278 srand(background.red + background.green + background.blue + 1);
10256 10279
10257 breakout_time = time(NULL) + 3; 10280 breakout_time = time(NULL) + 3;
10258 10281
10259 /* first we look through the list of "good" colors: colors that differ from every other color in the 10282 /* first we look through the list of "good" colors: colors that differ from every other color in the

mercurial