aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-accounts-dialog.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2009-07-25 03:24:38 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-07-30 06:13:20 +0800
commit6d59456848be4257df0724a610ef224d8c1d2e84 (patch)
treeb921e2e64445658455a4c42a90d944395c9e4d0a /src/empathy-accounts-dialog.c
parente3ed5ba84d20da177070d4708bca4bdb9d0ee149 (diff)
downloadgsoc2013-empathy-6d59456848be4257df0724a610ef224d8c1d2e84.tar
gsoc2013-empathy-6d59456848be4257df0724a610ef224d8c1d2e84.tar.gz
gsoc2013-empathy-6d59456848be4257df0724a610ef224d8c1d2e84.tar.bz2
gsoc2013-empathy-6d59456848be4257df0724a610ef224d8c1d2e84.tar.lz
gsoc2013-empathy-6d59456848be4257df0724a610ef224d8c1d2e84.tar.xz
gsoc2013-empathy-6d59456848be4257df0724a610ef224d8c1d2e84.tar.zst
gsoc2013-empathy-6d59456848be4257df0724a610ef224d8c1d2e84.zip
Make sure the account dialog respects the initial selection
Diffstat (limited to 'src/empathy-accounts-dialog.c')
-rw-r--r--src/empathy-accounts-dialog.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 3b5386606..a9a5e7f63 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -96,8 +96,8 @@ typedef struct {
EmpathyAccountManager *account_manager;
EmpathyConnectionManagers *cms;
- EmpathyAccount *selected_account;
GtkWindow *parent_window;
+ EmpathyAccount *initial_selection;
} EmpathyAccountsDialogPriv;
enum {
@@ -110,8 +110,7 @@ enum {
};
enum {
- PROP_SELECTED_ACCOUNT = 1,
- PROP_PARENT
+ PROP_PARENT = 1
};
static void accounts_dialog_update (EmpathyAccountsDialog *dialog,
@@ -1202,12 +1201,33 @@ accounts_dialog_destroy_cb (GtkObject *obj,
}
static void
+accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog,
+ EmpathyAccount *account)
+{
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+ if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
+ gtk_tree_selection_select_iter (selection, &iter);
+ }
+}
+
+static void
accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms,
GParamSpec *pspec,
EmpathyAccountsDialog *dialog)
{
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
if (empathy_connection_managers_is_ready (cms)) {
accounts_dialog_update_settings (dialog, NULL);
+
+ if (priv->initial_selection != NULL) {
+ accounts_dialog_set_selected_account (dialog, priv->initial_selection);
+ priv->initial_selection = NULL;
+ }
}
}
@@ -1346,9 +1366,6 @@ do_get_property (GObject *object,
case PROP_PARENT:
g_value_set_object (value, priv->parent_window);
break;
- case PROP_SELECTED_ACCOUNT:
- g_value_set_object (value, priv->selected_account);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -1366,9 +1383,6 @@ do_set_property (GObject *object,
case PROP_PARENT:
priv->parent_window = g_value_get_object (value);
break;
- case PROP_SELECTED_ACCOUNT:
- priv->selected_account = g_value_get_object (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -1422,19 +1436,7 @@ do_constructed (GObject *object)
G_CALLBACK (accounts_dialog_cms_ready_cb), dialog);
}
- if (priv->selected_account) {
- GtkTreeSelection *selection;
- GtkTreeIter iter;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
- if (accounts_dialog_get_account_iter (dialog, priv->selected_account, &iter)) {
- gtk_tree_selection_select_iter (selection, &iter);
- }
-
- priv->selected_account = NULL;
- } else {
- accounts_dialog_model_select_first (dialog);
- }
+ accounts_dialog_model_select_first (dialog);
empathy_conf_get_bool (empathy_conf_get (),
EMPATHY_PREFS_IMPORT_ASKED, &import_asked);
@@ -1474,13 +1476,6 @@ empathy_accounts_dialog_class_init (EmpathyAccountsDialogClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (oclass, PROP_PARENT, param_spec);
- param_spec = g_param_spec_object ("selected-account",
- "selected-account", "The account selected by default",
- EMPATHY_TYPE_ACCOUNT,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (oclass, PROP_SELECTED_ACCOUNT, param_spec);
-
-
g_type_class_add_private (klass, sizeof (EmpathyAccountsDialogPriv));
}
@@ -1505,10 +1500,19 @@ empathy_accounts_dialog_show (GtkWindow *parent,
EmpathyAccountsDialogPriv *priv;
dialog = g_object_new (EMPATHY_TYPE_ACCOUNTS_DIALOG,
- "parent", parent, "selected-account", selected_account, NULL);
+ "parent", parent, NULL);
priv = GET_PRIV (dialog);
+ if (selected_account && empathy_connection_managers_is_ready (priv->cms)) {
+ accounts_dialog_set_selected_account (dialog, selected_account);
+ } else {
+ /* save the selection to set it later when the cms
+ * becomes ready.
+ */
+ priv->initial_selection = selected_account;
+ }
+
gtk_window_present (GTK_WINDOW (priv->window));
return priv->window;