From 9223336edde583afe690a3757d71188ed6ebf16d Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 1 Jun 2007 20:25:05 +0000 Subject: Monitor changes on chatrooms.xml file and relead it when it's modified. 2007-06-01 Xavier Claessens * libempathy-gtk/gossip-chatrooms-window.c: * libempathy-gtk/gossip-chat-window.c: * libempathy/gossip-chatroom.c: * libempathy/gossip-chatroom-manager.c: * configure.ac: Monitor changes on chatrooms.xml file and relead it when it's modified. connect chatroom-added/removed in some places where needed. svn path=/trunk/; revision=111 --- libempathy-gtk/gossip-chatrooms-window.c | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'libempathy-gtk/gossip-chatrooms-window.c') diff --git a/libempathy-gtk/gossip-chatrooms-window.c b/libempathy-gtk/gossip-chatrooms-window.c index 5ff5d8812..4d4333e8d 100644 --- a/libempathy-gtk/gossip-chatrooms-window.c +++ b/libempathy-gtk/gossip-chatrooms-window.c @@ -84,6 +84,13 @@ static void chatrooms_window_button_close_clicked_cb (GtkWid static void chatrooms_window_chatroom_added_cb (GossipChatroomManager *manager, GossipChatroom *chatroom, GossipChatroomsWindow *window); +static void chatrooms_window_chatroom_removed_cb (GossipChatroomManager *manager, + GossipChatroom *chatroom, + GossipChatroomsWindow *window); +static gboolean chatrooms_window_remove_chatroom_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + GossipChatroom *chatroom); static void chatrooms_window_account_changed_cb (GtkWidget *combo_box, GossipChatroomsWindow *window); @@ -139,6 +146,9 @@ gossip_chatrooms_window_show (GtkWindow *parent) g_signal_connect (window->manager, "chatroom-added", G_CALLBACK (chatrooms_window_chatroom_added_cb), window); + g_signal_connect (window->manager, "chatroom-removed", + G_CALLBACK (chatrooms_window_chatroom_removed_cb), + window); /* Account chooser for chat rooms */ window->account_chooser = gossip_account_chooser_new (); @@ -521,6 +531,41 @@ chatrooms_window_chatroom_added_cb (GossipChatroomManager *manager, } } +static void +chatrooms_window_chatroom_removed_cb (GossipChatroomManager *manager, + GossipChatroom *chatroom, + GossipChatroomsWindow *window) +{ + GtkTreeModel *model; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (window->treeview)); + + gtk_tree_model_foreach (model, + (GtkTreeModelForeachFunc) chatrooms_window_remove_chatroom_foreach, + chatroom); +} + +static gboolean +chatrooms_window_remove_chatroom_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + GossipChatroom *chatroom) +{ + GossipChatroom *this_chatroom; + + gtk_tree_model_get (model, iter, COL_POINTER, &this_chatroom, -1); + + if (gossip_chatroom_equal (chatroom, this_chatroom)) { + gtk_list_store_remove (GTK_LIST_STORE (model), iter); + g_object_unref (this_chatroom); + return TRUE; + } + + g_object_unref (this_chatroom); + + return FALSE; +} + static void chatrooms_window_account_changed_cb (GtkWidget *combo_box, GossipChatroomsWindow *window) -- cgit v1.2.3