]> git.0d.be Git - empathy.git/commitdiff
Refactor the startup sequence a bit
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Sun, 23 Aug 2009 17:55:54 +0000 (18:55 +0100)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Sun, 23 Aug 2009 22:18:48 +0000 (23:18 +0100)
On initial start the following should happen:
  * If we haven't tried to import mc4 accounts, do so
  * If there were no mc4 accounts imported and there are no accounts defined
    show the account creation assistant.
  * If we haven't created a salut account, do so

src/empathy.c

index a80d3968468b8d8a5199623dac3718c4a2de32f1..38fd56c54acb4c741666699b480b5b263d2a836c 100644 (file)
@@ -323,39 +323,41 @@ create_salut_account_if_needed (EmpathyConnectionManagers *managers)
 }
 
 static void
-connection_managers_ready_cb (EmpathyConnectionManagers *managers,
-    GParamSpec *spec,
-    gpointer user_data)
+maybe_show_account_assistant (void)
 {
-  if (empathy_connection_managers_is_ready (managers))
+  EmpathyAccountManager *manager;
+  manager = empathy_account_manager_dup_singleton ();
+
+  if (empathy_account_manager_get_count (manager) == 0)
     {
-      empathy_import_mc4_accounts ();
-      create_salut_account_if_needed (managers);
-      g_object_unref (managers);
-      managers = NULL;
+      GtkWidget * assistant = empathy_account_assistant_new (
+        GTK_WINDOW (empathy_main_window_get ()));
+      gtk_window_present (GTK_WINDOW (assistant));
     }
 }
 
-static void
-create_salut_account (void)
+static gboolean
+check_connection_managers_ready (EmpathyConnectionManagers *managers)
 {
-  EmpathyConnectionManagers *managers;
-
-  if (!should_create_salut_account ())
-    return;
-
-  managers = empathy_connection_managers_dup_singleton ();
-
   if (empathy_connection_managers_is_ready (managers))
     {
+      if (!empathy_import_mc4_accounts (managers))
+        maybe_show_account_assistant ();
+
       create_salut_account_if_needed (managers);
       g_object_unref (managers);
+      managers = NULL;
+      return TRUE;
     }
-  else
-    {
-      g_signal_connect (managers, "notify::ready",
-                        G_CALLBACK (connection_managers_ready_cb), NULL);
-    }
+  return FALSE;
+}
+
+static void
+connection_managers_ready_cb (EmpathyConnectionManagers *managers,
+    GParamSpec *spec,
+    gpointer user_data)
+{
+  check_connection_managers_ready (managers);
 }
 
 static void
@@ -536,19 +538,24 @@ account_manager_ready_cb (EmpathyAccountManager *manager,
     GParamSpec *spec,
     gpointer user_data)
 {
-  GtkWidget *assistant;
-
   if (!empathy_account_manager_is_ready (manager))
     return;
 
-  if (empathy_account_manager_get_count (manager) == 0)
+  if (should_create_salut_account () || !empathy_import_mc4_has_imported ())
     {
-      assistant = empathy_account_assistant_new (
-          GTK_WINDOW (empathy_main_window_get ()));
-      gtk_window_present (GTK_WINDOW (assistant));
-    }
+      EmpathyConnectionManagers *managers;
+      managers = empathy_connection_managers_dup_singleton ();
 
-  create_salut_account ();
+      if (!check_connection_managers_ready (managers))
+        {
+          g_signal_connect (managers, "notify::ready",
+            G_CALLBACK (connection_managers_ready_cb), NULL);
+        }
+    }
+  else
+    {
+      maybe_show_account_assistant ();
+    }
 }
 
 int