changeset 24282:d38d854cd0bf

Use GtkSetting to obtain the tooltip preferences instead of our own hidden pref, when compiling against GTK+ 2.14 or higher.
author Richard Laager <rlaager@wiktel.com>
date Thu, 30 Oct 2008 19:53:55 +0000
parents c06b85e1d020
children a41e0d8ddae4
files ChangeLog pidgin/gtkblist.c pidgin/pidgintooltip.c
diffstat 3 files changed, 41 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Oct 30 05:41:19 2008 +0000
+++ b/ChangeLog	Thu Oct 30 19:53:55 2008 +0000
@@ -8,6 +8,16 @@
 	  --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.
--- a/pidgin/gtkblist.c	Thu Oct 30 05:41:19 2008 +0000
+++ b/pidgin/gtkblist.c	Thu Oct 30 19:53:55 2008 +0000
@@ -7177,7 +7177,10 @@
 	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",
--- a/pidgin/pidgintooltip.c	Thu Oct 30 05:41:19 2008 +0000
+++ b/pidgin/pidgintooltip.c	Thu Oct 30 19:53:55 2008 +0000
@@ -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 @@
 } 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, 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 @@
 	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 @@
 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;
 }