pidgin: 2ed47bf7: Use the toolbar as the userdat to avoid ...

qulogic at pidgin.im qulogic at pidgin.im
Thu Jan 5 23:00:48 EST 2012


----------------------------------------------------------------------
Revision: 2ed47bf7b1d9282687f500154402e8ca1dba4b26
Parent:   dc7fdb516afcf5689d9c101d8fb0a1a3f667dfe8
Author:   qulogic at pidgin.im
Date:     01/05/12 04:16:22
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2ed47bf7b1d9282687f500154402e8ca1dba4b26

Changelog: 

Use the toolbar as the userdat to avoid g_object_[gs]et_data.

Changes against parent dc7fdb516afcf5689d9c101d8fb0a1a3f667dfe8

  patched  pidgin/gtkwebviewtoolbar.c

-------------- next part --------------
============================================================
--- pidgin/gtkwebviewtoolbar.c	78d98f15823236085879eda1068cf3ab9445b964
+++ pidgin/gtkwebviewtoolbar.c	a91f717a76fdff3bb7eaba230f8b453686b8d578
@@ -197,13 +197,13 @@ static void
 }
 
 static void
-apply_font(GtkWidget *widget, GtkFontSelectionDialog *fontsel)
+apply_font(GtkWidget *widget, GtkWebViewToolbar *toolbar)
 {
 	/* this could be expanded to include font size, weight, etc.
 	   but for now only works with font face */
+	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
+	GtkFontSelectionDialog *fontsel = GTK_FONT_SELECTION_DIALOG(priv->font_dialog);
 	gchar *fontname = gtk_font_selection_dialog_get_font_name(fontsel);
-	GtkWebViewToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel),
-	                                              "purple_toolbar");
 
 	if (fontname) {
 		const gchar *family_name = NULL;
@@ -237,8 +237,6 @@ toggle_font(GtkWidget *font, GtkWebViewT
 		if (!priv->font_dialog) {
 			priv->font_dialog = gtk_font_selection_dialog_new(_("Select Font"));
 
-			g_object_set_data(G_OBJECT(priv->font_dialog), "purple_toolbar", toolbar);
-
 			if (fontname) {
 				char *fonttif = g_strdup_printf("%s 12", fontname);
 				gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(priv->font_dialog),
@@ -252,12 +250,13 @@ toggle_font(GtkWidget *font, GtkWebViewT
 			g_signal_connect(G_OBJECT(priv->font_dialog), "delete_event",
 							 G_CALLBACK(destroy_toolbar_font), toolbar);
 			g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(priv->font_dialog)->ok_button), "clicked",
-							 G_CALLBACK(apply_font), priv->font_dialog);
+							 G_CALLBACK(apply_font), toolbar);
 			g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(priv->font_dialog)->cancel_button), "clicked",
 							 G_CALLBACK(cancel_toolbar_font), toolbar);
 			g_signal_connect_after(G_OBJECT(priv->font_dialog), "realize",
 							 G_CALLBACK(realize_toolbar_font), toolbar);
 		}
+
 		gtk_window_present(GTK_WINDOW(priv->font_dialog));
 	} else {
 		cancel_toolbar_font(font, toolbar);
@@ -291,12 +290,17 @@ static void
 }
 
 static void
-do_fgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
+do_fgcolor(GtkWidget *widget, GtkWebViewToolbar *toolbar)
 {
+	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
+	GtkColorSelectionDialog *dialog;
+	GtkColorSelection *colorsel;
 	GdkColor text_color;
-	GtkWebViewToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "purple_toolbar");
 	char *open_tag;
 
