Wed, 08 May 2013 02:39:26 -0400
Fix background change in IP and debug filter entries.
It uses theme colours on GTK+3, so it will fit in better, hopefully.
However, I may be abusing the "success_color" a little bit.
| pidgin/gtkdebug.c | file | annotate | diff | comparison | revisions | |
| pidgin/gtkprefs.c | file | annotate | diff | comparison | revisions |
--- a/pidgin/gtkdebug.c Tue May 07 05:04:46 2013 -0400 +++ b/pidgin/gtkdebug.c Wed May 08 02:39:26 2013 -0400 @@ -151,18 +151,42 @@ *****************************************************************************/ static void regex_clear_color(GtkWidget *w) { +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *context = gtk_widget_get_style_context(w); + gtk_style_context_remove_class(context, "good-filter"); + gtk_style_context_remove_class(context, "bad-filter"); +#else gtk_widget_modify_base(w, GTK_STATE_NORMAL, NULL); +#endif } static void -regex_change_color(GtkWidget *w, guint16 r, guint16 g, guint16 b) { +regex_change_color(GtkWidget *w, gboolean success) { +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *context = gtk_widget_get_style_context(w); + + if (success) { + gtk_style_context_add_class(context, "good-filter"); + gtk_style_context_remove_class(context, "bad-filter"); + } else { + gtk_style_context_add_class(context, "bad-filter"); + gtk_style_context_remove_class(context, "good-filter"); + } +#else GdkColor color; - color.red = r; - color.green = g; - color.blue = b; + if (success) { + color.red = 0xAFFF; + color.green = 0xFFFF; + color.blue = 0xAFFF; + } else { + color.red = 0xFFFF; + color.green = 0xAFFF; + color.blue = 0xAFFF; + } gtk_widget_modify_base(w, GTK_STATE_NORMAL, &color); +#endif } static void @@ -279,11 +303,11 @@ #endif if (win->regex == NULL) { /* failed to compile */ - regex_change_color(win->expression, 0xFFFF, 0xAFFF, 0xAFFF); + regex_change_color(win->expression, FALSE); gtk_widget_set_sensitive(win->filter, FALSE); } else { /* compiled successfully */ - regex_change_color(win->expression, 0xAFFF, 0xFFFF, 0xAFFF); + regex_change_color(win->expression, TRUE); gtk_widget_set_sensitive(win->filter, TRUE); } } @@ -410,6 +434,21 @@ gint width, height; void *handle; GtkToolItem *item; + GtkStyleContext *context; + GtkCssProvider *filter_css; + const gchar filter_style[] = + ".bad-filter {" + "color: @error_fg_color;" + "text-shadow: 0 1px @error_text_shadow;" + "background-image: none;" + "background-color: @error_bg_color;" + "}" + ".good-filter {" + "color: @question_fg_color;" + "text-shadow: 0 1px @question_text_shadow;" + "background-image: none;" + "background-color: @success_color;" + "}"; win = g_new0(DebugWindow, 1); @@ -503,6 +542,13 @@ gtk_container_add(GTK_CONTAINER(item), GTK_WIDGET(win->expression)); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item)); + filter_css = gtk_css_provider_new(); + gtk_css_provider_load_from_data(filter_css, filter_style, -1, NULL); + context = gtk_widget_get_style_context(win->expression); + gtk_style_context_add_provider(context, + GTK_STYLE_PROVIDER(filter_css), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + /* this needs to be before the text is set from the pref if we want it * to colorize a stored expression. */
--- a/pidgin/gtkprefs.c Tue May 07 05:04:46 2013 -0400 +++ b/pidgin/gtkprefs.c Wed May 08 02:39:26 2013 -0400 @@ -1869,6 +1869,26 @@ static void network_ip_changed(GtkEntry *entry, gpointer data) { +#if GTK_CHECK_VERSION(3,0,0) + const gchar *text = gtk_entry_get_text(entry); + GtkStyleContext *context = gtk_widget_get_style_context(GTK_WIDGET(entry)); + + if (text && *text) { + if (purple_ip_address_is_valid(text)) { + purple_network_set_public_ip(text); + gtk_style_context_add_class(context, "good-ip"); + gtk_style_context_remove_class(context, "bad-ip"); + } else { + gtk_style_context_add_class(context, "bad-ip"); + gtk_style_context_remove_class(context, "good-ip"); + } + + } else { + purple_network_set_public_ip(""); + gtk_style_context_remove_class(context, "bad-ip"); + gtk_style_context_remove_class(context, "good-ip"); + } +#else const gchar *text = gtk_entry_get_text(entry); GdkColor color; @@ -1891,6 +1911,7 @@ purple_network_set_public_ip(""); gtk_widget_modify_base(GTK_WIDGET(entry), GTK_STATE_NORMAL, NULL); } +#endif } static gboolean @@ -2013,6 +2034,21 @@ GtkWidget *vbox, *hbox, *entry; GtkWidget *label, *auto_ip_checkbox, *ports_checkbox, *spin_button; GtkSizeGroup *sg; + GtkStyleContext *context; + GtkCssProvider *ip_css; + const gchar ip_style[] = + ".bad-ip {" + "color: @error_fg_color;" + "text-shadow: 0 1px @error_text_shadow;" + "background-image: none;" + "background-color: @error_bg_color;" + "}" + ".good-ip {" + "color: @question_fg_color;" + "text-shadow: 0 1px @question_text_shadow;" + "background-image: none;" + "background-color: @success_color;" + "}"; ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER); @@ -2054,6 +2090,13 @@ g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(network_ip_changed), NULL); + ip_css = gtk_css_provider_new(); + gtk_css_provider_load_from_data(ip_css, ip_style, -1, NULL); + context = gtk_widget_get_style_context(entry); + gtk_style_context_add_provider(context, + GTK_STYLE_PROVIDER(ip_css), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Public _IP:"), sg, entry, TRUE, NULL);