pidgin: 9cbb69e0: As described in the ChangeLog:

rlaager at pidgin.im rlaager at pidgin.im
Sat May 10 04:20:50 EDT 2008


-----------------------------------------------------------------
Revision: 9cbb69e06e19c581b9691f6acb2c48f204050dd6
Ancestor: 6884edec6238b2b587fc5902763fd6186d6949b0
Author: rlaager at pidgin.im
Date: 2008-05-10T08:17:53
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/9cbb69e06e19c581b9691f6acb2c48f204050dd6

Modified files:
        ChangeLog pidgin/gtkimhtmltoolbar.c

ChangeLog: 

As described in the ChangeLog:
        * The formatting toolbar will now respect your system-wide GTK+ toolbar
          setting (to the extent possible with our two choices).  You can still
          override it by right-clicking on the formatting toolbar.

-------------- next part --------------
============================================================
--- ChangeLog	79712a51bc722eb8813ca8646c6c114727695154
+++ ChangeLog	431cfdf19ab0d719e460fdfc880f833d06348bc5
@@ -39,6 +39,9 @@ version 2.x.x:
 	  lines.
 	* Moved the "Local alias" field in the Modify Account dialog to be below
 	  the "User Options" heading on the "Basic" tab.
+	* The formatting toolbar will now respect your system-wide GTK+ toolbar
+	  setting (to the extent possible with our two choices).  You can still
+	  override it by right-clicking on the formatting toolbar.
 
 	General:
 	* The configure script now dies on more absent dependencies.  The
============================================================
--- pidgin/gtkimhtmltoolbar.c	bb0f6cb4e8a66237645d15ecb440332f6444b5b6
+++ pidgin/gtkimhtmltoolbar.c	f05b05b7d41e8bfa55f1fbcd4342da9cbcf68eb8
@@ -42,12 +42,49 @@ static GtkHBoxClass *parent_class = NULL
 #include <gdk/gdkkeysyms.h>
 
 static GtkHBoxClass *parent_class = NULL;
+static GtkSettings *settings = NULL;
 
 static void toggle_button_set_active_block(GtkToggleButton *button,
 										   gboolean is_active,
 										   GtkIMHtmlToolbar *toolbar);
 
+static gboolean get_gtk_wide(void);
 
+/* If we're not overriding GTK+, grab its potentially new default and use that. */
+static void toolbar_style_changed_cb(GObject *obj, GParamSpec *pspec, gpointer data)
+{
+	/* If we're not overriding GTK+, grab its potentially new default and use that.
+	 * Otherwise, if the potentially new default matches the user's setting, we
+	 * no longer want to override. */
+        if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/override_gtk"))
+        {
+                purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
+                                get_gtk_wide());
+        }
+	else
+	{
+		gboolean gtk_wide = get_gtk_wide();
+		gboolean pidgin_wide = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide");
+		purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/override_gtk", (gtk_wide != pidgin_wide));
+	}
+}
+
+static gboolean get_gtk_wide()
+{
+	gint style;
+
+	if (settings == NULL)
+	{
+		settings = gtk_settings_get_default();
+		g_signal_connect(settings, "notify::gtk-toolbar-style",
+		                 G_CALLBACK(toolbar_style_changed_cb), NULL);
+	}
+
+	g_object_get(settings, "gtk-toolbar-style", &style, NULL);
+
+	return (style == GTK_TOOLBAR_ICONS);
+}
+
 static void do_bold(GtkWidget *bold, GtkIMHtmlToolbar *toolbar)
 {
 	g_return_if_fail(toolbar != NULL);
@@ -1033,10 +1070,16 @@ static void
 }
 
 static void
-switch_toolbar_view(GtkWidget *item, GtkIMHtmlToolbar *toolbar)
+switch_toolbar_view(GtkWidget *item, gpointer data)
 {
-	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
-			!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide"));
+	gboolean gtk_wide;    /* The current GTK+ default. */
+	gboolean pidgin_wide; /* The desired Pidgin setting. */
+
+	gtk_wide = get_gtk_wide();
+	pidgin_wide = !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide");
+
+	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/override_gtk", (gtk_wide != pidgin_wide));
+	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide", pidgin_wide);
 }
 
 static gboolean
@@ -1053,7 +1096,7 @@ gtk_imhtmltoolbar_popup_menu(GtkWidget *
 
 	menu = gtk_menu_new();
 	item = gtk_menu_item_new_with_mnemonic(wide ? _("Group Items") : _("Ungroup Items"));
-	g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(switch_toolbar_view), toolbar);
+	g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(switch_toolbar_view), NULL);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 	gtk_widget_show(item);
 
@@ -1074,6 +1117,7 @@ static void gtk_imhtmltoolbar_class_init
 
 	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations/toolbar");
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/wide", FALSE);
+	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/toolbar/override_gtk", FALSE);
 }
 
 static void gtk_imhtmltoolbar_create_old_buttons(GtkIMHtmlToolbar *toolbar)
@@ -1313,6 +1357,7 @@ static void gtk_imhtmltoolbar_init (GtkI
 	g_object_set_data(G_OBJECT(hbox), "lean-view", box);
 	gtk_widget_show(box);
 
+	toolbar_style_changed_cb(NULL, NULL, NULL);
 	purple_prefs_connect_callback(toolbar, PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
 			imhtmltoolbar_view_pref_changed, toolbar);
 	g_signal_connect_data(G_OBJECT(toolbar), "realize",


More information about the Commits mailing list