/pidgin/main: 142968b1ac07: Hide tooltips field from PidginMenuT...

Elliott Sales de Andrade qulogic at pidgin.im
Tue Jul 24 04:03:44 EDT 2012


Changeset: 142968b1ac079c6b22cf7c5c3276f0f6aa9ed605
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2012-07-23 03:25 -0400
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/142968b1ac07

Description:

Hide tooltips field from PidginMenuTray.

We don't really use the grouping functionality, so we can just use one
tooltip object for all menu tray objects.

diffstat:

 pidgin/gtkmenutray.c |  36 ++++++++++++++++++++++++------------
 pidgin/gtkmenutray.h |   3 ---
 2 files changed, 24 insertions(+), 15 deletions(-)

diffs (95 lines):

diff --git a/pidgin/gtkmenutray.c b/pidgin/gtkmenutray.c
--- a/pidgin/gtkmenutray.c
+++ b/pidgin/gtkmenutray.c
@@ -35,6 +35,9 @@
  * Globals
  *****************************************************************************/
 static GObjectClass *parent_class = NULL;
+#if !GTK_CHECK_VERSION(2,12,0)
+static GtkTooltips *tooltips = NULL;
+#endif
 
 /******************************************************************************
  * Internal Stuff
@@ -65,6 +68,16 @@
 /******************************************************************************
  * Widget Stuff
  *****************************************************************************/
+#if !GTK_CHECK_VERSION(2,12,0)
+static void
+tooltips_unref_cb(gpointer data, GObject *object, gboolean is_last_ref)
+{
+	if (is_last_ref) {
+		g_object_unref(tooltips);
+		tooltips = NULL;
+	}
+}
+#endif
 
 /******************************************************************************
  * Object Stuff
@@ -96,10 +109,9 @@
 static void
 pidgin_menu_tray_finalize(GObject *obj)
 {
-#if !GTK_CHECK_VERSION(2,12,0)
+#if 0
 	PidginMenuTray *tray = PIDGIN_MENU_TRAY(obj);
-#endif
-#if 0
+
 	/* This _might_ be leaking, but I have a sneaking suspicion that the widget is
 	 * getting destroyed in GtkContainer's finalize function.  But if were are
 	 * leaking here, be sure to figure out why this causes a crash.
@@ -110,12 +122,6 @@
 		gtk_widget_destroy(GTK_WIDGET(tray->tray));
 #endif
 
-#if !GTK_CHECK_VERSION(2,12,0)
-	if (tray->tooltips) {
-		gtk_object_sink(GTK_OBJECT(tray->tooltips));
-	}
-#endif
-
 	G_OBJECT_CLASS(parent_class)->finalize(obj);
 }
 
@@ -247,8 +253,11 @@
 pidgin_menu_tray_set_tooltip(PidginMenuTray *menu_tray, GtkWidget *widget, const char *tooltip)
 {
 #if !GTK_CHECK_VERSION(2,12,0)
-	if (!menu_tray->tooltips)
-		menu_tray->tooltips = gtk_tooltips_new();
+	gboolean notify_tooltips = FALSE;
+	if (!tooltips) {
+		tooltips = gtk_tooltips_new();
+		notify_tooltips = TRUE;
+	}
 #endif
 
 	/* Should we check whether widget is a child of menu_tray? */
@@ -266,7 +275,10 @@
 #if GTK_CHECK_VERSION(2,12,0)
 	gtk_widget_set_tooltip_text(widget, tooltip);
 #else
-	gtk_tooltips_set_tip(menu_tray->tooltips, widget, tooltip, NULL);
+	gtk_tooltips_set_tip(tooltips, widget, tooltip, NULL);
+
+	if (notify_tooltips)
+		g_object_add_toggle_ref(G_OBJECT(tooltips), tooltips_unref_cb, NULL);
 #endif
 }
 
diff --git a/pidgin/gtkmenutray.h b/pidgin/gtkmenutray.h
--- a/pidgin/gtkmenutray.h
+++ b/pidgin/gtkmenutray.h
@@ -40,9 +40,6 @@
 struct _PidginMenuTray {
 	GtkMenuItem gparent;					/**< The parent instance */
 	GtkWidget *tray;						/**< The tray */
-#if !GTK_CHECK_VERSION(2,12,0)
-	GtkTooltips *tooltips;					/**< Tooltips */
-#endif
 };
 
 /** A PidginMenuTrayClass */



More information about the Commits mailing list