static void chatrooms_window_model_refresh_data (EmpathyChatroomsWindow *window, gboolean first_time) { GtkTreeView *view; GtkTreeSelection *selection; GtkTreeModel *model; GtkListStore *store; GtkTreeIter iter; GtkTreeViewColumn *column; EmpathyAccountChooser *account_chooser; EmpathyAccount *account; GList *chatrooms, *l; view = GTK_TREE_VIEW (window->treeview); selection = gtk_tree_view_get_selection (view); model = gtk_tree_view_get_model (view); store = GTK_LIST_STORE (model); /* Look up chatrooms */ account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser); account = empathy_account_chooser_dup_account (account_chooser); chatrooms = empathy_chatroom_manager_get_chatrooms (window->manager, account); /* Sort out columns, we only show the server column for * selected protocol types, such as Jabber. */ if (account) { column = gtk_tree_view_get_column (view, window->room_column); gtk_tree_view_column_set_visible (column, TRUE); } else { column = gtk_tree_view_get_column (view, window->room_column); gtk_tree_view_column_set_visible (column, FALSE); } /* Clean out the store */ gtk_list_store_clear (store); /* Populate with chatroom list. */ for (l = chatrooms; l; l = l->next) { chatrooms_window_model_add (window, l->data, FALSE); } if (gtk_tree_model_get_iter_first (model, &iter)) { gtk_tree_selection_select_iter (selection, &iter); } if (account) { g_object_unref (account); } g_list_free (chatrooms); }
static void chatrooms_window_chatroom_added_cb (EmpathyChatroomManager *manager, EmpathyChatroom *chatroom, EmpathyChatroomsWindow *window) { EmpathyAccountChooser *account_chooser; TpAccount *account; account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser); account = empathy_account_chooser_dup_account (account_chooser); if (!account) { chatrooms_window_model_add (window, chatroom, FALSE); } else { if (account == empathy_chatroom_get_account (chatroom)) { chatrooms_window_model_add (window, chatroom, FALSE); } g_object_unref (account); } }