diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-08-19 05:36:49 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-08-19 05:36:49 +0800 |
commit | ba0ca2274b9aa0a41c3b60a6bfd862aa385c3b45 (patch) | |
tree | 8841ffa1bf34b903705d40241ad69844de73c763 /src | |
parent | 55e9b194df4e863c4af4a0c4874d00d1e82fa8c5 (diff) | |
download | gsoc2013-empathy-ba0ca2274b9aa0a41c3b60a6bfd862aa385c3b45.tar gsoc2013-empathy-ba0ca2274b9aa0a41c3b60a6bfd862aa385c3b45.tar.gz gsoc2013-empathy-ba0ca2274b9aa0a41c3b60a6bfd862aa385c3b45.tar.bz2 gsoc2013-empathy-ba0ca2274b9aa0a41c3b60a6bfd862aa385c3b45.tar.lz gsoc2013-empathy-ba0ca2274b9aa0a41c3b60a6bfd862aa385c3b45.tar.xz gsoc2013-empathy-ba0ca2274b9aa0a41c3b60a6bfd862aa385c3b45.tar.zst gsoc2013-empathy-ba0ca2274b9aa0a41c3b60a6bfd862aa385c3b45.zip |
If adding a an account that is already in the treeview, simply update values. That happens when an account becomes valid
svn path=/trunk/; revision=1346
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-accounts-dialog.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 12cc00a58..977aeefbc 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -114,7 +114,7 @@ static void accounts_dialog_model_set_selected (EmpathyAccountsDial static gboolean accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog); static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection, EmpathyAccountsDialog *dialog); -static void accounts_dialog_add_account (EmpathyAccountsDialog *dialog, +static void accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog, McAccount *account); static void accounts_dialog_account_added_cb (McAccountMonitor *monitor, gchar *unique_name, @@ -596,8 +596,8 @@ accounts_dialog_model_selection_changed (GtkTreeSelection *selection, } static void -accounts_dialog_add_account (EmpathyAccountsDialog *dialog, - McAccount *account) +accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog, + McAccount *account) { GtkTreeModel *model; GtkTreeIter iter; @@ -605,26 +605,23 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, const gchar *name; gboolean enabled; - if (accounts_dialog_get_account_iter (dialog, account, &iter)) { - return; - } - + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); status = mission_control_get_connection_status (dialog->mc, account, NULL); name = mc_account_get_display_name (account); enabled = mc_account_is_enabled (account); - g_return_if_fail (name != NULL); + if (!accounts_dialog_get_account_iter (dialog, account, &iter)) { + DEBUG ("Adding new account"); + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + } - DEBUG ("Adding new account: %s", name); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_ENABLED, enabled, + COL_NAME, name, + COL_STATUS, status, + COL_ACCOUNT_POINTER, account, + -1); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview)); - gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, - -1, - COL_ENABLED, enabled, - COL_NAME, name, - COL_STATUS, status, - COL_ACCOUNT_POINTER, account, - -1); accounts_dialog_status_changed_cb (dialog->mc, status, MC_PRESENCE_UNSET, @@ -641,7 +638,7 @@ accounts_dialog_account_added_cb (McAccountMonitor *monitor, McAccount *account; account = mc_account_lookup (unique_name); - accounts_dialog_add_account (dialog, account); + accounts_dialog_add_or_update_account (dialog, account); g_object_unref (account); } @@ -811,7 +808,7 @@ accounts_dialog_button_create_clicked_cb (GtkWidget *button, } } - accounts_dialog_add_account (dialog, account); + accounts_dialog_add_or_update_account (dialog, account); accounts_dialog_model_set_selected (dialog, account); g_object_unref (account); @@ -1077,7 +1074,7 @@ empathy_accounts_dialog_show (GtkWindow *parent, /* Add existing accounts */ accounts = mc_accounts_list (); for (l = accounts; l; l = l->next) { - accounts_dialog_add_account (dialog, l->data); + accounts_dialog_add_or_update_account (dialog, l->data); g_object_unref (l->data); } g_list_free (accounts); |