/pidgin/main: 0e6c78789caa: Fix some GtkStyle deprecations.

Elliott Sales de Andrade qulogic at pidgin.im
Sun Feb 9 19:18:52 EST 2014


Changeset: 0e6c78789caa7f561d302a92f72c05b5b4748fd4
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2014-02-09 18:46 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/0e6c78789caa

Description:

Fix some GtkStyle deprecations.

There's still one more, but that might have API ramifications, so we'd
need to discuss that change.

diffstat:

 pidgin/gtkaccount.c |  25 +++++++++++++++++++++++++
 pidgin/gtkconv.c    |  29 ++++++++++++++++++++++++++++-
 pidgin/gtkmedia.c   |  16 ++++++++++++++++
 pidgin/gtkprefs.c   |   8 ++++++++
 4 files changed, 77 insertions(+), 1 deletions(-)

diffs (194 lines):

diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -534,7 +534,12 @@ account_dnd_recv(GtkWidget *widget, GdkD
 static void
 update_editable(PurpleConnection *gc, AccountPrefsDialog *dialog)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+	GtkStyleContext *style;
+	GdkRGBA color;
+#else
 	GtkStyle *style;
+#endif
 	gboolean set;
 	GList *l;
 
@@ -547,16 +552,36 @@ update_editable(PurpleConnection *gc, Ac
 	set = !(purple_account_is_connected(dialog->account) || purple_account_is_connecting(dialog->account));
 	gtk_widget_set_sensitive(dialog->protocol_menu, set);
 	gtk_editable_set_editable(GTK_EDITABLE(dialog->username_entry), set);
+#if GTK_CHECK_VERSION(3,0,0)
+	style = set ? NULL : gtk_widget_get_style_context(dialog->username_entry);
+	if (style) {
+		gtk_style_context_get_background_color(style, GTK_STATE_FLAG_INSENSITIVE, &color);
+		gtk_widget_override_background_color(dialog->username_entry, GTK_STATE_FLAG_NORMAL, &color);
+	} else {
+		gtk_widget_override_background_color(dialog->username_entry, GTK_STATE_FLAG_NORMAL, NULL);
+	}
+#else
 	style = set ? NULL : gtk_widget_get_style(dialog->username_entry);
 	gtk_widget_modify_base(dialog->username_entry, GTK_STATE_NORMAL,
 			style ? &style->base[GTK_STATE_INSENSITIVE] : NULL);
+#endif
 
 	for (l = dialog->user_split_entries ; l != NULL ; l = l->next) {
 		if (GTK_IS_EDITABLE(l->data)) {
 			gtk_editable_set_editable(GTK_EDITABLE(l->data), set);
+#if GTK_CHECK_VERSION(3,0,0)
+			style = set ? NULL : gtk_widget_get_style_context(GTK_WIDGET(l->data));
+			if (style) {
+				gtk_style_context_get_background_color(style, GTK_STATE_FLAG_INSENSITIVE, &color);
+				gtk_widget_override_background_color(GTK_WIDGET(l->data), GTK_STATE_FLAG_NORMAL, &color);
+			} else {
+				gtk_widget_override_background_color(GTK_WIDGET(l->data), GTK_STATE_FLAG_NORMAL, NULL);
+			}
+#else
 			style = set ? NULL : gtk_widget_get_style(GTK_WIDGET(l->data));
 			gtk_widget_modify_base(GTK_WIDGET(l->data), GTK_STATE_NORMAL,
 					style ? &style->base[GTK_STATE_INSENSITIVE] : NULL);
+#endif
 		} else {
 			gtk_widget_set_sensitive(GTK_WIDGET(l->data), set);
 		}
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -220,13 +220,23 @@ static gboolean pidgin_conv_xy_to_right_
 
 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 @@ pidgin_conv_create_tooltip(GtkWidget *ti
 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 @@ quickfind_process_input(GtkWidget *entry
 		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:
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -791,7 +791,11 @@ pidgin_media_ready_cb(PurpleMedia *media
 		PidginMediaRealizeData *data;
 		GtkWidget *aspect;
 		GtkWidget *remote_video;
+#if GTK_CHECK_VERSION(3,0,0)
+		GdkRGBA color = {0.0, 0.0, 0.0, 1.0};
+#else
 		GdkColor color = {0, 0, 0, 0};
+#endif
 
 		aspect = gtk_aspect_frame_new(NULL, 0, 0, 4.0/3.0, FALSE);
 		gtk_frame_set_shadow_type(GTK_FRAME(aspect), GTK_SHADOW_IN);
@@ -803,7 +807,11 @@ pidgin_media_ready_cb(PurpleMedia *media
 		data->participant = g_strdup(gtkmedia->priv->screenname);
 
 		remote_video = gtk_drawing_area_new();
+#if GTK_CHECK_VERSION(3,0,0)
+		gtk_widget_override_background_color(remote_video, GTK_STATE_FLAG_NORMAL, &color);
+#else
 		gtk_widget_modify_bg(remote_video, GTK_STATE_NORMAL, &color);
+#endif
 		g_signal_connect(G_OBJECT(remote_video), "realize",
 				G_CALLBACK(realize_cb), data);
 		gtk_container_add(GTK_CONTAINER(aspect), remote_video);
@@ -822,7 +830,11 @@ pidgin_media_ready_cb(PurpleMedia *media
 		PidginMediaRealizeData *data;
 		GtkWidget *aspect;
 		GtkWidget *local_video;
+#if GTK_CHECK_VERSION(3,0,0)
+		GdkRGBA color = {0.0, 0.0, 0.0, 1.0};
+#else
 		GdkColor color = {0, 0, 0, 0};
+#endif
 
 		aspect = gtk_aspect_frame_new(NULL, 0, 0, 4.0/3.0, TRUE);
 		gtk_frame_set_shadow_type(GTK_FRAME(aspect), GTK_SHADOW_IN);
@@ -834,7 +846,11 @@ pidgin_media_ready_cb(PurpleMedia *media
 		data->participant = NULL;
 
 		local_video = gtk_drawing_area_new();
+#if GTK_CHECK_VERSION(3,0,0)
+		gtk_widget_override_background_color(local_video, GTK_STATE_FLAG_NORMAL, &color);
+#else
 		gtk_widget_modify_bg(local_video, GTK_STATE_NORMAL, &color);
+#endif
 		g_signal_connect(G_OBJECT(local_video), "realize",
 				G_CALLBACK(realize_cb), data);
 		gtk_container_add(GTK_CONTAINER(aspect), local_video);
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -4041,11 +4041,19 @@ make_video_test(GtkWidget *vbox)
 {
 	GtkWidget *test;
 	GtkWidget *video;
+#if GTK_CHECK_VERSION(3,0,0)
+	GdkRGBA color = {0.0, 0.0, 0.0, 1.0};
+#else
 	GdkColor color = {0, 0, 0, 0};
+#endif
 
 	video = gtk_drawing_area_new();
 	gtk_box_pack_start(GTK_BOX(vbox), video, TRUE, TRUE, 0);
+#if GTK_CHECK_VERSION(3,0,0)
+	gtk_widget_override_background_color(video, GTK_STATE_FLAG_NORMAL, &color);
+#else
 	gtk_widget_modify_bg(video, GTK_STATE_NORMAL, &color);
+#endif
 	gtk_widget_set_size_request(GTK_WIDGET(video), 240, 180);
 
 	test = gtk_toggle_button_new_with_label(_("Test Video"));



More information about the Commits mailing list