[empathy] contact-list-view: backport fixes from individual_view_popup_menu_idle_cb



commit 7cbe28b6cfc22744a0a6079213b9614d87bf22ad
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Thu Feb 3 11:07:06 2011 +0100

    contact-list-view: backport fixes from individual_view_popup_menu_idle_cb

 libempathy-gtk/empathy-contact-list-view.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index cccfebb..4ab3607 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -804,6 +804,17 @@ typedef struct {
 	guint32                 time;
 } MenuPopupData;
 
+static void
+menu_deactivate_cb (GtkMenuShell *menushell,
+		    gpointer user_data)
+{
+	gtk_menu_detach (GTK_MENU (menushell));
+
+	/* FIXME: we shouldn't have to disconnec the signal (bgo #641327) */
+	g_signal_handlers_disconnect_by_func (menushell,
+		menu_deactivate_cb, user_data);
+}
+
 static gboolean
 contact_list_view_popup_menu_idle_cb (gpointer user_data)
 {
@@ -822,8 +833,15 @@ contact_list_view_popup_menu_idle_cb (gpointer user_data)
 		gtk_menu_popup (GTK_MENU (menu),
 				NULL, NULL, NULL, NULL,
 				data->button, data->time);
-		g_object_ref_sink (menu);
-		g_object_unref (menu);
+
+		/* menu is initially unowned but gtk_menu_attach_to_widget() taked its
+		 * floating ref. We can either wait that the treeview releases its ref
+		 * when it will be destroyed (when leaving Empathy) or explicitely
+		 * detach the menu when it's not displayed any more.
+		 * We go for the latter as we don't want to keep useless menus in memory
+		 * during the whole lifetime of Empathy. */
+		g_signal_connect (menu, "deactivate", G_CALLBACK (menu_deactivate_cb),
+			NULL);
 	}
 
 	g_slice_free (MenuPopupData, data);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]