+	dialog = GTK_COLOR_SELECTION_DIALOG(priv->fgcolor_dialog);
+	colorsel = GTK_COLOR_SELECTION(dialog->colorsel);
+
 	open_tag = g_malloc(30);
 	gtk_color_selection_get_current_color(colorsel, &text_color);
 	g_snprintf(open_tag, 23, "#%02X%02X%02X",
@@ -319,7 +323,6 @@ toggle_fg_color(GtkWidget *color, GtkWeb
 		const char *color = gtk_webview_get_current_forecolor(GTK_WEBVIEW(toolbar->webview));
 
 		if (!priv->fgcolor_dialog) {
-
 			priv->fgcolor_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
 			colorsel = GTK_COLOR_SELECTION_DIALOG(priv->fgcolor_dialog)->colorsel;
 			if (color) {
@@ -327,15 +330,14 @@ toggle_fg_color(GtkWidget *color, GtkWeb
 				gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &fgcolor);
 			}
 
-			g_object_set_data(G_OBJECT(colorsel), "purple_toolbar", toolbar);
-
 			g_signal_connect(G_OBJECT(priv->fgcolor_dialog), "delete_event",
 							 G_CALLBACK(destroy_toolbar_fgcolor), toolbar);
 			g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(priv->fgcolor_dialog)->ok_button), "clicked",
-							 G_CALLBACK(do_fgcolor), colorsel);
+							 G_CALLBACK(do_fgcolor), toolbar);
 			g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(priv->fgcolor_dialog)->cancel_button), "clicked",
 							 G_CALLBACK(cancel_toolbar_fgcolor), toolbar);
 		}
+
 		gtk_window_present(GTK_WINDOW(priv->fgcolor_dialog));
 	} else {
 		cancel_toolbar_fgcolor(color, toolbar);
@@ -374,12 +376,17 @@ static void
 }
 
 static void
-do_bgcolor(GtkWidget *widget, GtkColorSelection *colorsel)
+do_bgcolor(GtkWidget *widget, GtkWebViewToolbar *toolbar)
 {
+	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
+	GtkColorSelectionDialog *dialog;
+	GtkColorSelection *colorsel;
 	GdkColor text_color;
-	GtkWebViewToolbar *toolbar = g_object_get_data(G_OBJECT(colorsel), "purple_toolbar");
 	char *open_tag;
 
+	dialog = GTK_COLOR_SELECTION_DIALOG(priv->bgcolor_dialog);
+	colorsel = GTK_COLOR_SELECTION(dialog->colorsel);
+
 	open_tag = g_malloc(30);
 	gtk_color_selection_get_current_color(colorsel, &text_color);
 	g_snprintf(open_tag, 23, "#%02X%02X%02X",
@@ -407,7 +414,6 @@ toggle_bg_color(GtkWidget *color, GtkWeb
 		const char *color = gtk_webview_get_current_backcolor(GTK_WEBVIEW(toolbar->webview));
 
 		if (!priv->bgcolor_dialog) {
-
 			priv->bgcolor_dialog = gtk_color_selection_dialog_new(_("Select Background Color"));
 			colorsel = GTK_COLOR_SELECTION_DIALOG(priv->bgcolor_dialog)->colorsel;
 			if (color) {
@@ -415,16 +421,14 @@ toggle_bg_color(GtkWidget *color, GtkWeb
 				gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel), &bgcolor);
 			}
 
-			g_object_set_data(G_OBJECT(colorsel), "purple_toolbar", toolbar);
-
 			g_signal_connect(G_OBJECT(priv->bgcolor_dialog), "delete_event",
 							 G_CALLBACK(destroy_toolbar_bgcolor), toolbar);
 			g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(priv->bgcolor_dialog)->ok_button), "clicked",
-							 G_CALLBACK(do_bgcolor), colorsel);
+							 G_CALLBACK(do_bgcolor), toolbar);
 			g_signal_connect(G_OBJECT(GTK_COLOR_SELECTION_DIALOG(priv->bgcolor_dialog)->cancel_button), "clicked",
 							 G_CALLBACK(cancel_toolbar_bgcolor), toolbar);
-
 		}
+
 		gtk_window_present(GTK_WINDOW(priv->bgcolor_dialog));
 	} else {
 		cancel_toolbar_bgcolor(color, toolbar);


More information about the Commits mailing list