aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2009-04-21 03:04:59 +0800
committerLars-Peter Clausen <lars@metafoo.de>2009-04-21 18:30:41 +0800
commitbb1250cad11d6f4af2e9e77d1b9e7032c37192a0 (patch)
tree81c36838ca3d844e946933ec8032b7b0788b3cc9
parent0fdb1cd86abf74defbbf351ce7568b47d9d060da (diff)
downloadgsoc2013-empathy-bb1250cad11d6f4af2e9e77d1b9e7032c37192a0.tar
gsoc2013-empathy-bb1250cad11d6f4af2e9e77d1b9e7032c37192a0.tar.gz
gsoc2013-empathy-bb1250cad11d6f4af2e9e77d1b9e7032c37192a0.tar.bz2
gsoc2013-empathy-bb1250cad11d6f4af2e9e77d1b9e7032c37192a0.tar.lz
gsoc2013-empathy-bb1250cad11d6f4af2e9e77d1b9e7032c37192a0.tar.xz
gsoc2013-empathy-bb1250cad11d6f4af2e9e77d1b9e7032c37192a0.tar.zst
gsoc2013-empathy-bb1250cad11d6f4af2e9e77d1b9e7032c37192a0.zip
Instead of destroying the submenu when it's not needed only create it if there
is a submenu item.
-rw-r--r--libempathy-gtk/empathy-contact-menu.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index 7e5a86c80..2b1212836 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -360,9 +360,7 @@ empathy_contact_invite_menu_item_new (EmpathyContact *contact)
GtkWidget *room_item;
EmpathyChatroomManager *mgr;
GList *rooms, *l;
- GtkWidget *submenu;
- GtkMenuShell *submenu_shell;
- gboolean have_rooms = FALSE;
+ GtkWidget *submenu = NULL;
g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
@@ -375,29 +373,23 @@ empathy_contact_invite_menu_item_new (EmpathyContact *contact)
rooms = empathy_chatroom_manager_get_chatrooms (mgr,
empathy_contact_get_account (contact));
- /* create rooms sub menu */
- submenu = gtk_menu_new ();
- submenu_shell = GTK_MENU_SHELL (submenu);
-
for (l = rooms; l != NULL; l = g_list_next (l)) {
EmpathyChatroom *chatroom = l->data;
if (empathy_chatroom_get_tp_chat (chatroom) != NULL) {
- have_rooms = TRUE;
+ if (G_UNLIKELY (submenu == NULL))
+ submenu = gtk_menu_new ();
room_item = create_room_sub_menu (contact, chatroom);
- gtk_menu_shell_append (submenu_shell, room_item);
+ gtk_menu_shell_append ((GtkMenuShell*)submenu, room_item);
gtk_widget_show (room_item);
}
}
- if (have_rooms) {
+ if (submenu) {
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
} else {
gtk_widget_set_sensitive (item, FALSE);
- g_object_ref_sink (submenu);
- gtk_widget_destroy (submenu);
- g_object_unref (submenu);
}
gtk_widget_show (image);