From f1f0b2c029a92d3a6bb70e8f9dcefd89e0da01dc Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 7 Mar 2011 11:31:48 +0100 Subject: accounts_dialog_add_account: ensure that the selected account is still visible in the treeview --- src/empathy-accounts-dialog.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 2d8968c4b..ee601ac6b 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -1788,6 +1788,7 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, const gchar *name; gboolean enabled; EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + gboolean selected = FALSE; model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); status = tp_account_get_connection_status (account, NULL); @@ -1797,7 +1798,16 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, settings = empathy_account_settings_new_for_account (account); if (!accounts_dialog_get_account_iter (dialog, account, &iter)) - gtk_list_store_append (GTK_LIST_STORE (model), &iter); + { + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + } + else + { + GtkTreeSelection *selection; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)); + selected = gtk_tree_selection_iter_is_selected (selection, &iter); + } gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_NAME, name, @@ -1806,6 +1816,14 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog, COL_ACCOUNT_SETTINGS, settings, -1); + if (selected) + { + /* We just modified the selected account. Its display name may have been + * changed and so it's place in the treeview. Scroll to it so it stays + * visible. */ + select_and_scroll_to_iter (dialog, &iter); + } + accounts_dialog_connection_changed_cb (account, 0, status, -- cgit v1.2.3