diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-08-30 00:04:54 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-08-30 00:04:54 +0800 |
commit | d14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d (patch) | |
tree | a73e47505d2573d5ade3deed9bb52253d3d854ef /src/empathy-chat-window.c | |
parent | f072481137b81850c18db4272bcc729e04dbffc0 (diff) | |
download | gsoc2013-empathy-d14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d.tar gsoc2013-empathy-d14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d.tar.gz gsoc2013-empathy-d14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d.tar.bz2 gsoc2013-empathy-d14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d.tar.lz gsoc2013-empathy-d14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d.tar.xz gsoc2013-empathy-d14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d.tar.zst gsoc2013-empathy-d14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d.zip |
Do not create a new EmpathyChatroom is it already exists.
svn path=/trunk/; revision=1402
Diffstat (limited to 'src/empathy-chat-window.c')
-rw-r--r-- | src/empathy-chat-window.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 73c41a9f0..5d15d58b1 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -518,27 +518,35 @@ chat_window_clear_activate_cb (GtkWidget *menuitem, } static void -chat_window_favorite_activate_cb (GtkWidget *menuitem, - EmpathyChatWindow *window) +chat_window_favorite_toggled_cb (GtkCheckMenuItem *menuitem, + EmpathyChatWindow *window) { EmpathyChatWindowPriv *priv = GET_PRIV (window); + gboolean active; McAccount *account; const gchar *room; - const gchar *name; EmpathyChatroom *chatroom; + active = gtk_check_menu_item_get_active (menuitem); account = empathy_chat_get_account (priv->current_chat); room = empathy_chat_get_id (priv->current_chat); - name = empathy_chat_get_name (priv->current_chat); - chatroom = empathy_chatroom_new_full (account, room, name, FALSE); - if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (priv->menu_conv_favorite))) { + chatroom = empathy_chatroom_manager_find (priv->chatroom_manager, + account, room); + + if (active && !chatroom) { + const gchar *name; + + name = empathy_chat_get_name (priv->current_chat); + chatroom = empathy_chatroom_new_full (account, room, name, FALSE); empathy_chatroom_manager_add (priv->chatroom_manager, chatroom); - } else { + g_object_unref (chatroom); + return; + } + + if (!active && chatroom) { empathy_chatroom_manager_remove (priv->chatroom_manager, chatroom); } - - g_object_unref (chatroom); } static const gchar * @@ -1194,7 +1202,7 @@ empathy_chat_window_init (EmpathyChatWindow *window) "chat_window", "configure-event", chat_window_configure_event_cb, "menu_conv", "activate", chat_window_conv_activate_cb, "menu_conv_clear", "activate", chat_window_clear_activate_cb, - "menu_conv_favorite", "activate", chat_window_favorite_activate_cb, + "menu_conv_favorite", "toggled", chat_window_favorite_toggled_cb, "menu_conv_close", "activate", chat_window_close_activate_cb, "menu_edit", "activate", chat_window_edit_activate_cb, "menu_edit_cut", "activate", chat_window_cut_activate_cb, |