aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-08-30 00:04:54 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-08-30 00:04:54 +0800
commitd14f7c7fe5f82da3f5e9ad6bcb73dd931ddbcd6d (patch)
treea73e47505d2573d5ade3deed9bb52253d3d854ef /src
parentf072481137b81850c18db4272bcc729e04dbffc0 (diff)
downloadgsoc2013-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')
-rw-r--r--src/empathy-chat-window.c28
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,