[gnome-initial-setup] goa: Sync code to be closer to g-c-c panel



commit ebc23e6b2cf792fd1cc523dce67161e5a355f529
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Sep 24 16:26:57 2013 -0400

    goa: Sync code to be closer to g-c-c panel
    
    This also eliminates some compiler warnings

 gnome-initial-setup/pages/goa/gis-goa-page.c |   81 +++++++++++---------------
 1 files changed, 35 insertions(+), 46 deletions(-)
---
diff --git a/gnome-initial-setup/pages/goa/gis-goa-page.c b/gnome-initial-setup/pages/goa/gis-goa-page.c
index 4a6f826..c6d1f36 100644
--- a/gnome-initial-setup/pages/goa/gis-goa-page.c
+++ b/gnome-initial-setup/pages/goa/gis-goa-page.c
@@ -43,7 +43,6 @@
 
 struct _GisGoaPagePrivate {
   GoaClient *goa_client;
-  GtkWidget *dialog;
   gboolean accounts_exist;
 };
 typedef struct _GisGoaPagePrivate GisGoaPagePrivate;
@@ -58,66 +57,40 @@ on_have_providers (GObject       *source,
                    GAsyncResult  *res,
                    gpointer       user_data)
 {
+  GisGoaPage *page = GIS_GOA_PAGE (user_data);
+  GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
   GList *providers;
   GList *l;
+  GtkWindow *parent;
+  GtkWidget *dialog;
   GError *error = NULL;
-  GisGoaPage *page = GIS_GOA_PAGE (user_data);
-  GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
 
   if (!goa_provider_get_all_finish (&providers, res, &error))
     goto out;
-  
+
+  parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page)));
+
+  dialog = goa_panel_add_account_dialog_new (priv->goa_client);
+  gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+
   for (l = providers; l != NULL; l = l->next)
     {
       GoaProvider *provider;
 
       provider = GOA_PROVIDER (l->data);
-      goa_panel_add_account_dialog_add_provider (GOA_PANEL_ADD_ACCOUNT_DIALOG (priv->dialog), provider);
-    }
-
-  g_list_foreach (providers, (GFunc) g_object_unref, NULL);
-  g_list_free (providers);
-
- out:
-  if (error)
-    {
-      g_printerr ("Failed to list providers: %s\n", error->message);
-      g_error_free (error);
+      goa_panel_add_account_dialog_add_provider (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), provider);
     }
-}
 
-static void
-show_online_account_dialog (GtkButton *button,
-                            gpointer   user_data)
-{
-  GisGoaPage *page = GIS_GOA_PAGE (user_data);
-  GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
-  GtkWindow *parent;
-  GtkWidget *dialog;
-  gint response;
-  GoaObject *object;
-  GError *error;
-
-  parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page)));
-
-  priv->dialog = goa_panel_add_account_dialog_new (priv->goa_client);
-  gtk_window_set_transient_for (GTK_WINDOW (priv->dialog), parent);
-
-  goa_provider_get_all (on_have_providers, page);
-
-  gtk_widget_show_all (priv->dialog);
-  response = gtk_dialog_run (GTK_DIALOG (priv->dialog));
-  if (response != GTK_RESPONSE_OK)
-    {
-      gtk_widget_destroy (dialog);
-      goto out;
-    }
+  goa_panel_add_account_dialog_run (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog));
+  goa_panel_add_account_dialog_get_account (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), &error);
+  gtk_widget_destroy (dialog);
 
-  object = goa_panel_add_account_dialog_get_account (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), &error);
+  /* We might have an object even when error is set.
+   * eg., if we failed to store the credentials in the keyring.
+   */
 
-  if (object == NULL)
+  if (error != NULL)
     {
-      gtk_widget_destroy (dialog);
       if (!(error->domain == GOA_ERROR && error->code == GOA_ERROR_DIALOG_DISMISSED))
         {
           dialog = gtk_message_dialog_new (parent,
@@ -134,8 +107,24 @@ show_online_account_dialog (GtkButton *button,
         }
       g_error_free (error);
     }
+
+  g_list_free_full (providers, g_object_unref);
+
  out:
-  return;
+  if (error)
+    {
+      g_printerr ("Failed to list providers: %s\n", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+show_online_account_dialog (GtkButton *button,
+                            gpointer   user_data)
+{
+  GisGoaPage *page = GIS_GOA_PAGE (user_data);
+
+  goa_provider_get_all (on_have_providers, page);
 }
 
 static void


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