/pidgin/main: 837716b0a579: Use CSS for colourizing the conversa...

Elliott Sales de Andrade qulogic at pidgin.im
Mon Feb 10 17:49:47 EST 2014


Changeset: 837716b0a579082dfa5f070f7640ac82af7d8b36
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2014-02-10 17:49 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/837716b0a579

Description:

Use CSS for colourizing the conversation search entry.

Even though the GTK+ docs recommend gtk_widget_override_background_color,
it doesn't really work. All our other widgets that do this already use
CSS instead.

diffstat:

 pidgin/gtkconv.c |  33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diffs (69 lines):

diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -5229,7 +5229,8 @@ static gboolean
 pidgin_conv_end_quickfind(PidginConversation *gtkconv)
 {
 #if GTK_CHECK_VERSION(3,0,0)
-	gtk_widget_override_background_color(gtkconv->quickfind_entry, GTK_STATE_FLAG_NORMAL, NULL);
+	GtkStyleContext *context = gtk_widget_get_style_context(gtkconv->quickfind_entry);
+	gtk_style_context_remove_class(context, "not-found");
 #else
 	gtk_widget_modify_base(gtkconv->quickfind_entry, GTK_STATE_NORMAL, NULL);
 #endif
@@ -5249,18 +5250,15 @@ quickfind_process_input(GtkWidget *entry
 		case GDK_KEY_KP_Enter:
 			if (webkit_web_view_search_text(WEBKIT_WEB_VIEW(gtkconv->webview), gtk_entry_get_text(GTK_ENTRY(entry)), FALSE, TRUE, TRUE)) {
 #if GTK_CHECK_VERSION(3,0,0)
-				gtk_widget_override_background_color(gtkconv->quickfind_entry, GTK_STATE_FLAG_NORMAL, NULL);
+				GtkStyleContext *context = gtk_widget_get_style_context(gtkconv->quickfind_entry);
+				gtk_style_context_remove_class(context, "not-found");
 #else
 				gtk_widget_modify_base(gtkconv->quickfind_entry, GTK_STATE_NORMAL, NULL);
 #endif
 			} else {
 #if GTK_CHECK_VERSION(3,0,0)
-				GdkRGBA col;
-				col.red = 1.0;
-				col.green = 0xafff/(double)0xffff;
-				col.blue = 0xafff/(double)0xffff;
-				col.alpha = 1.0;
-				gtk_widget_override_background_color(gtkconv->quickfind_entry, GTK_STATE_FLAG_NORMAL, &col);
+				GtkStyleContext *context = gtk_widget_get_style_context(gtkconv->quickfind_entry);
+				gtk_style_context_add_class(context, "not-found");
 #else
 				GdkColor col;
 				col.red = 0xffff;
@@ -5284,6 +5282,17 @@ pidgin_conv_setup_quickfind(PidginConver
 {
 	GtkWidget *widget = gtk_hbox_new(FALSE, 0);
 	GtkWidget *label, *entry, *close;
+#if GTK_CHECK_VERSION(3,0,0)
+	GtkStyleContext *context;
+	GtkCssProvider *filter_css;
+	const gchar filter_style[] =
+		".not-found {"
+			"color: @error_fg_color;"
+			"text-shadow: 0 1px @error_text_shadow;"
+			"background-image: none;"
+			"background-color: @error_bg_color;"
+		"}";
+#endif
 
 	gtk_box_pack_start(GTK_BOX(container), widget, FALSE, FALSE, 0);
 
@@ -5296,6 +5305,14 @@ pidgin_conv_setup_quickfind(PidginConver
 
 	entry = gtk_entry_new();
 	gtk_box_pack_start(GTK_BOX(widget), entry, TRUE, TRUE, 0);
+#if GTK_CHECK_VERSION(3,0,0)
+	filter_css = gtk_css_provider_new();
+	gtk_css_provider_load_from_data(filter_css, filter_style, -1, NULL);
+	context = gtk_widget_get_style_context(entry);
+	gtk_style_context_add_provider(context,
+	                               GTK_STYLE_PROVIDER(filter_css),
+	                               GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+#endif
 
 	gtkconv->quickfind_entry = entry;
 	gtkconv->quickfind_container = widget;



More information about the Commits mailing list