From 7cbe28b6cfc22744a0a6079213b9614d87bf22ad Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 3 Feb 2011 11:07:06 +0100 Subject: contact-list-view: backport fixes from individual_view_popup_menu_idle_cb --- libempathy-gtk/empathy-contact-list-view.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index cccfebb51..4ab3607ec 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); -- cgit v1.2.3