diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2009-04-21 03:04:59 +0800 |
---|---|---|
committer | Lars-Peter Clausen <lars@metafoo.de> | 2009-04-21 16:42:14 +0800 |
commit | d0fcb58a5ffb5e4025dcac522e3dbc94930c4124 (patch) | |
tree | 23c3ef4fc26b46248ac3402513c74dd5493d1e1c /libempathy-gtk | |
parent | b2121beb130e23425c0cd50deac2ac981af610f3 (diff) | |
download | gsoc2013-empathy-d0fcb58a5ffb5e4025dcac522e3dbc94930c4124.tar gsoc2013-empathy-d0fcb58a5ffb5e4025dcac522e3dbc94930c4124.tar.gz gsoc2013-empathy-d0fcb58a5ffb5e4025dcac522e3dbc94930c4124.tar.bz2 gsoc2013-empathy-d0fcb58a5ffb5e4025dcac522e3dbc94930c4124.tar.lz gsoc2013-empathy-d0fcb58a5ffb5e4025dcac522e3dbc94930c4124.tar.xz gsoc2013-empathy-d0fcb58a5ffb5e4025dcac522e3dbc94930c4124.tar.zst gsoc2013-empathy-d0fcb58a5ffb5e4025dcac522e3dbc94930c4124.zip |
Instead of destroying the submenu when it's not needed only create it if there
is a submenu item.
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-contact-menu.c | 18 |
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); |