pidgin: 8e8e913f: Use GtkSetting to obtain the tooltip pre...

rlaager at pidgin.im rlaager at pidgin.im
Thu Oct 30 18:55:51 EDT 2008


-----------------------------------------------------------------
Revision: 8e8e913ff6040c262bb364188317b5567707317a
Ancestor: 9287a75e196278c66cd6724dc8d30a471a029c27
Author: rlaager at pidgin.im
Date: 2008-10-30T19:53:55
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8e8e913ff6040c262bb364188317b5567707317a

Modified files:
        ChangeLog pidgin/gtkblist.c pidgin/pidgintooltip.c

ChangeLog: 

Use GtkSetting to obtain the tooltip preferences instead of our own hidden
pref, when compiling against GTK+ 2.14 or higher.

-------------- next part --------------
============================================================
--- ChangeLog	42316ef00a0c9d18d11be3959538ae0547cf99a4
+++ ChangeLog	943ba05782fab0e0e9098a583c2fdbd5acc6b4ae
@@ -8,6 +8,16 @@ version 2.5.3 (??/??/????):
 	  --with-system-ssl-certs and GnuTLS need to include these in the
 	  system certs directory.
 
+	Pidgin:
+	* On GTK+ 2.14 and higher, we're using the gtk-tooltip-delay setting
+	  instead of our own (hidden) tooltip_delay pref.  If you had
+	  previously changed that pref, add a line like this to
+	  ~/.purple/gtkrc-2.0 (where 500 is the timeout (in ms) you want):
+	      gtk-tooltip-timeout = 500
+	  To completely disable tooltips (e.g. if you had an old tooltip_delay
+	  of zero), add this to ~/.purple/gtkrc-2.0:
+	      gtk-enable-tooltips = 0
+
 version 2.5.2 (10/19/2008):
 	libpurple:
 	* Fixed a crash on removing a custom buddy icon on a buddy.
============================================================
--- pidgin/gtkblist.c	a26446cada992c9ef64bdb8d376142b79839e5c9
+++ pidgin/gtkblist.c	74ea6d58b22faa960fddd092a9e8521acca613a9
@@ -7177,7 +7177,10 @@ void pidgin_blist_init(void)
 	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/blist/y", 0);
 	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/blist/width", 250); /* Golden ratio, baby */
 	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/blist/height", 405); /* Golden ratio, baby */
+#if !GTK_CHECK_VERSION(2,14,0)
+	/* This pref is used in pidgintooltip.c. */
 	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay", 500);
+#endif
 
 	/* Register our signals */
 	purple_signal_register(gtk_blist_handle, "gtkblist-hiding",
============================================================
--- pidgin/pidgintooltip.c	924ac807d14104886d3e96b2e6456238c621b4a8
+++ pidgin/pidgintooltip.c	86b0882aa193ee32a7e9b0f3599d83a8af263b08
@@ -30,6 +30,9 @@
 #include "pidgintooltip.h"
 #include "debug.h"
 
+static gboolean enable_tooltips;
+static int tooltip_delay = -1;
+
 struct
 {
 	GtkWidget *widget;
@@ -56,6 +59,25 @@ static void
 } PidginTooltipData;
 
 static void
+initialize_tooltip_delay()
+{
+	GtkSettings *settings;
+
+	if (tooltip_delay != -1)
+		return;
+
+#if GTK_CHECK_VERSION(2,14,0)
+	settings = gtk_settings_get_default();
+
+	g_object_get(settings, "gtk-enable-tooltips", &enable_tooltips, NULL);
+	g_object_get(settings, "gtk-tooltip-timeout", &tooltip_delay, NULL);
+#else
+	tooltip_delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay");
+	enable_tooltips = (tooltip_delay != 0);
+#endif
+}
+
+static void
 destroy_tooltip_data(PidginTooltipData *data)
 {
 	gtk_tree_path_free(data->common.treeview.path);
@@ -280,14 +302,12 @@ row_motion_cb(GtkWidget *tv, GdkEventMot
 row_motion_cb(GtkWidget *tv, GdkEventMotion *event, gpointer userdata)
 {
 	GtkTreePath *path;
-	int delay;
 
 	if (event->window != gtk_tree_view_get_bin_window(GTK_TREE_VIEW(tv)))
 		return FALSE;    /* The cursor is probably on the TreeView's header. */
 
-	/* XXX: probably use something more generic? */
-	delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay");
-	if (delay == 0)
+	initialize_tooltip_delay();
+	if (!enable_tooltips)
 		return FALSE;
 
 	if (pidgin_tooltip.timeout) {
@@ -307,7 +327,7 @@ row_motion_cb(GtkWidget *tv, GdkEventMot
 	gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &pidgin_tooltip.tip_rect);
 	gtk_tree_path_free(path);
 
-	pidgin_tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_tooltip_timeout, userdata);
+	pidgin_tooltip.timeout = g_timeout_add(tooltip_delay, (GSourceFunc)pidgin_tooltip_timeout, userdata);
 
 	return FALSE;
 }
@@ -337,13 +357,13 @@ widget_motion_cb(GtkWidget *widget, GdkE
 static gboolean
 widget_motion_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-	int delay = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/tooltip_delay");
+	initialize_tooltip_delay();
 
 	pidgin_tooltip_destroy();
-	if (delay == 0)
+	if (!enable_tooltips)
 		return FALSE;
 
-	pidgin_tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_tooltip_timeout, data);
+	pidgin_tooltip.timeout = g_timeout_add(tooltip_delay, (GSourceFunc)pidgin_tooltip_timeout, data);
 	return FALSE;
 }
 


More information about the Commits mailing list