diff options
author | Travis Reitter <treitter@gmail.com> | 2010-03-02 07:54:13 +0800 |
---|---|---|
committer | Travis Reitter <treitter@gmail.com> | 2010-03-02 07:54:58 +0800 |
commit | 0309966cb4998548e404c1d76bd6c94a5e0f4259 (patch) | |
tree | 8379772b10cb6721d5aee5d02df64c0b480d2ce4 /src/empathy-accounts-dialog.c | |
parent | 74be0ae5e7a1c1fe845a056cd38977c649e0989a (diff) | |
download | gsoc2013-empathy-0309966cb4998548e404c1d76bd6c94a5e0f4259.tar gsoc2013-empathy-0309966cb4998548e404c1d76bd6c94a5e0f4259.tar.gz gsoc2013-empathy-0309966cb4998548e404c1d76bd6c94a5e0f4259.tar.bz2 gsoc2013-empathy-0309966cb4998548e404c1d76bd6c94a5e0f4259.tar.lz gsoc2013-empathy-0309966cb4998548e404c1d76bd6c94a5e0f4259.tar.xz gsoc2013-empathy-0309966cb4998548e404c1d76bd6c94a5e0f4259.tar.zst gsoc2013-empathy-0309966cb4998548e404c1d76bd6c94a5e0f4259.zip |
Disable the Cancel button in the accounts dialog if there are no existing accounts to display (ie, we're creating our first account).
Diffstat (limited to 'src/empathy-accounts-dialog.c')
-rw-r--r-- | src/empathy-accounts-dialog.c | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 8ae8450e8..a3a3b7e88 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -431,6 +431,28 @@ empathy_account_dialog_account_created_cb (EmpathyAccountWidget *widget_object, g_object_unref (settings); } +static gboolean +accounts_dialog_has_valid_accounts (EmpathyAccountsDialog *dialog) +{ + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GtkTreeModel *model; + GtkTreeIter iter; + gboolean creating; + + g_object_get (priv->setting_widget_object, + "creating-account", &creating, NULL); + + if (!creating) + return TRUE; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + + if (gtk_tree_model_get_iter_first (model, &iter)) + return gtk_tree_model_iter_next (model, &iter); + + return FALSE; +} + static void account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, EmpathyAccountSettings *settings) @@ -442,6 +464,10 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog, priv->setting_widget_object = empathy_account_widget_new_for_protocol (settings, FALSE); + if (accounts_dialog_has_valid_accounts (dialog)) + empathy_account_widget_set_other_accounts_exist ( + priv->setting_widget_object, TRUE); + priv->settings_widget = empathy_account_widget_get_widget (priv->setting_widget_object); @@ -1676,6 +1702,37 @@ accounts_dialog_account_validity_changed_cb (TpAccountManager *manager, } static void +accounts_dialog_accounts_model_row_inserted_cb (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + EmpathyAccountsDialog *dialog) +{ + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + if (priv->setting_widget_object != NULL && + accounts_dialog_has_valid_accounts (dialog)) + { + empathy_account_widget_set_other_accounts_exist ( + priv->setting_widget_object, TRUE); + } +} + +static void +accounts_dialog_accounts_model_row_deleted_cb (GtkTreeModel *model, + GtkTreePath *path, + EmpathyAccountsDialog *dialog) +{ + EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + + if (priv->setting_widget_object != NULL && + !accounts_dialog_has_valid_accounts (dialog)) + { + empathy_account_widget_set_other_accounts_exist ( + priv->setting_widget_object, FALSE); + } +} + +static void accounts_dialog_account_removed_cb (TpAccountManager *manager, TpAccount *account, EmpathyAccountsDialog *dialog) @@ -1686,7 +1743,7 @@ accounts_dialog_account_removed_cb (TpAccountManager *manager, if (accounts_dialog_get_account_iter (dialog, account, &iter)) { gtk_list_store_remove (GTK_LIST_STORE ( - gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter); + gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter); } } @@ -2038,6 +2095,7 @@ do_dispose (GObject *obj) { EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj); EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); + GtkTreeModel *model; if (priv->dispose_has_run) return; @@ -2045,6 +2103,12 @@ do_dispose (GObject *obj) priv->dispose_has_run = TRUE; /* Disconnect signals */ + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + g_signal_handlers_disconnect_by_func (model, + accounts_dialog_accounts_model_row_inserted_cb, dialog); + g_signal_handlers_disconnect_by_func (model, + accounts_dialog_accounts_model_row_deleted_cb, dialog); + g_signal_handlers_disconnect_by_func (priv->account_manager, accounts_dialog_account_validity_changed_cb, dialog); @@ -2149,10 +2213,17 @@ do_constructed (GObject *object) EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object); EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog); gboolean import_asked; + GtkTreeModel *model; accounts_dialog_build_ui (dialog); accounts_dialog_model_setup (dialog); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); + g_signal_connect (model, "row-inserted", + (GCallback) accounts_dialog_accounts_model_row_inserted_cb, dialog); + g_signal_connect (model, "row-deleted", + (GCallback) accounts_dialog_accounts_model_row_deleted_cb, dialog); + /* Set up signalling */ priv->account_manager = tp_account_manager_dup (); |