[empathy: 2/5] Cancel creation in the accounts dialog if the wizard is running



commit c15ddf6b53db97e61acd45da5fd8cc9f804d7625
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Thu Mar 4 12:19:32 2010 +0000

    Cancel creation in the accounts dialog if the wizard is running
    
    If the account wizard is finished it should have created at least some
    accounts. Cancel any account creation that was going on in the accounts dialog
    so it nicely jumps showing the first real account :)

 src/cc-empathy-accounts-page.c |   24 +++++++++++++++++++++++-
 src/empathy-accounts-dialog.c  |   30 ++++++++++++++++++++++++++----
 src/empathy-accounts-dialog.h  |    4 ++++
 3 files changed, 53 insertions(+), 5 deletions(-)
---
diff --git a/src/cc-empathy-accounts-page.c b/src/cc-empathy-accounts-page.c
index ef9b175..383e20d 100644
--- a/src/cc-empathy-accounts-page.c
+++ b/src/cc-empathy-accounts-page.c
@@ -28,6 +28,7 @@
 #include <glib/gi18n-lib.h>
 
 #include <telepathy-glib/account-manager.h>
+#include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-connection-managers.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 
@@ -75,6 +76,20 @@ page_pack_with_accounts_dialog (CcEmpathyAccountsPage *page)
 }
 
 static void
+account_assistant_closed_cb (GtkWidget *widget,
+    gpointer user_data)
+{
+  CcEmpathyAccountsPage *page = CC_EMPATHY_ACCOUNTS_PAGE (user_data);
+
+  if (empathy_accounts_dialog_is_creating (
+      EMPATHY_ACCOUNTS_DIALOG (page->priv->accounts_window)))
+    {
+      empathy_account_dialog_cancel (
+        EMPATHY_ACCOUNTS_DIALOG (page->priv->accounts_window));
+    }
+}
+
+static void
 connection_managers_prepare (GObject *source,
     GAsyncResult *result,
     gpointer user_data)
@@ -96,7 +111,14 @@ connection_managers_prepare (GObject *source,
   empathy_accounts_import (account_mgr, cm_mgr);
 
   if (!empathy_accounts_has_non_salut_accounts (account_mgr))
-    empathy_account_assistant_show (NULL, cm_mgr);
+    {
+      GtkWidget *w;
+      w = empathy_account_assistant_show (NULL, cm_mgr);
+
+      empathy_signal_connect_weak (w, "hide",
+        G_CALLBACK (account_assistant_closed_cb),
+        G_OBJECT (page));
+    }
 
 out:
   /* remove ref from active_changed() */
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index d8489ee..75357be 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -346,10 +346,8 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
   g_free (message_markup);
 }
 
-static void
-empathy_account_dialog_widget_cancelled_cb (
-    EmpathyAccountWidget *widget_object,
-    EmpathyAccountsDialog *dialog)
+void
+empathy_account_dialog_cancel (EmpathyAccountsDialog *dialog)
 {
   GtkTreeView *view;
   GtkTreeModel *model;
@@ -394,6 +392,14 @@ empathy_account_dialog_widget_cancelled_cb (
 }
 
 static void
+empathy_account_dialog_widget_cancelled_cb (
+    EmpathyAccountWidget *widget_object,
+    EmpathyAccountsDialog *dialog)
+{
+  empathy_account_dialog_cancel (dialog);
+}
+
+static void
 empathy_account_dialog_account_created_cb (EmpathyAccountWidget *widget_object,
     TpAccount *account,
     EmpathyAccountsDialog *dialog)
@@ -2344,3 +2350,19 @@ empathy_accounts_dialog_show_application (GdkScreen *screen,
   g_free (account_option);
   g_free (path);
 }
+
+gboolean
+empathy_account_dialog_is_creating (EmpathyAccountsDialog *dialog)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+  gboolean result = FALSE;
+
+  if (priv->setting_widget_object == NULL)
+    goto out;
+
+  g_object_get (priv->setting_widget_object,
+      "creating-account", &result, NULL);
+
+out:
+  return result;
+}
diff --git a/src/empathy-accounts-dialog.h b/src/empathy-accounts-dialog.h
index c171e3d..8f33add 100644
--- a/src/empathy-accounts-dialog.h
+++ b/src/empathy-accounts-dialog.h
@@ -56,6 +56,10 @@ typedef struct {
 GType empathy_accounts_dialog_get_type (void);
 GtkWidget *empathy_accounts_dialog_show (GtkWindow *parent,
     TpAccount *selected_account);
+
+void empathy_account_dialog_cancel (EmpathyAccountsDialog *dialog);
+gboolean empathy_account_dialog_is_creating (EmpathyAccountsDialog *dialog);
+
 void empathy_accounts_dialog_show_application (GdkScreen *screen,
     GChildWatchFunc application_exit_cb,
     gpointer user_data,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]