pidgin/gtkconv.c

branch
soc.2013.gobjectification.plugins
changeset 37108
73c5fb6d78b3
parent 37103
cdc96a002b33
parent 35510
0e6c78789caa
child 37109
94d1a2589d5a
--- a/pidgin/gtkconv.c	Mon Feb 10 03:17:49 2014 +0530
+++ b/pidgin/gtkconv.c	Mon Feb 10 16:22:00 2014 +0530
@@ -221,13 +221,23 @@
 
 static const GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+	GtkStyleContext *style = gtk_widget_get_style_context(gtkconv->webview);
+	GdkRGBA rgba;
+#else
+	GtkStyle *style = gtk_widget_get_style(gtkconv->webview);
+#endif
 	static GdkColor col;
-	GtkStyle *style = gtk_widget_get_style(gtkconv->webview);
 	float scale;
 
 	col = g_array_index(gtkconv->nick_colors, GdkColor, g_str_hash(name) % gtkconv->nick_colors->len);
+#if GTK_CHECK_VERSION(3,0,0)
+	gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &rgba);
+	scale = (1 - LUMINANCE(rgba)) * ((float)0xffff / MAX(MAX(col.red, col.blue), col.green));
+#else
 	scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) *
 		       (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green)));
+#endif
 
 	/* The colors are chosen to look fine on white; we should never have to darken */
 	if (scale > 1) {
@@ -5218,7 +5228,11 @@
 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);
+#else
 	gtk_widget_modify_base(gtkconv->quickfind_entry, GTK_STATE_NORMAL, NULL);
+#endif
 
 	webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(gtkconv->webview));
 	gtk_widget_hide(gtkconv->quickfind_container);
@@ -5234,13 +5248,26 @@
 		case GDK_KEY_Return:
 		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);
+#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);
+#else
 				GdkColor col;
 				col.red = 0xffff;
 				col.green = 0xafff;
 				col.blue = 0xafff;
 				gtk_widget_modify_base(gtkconv->quickfind_entry, GTK_STATE_NORMAL, &col);
+#endif
 			}
 			break;
 		case GDK_KEY_Escape:

mercurial