[gnome-initial-setup] goa: sync add account dialog from control-center



commit 8d33e84814304b21c1741388b39f6d512e11aa22
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jun 12 00:32:37 2013 -0400

    goa: sync add account dialog from control-center
    
    We were missing the separators, among other things.

 .../goa/cc-online-accounts-add-account-dialog.c    |  333 +++++++++++++-------
 .../goa/cc-online-accounts-add-account-dialog.h    |    4 +
 gnome-initial-setup/pages/goa/gis-goa-page.c       |   38 +--
 3 files changed, 237 insertions(+), 138 deletions(-)
---
diff --git a/gnome-initial-setup/pages/goa/cc-online-accounts-add-account-dialog.c 
b/gnome-initial-setup/pages/goa/cc-online-accounts-add-account-dialog.c
index 7082575..f9a27d4 100644
--- a/gnome-initial-setup/pages/goa/cc-online-accounts-add-account-dialog.c
+++ b/gnome-initial-setup/pages/goa/cc-online-accounts-add-account-dialog.c
@@ -1,6 +1,6 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  *
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012, 2013 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,17 +28,29 @@
 #define GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE
 #include <goabackend/goabackend.h>
 
+#include <egg-list-box/egg-list-box.h>
+
 #include "cc-online-accounts-add-account-dialog.h"
 
+#define BRANDED_PAGE "_branded"
+#define OTHER_PAGE "_other"
+
 struct _GoaPanelAddAccountDialogPrivate
 {
+  EggListBox *branded_list_box;
+  EggListBox *contacts_list_box;
+  EggListBox *mail_list_box;
+  EggListBox *ticketing_list_box;
   GError *error;
   GoaClient *client;
   GoaObject *object;
+  GoaProvider *provider;
   GtkListStore *list_store;
-  GtkTreePath *path;
-  GtkWidget *tree_view;
-  gboolean ignore_release;
+  GtkWidget *contacts_grid;
+  GtkWidget *mail_grid;
+  GtkWidget *ticketing_grid;
+  GtkWidget *stack;
+  gboolean add_other;
 };
 
 #define GOA_ADD_ACCOUNT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), 
GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG, GoaPanelAddAccountDialogPrivate))
@@ -59,36 +71,16 @@ enum
 
 G_DEFINE_TYPE (GoaPanelAddAccountDialog, goa_panel_add_account_dialog, GTK_TYPE_DIALOG)
 
-static GoaProvider *
-add_account_dialog_get_provider (GoaPanelAddAccountDialog *add_account)
-{
-  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
-  GoaProvider *provider;
-  GtkTreeIter iter;
-
-  if (priv->path == NULL)
-    return NULL;
-
-  if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->list_store), &iter, priv->path))
-    return NULL;
-
-  gtk_tree_model_get (GTK_TREE_MODEL (priv->list_store), &iter, COLUMN_PROVIDER, &provider, -1);
-  return provider;
-}
-
 static void
-add_account_dialog_add_account (GoaPanelAddAccountDialog *add_account)
+add_account_dialog_add_account (GoaPanelAddAccountDialog *add_account,
+                                GoaProvider *provider)
 {
   GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
   GList *children;
   GList *l;
-  GoaProvider *provider;
   GtkWidget *action_area;
   GtkWidget *vbox;
 
-  provider = add_account_dialog_get_provider (add_account);
-  g_assert (provider != NULL);
-
   action_area = gtk_dialog_get_action_area (GTK_DIALOG (add_account));
   vbox = gtk_dialog_get_content_area (GTK_DIALOG (add_account));
   children = gtk_container_get_children (GTK_CONTAINER (vbox));
@@ -100,70 +92,128 @@ add_account_dialog_add_account (GoaPanelAddAccountDialog *add_account)
     }
   g_list_free (children);
 
+  /* This spins gtk_dialog_run() */
   priv->object = goa_provider_add_account (provider,
                                            priv->client,
                                            GTK_DIALOG (add_account),
                                            GTK_BOX (vbox),
                                            &priv->error);
-  g_object_unref (provider);
 }
 
-static gboolean
-tree_view_button_press_event_cb (GtkWidget      *widget,
-                                 GdkEventButton *event,
-                                 gpointer       *user_data)
+static void
+list_box_child_activated_cb (GoaPanelAddAccountDialog *add_account, GtkWidget *child)
 {
-  GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (user_data);
-  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+  GoaProvider *provider;
 
-  /* be sure to ignore double and triple clicks */
-  priv->ignore_release = (event->type != GDK_BUTTON_PRESS);
+  provider = g_object_get_data (G_OBJECT (child), "provider");
+  if (provider == NULL)
+    {
+      gtk_stack_set_visible_child_name (GTK_STACK (add_account->priv->stack), OTHER_PAGE);
+      return;
+    }
 
-  return FALSE;
+  add_account_dialog_add_account (add_account, provider);
 }
 
-static gboolean
-tree_view_button_release_event_cb (GtkWidget      *widget,
-                                   GdkEventButton *event,
-                                   gpointer       *user_data)
+static void
+list_box_separator_cb (GtkWidget **separator, GtkWidget *child, GtkWidget *before, gpointer user_data)
 {
-  GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (user_data);
-  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
-  GtkTreePath *path;
-  GtkTreeViewColumn *column;
+  if (*separator == NULL && before != NULL)
+    {
+      *separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+
+      /* https://bugzilla.gnome.org/show_bug.cgi?id=690545 */
+      g_object_ref_sink (*separator);
+      gtk_widget_show (*separator);
+    }
+}
 
-  if (event->button != 1 || priv->ignore_release)
-    return TRUE;
+static void
+add_account_dialog_create_group_ui (GoaPanelAddAccountDialog *add_account,
+                                    EggListBox **list_box,
+                                    GtkWidget **group_grid,
+                                    GtkWidget *page_grid,
+                                    const gchar *name)
+{
+  GtkWidget *label;
+  GtkWidget *sw;
+  gchar *markup;
 
-  gtk_tree_view_get_cursor (GTK_TREE_VIEW (widget), &path, &column);
-  if (path == NULL)
-    return TRUE;
+  *group_grid = gtk_grid_new ();
+  gtk_widget_set_no_show_all (*group_grid, TRUE);
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (*group_grid), GTK_ORIENTATION_VERTICAL);
+  gtk_grid_set_row_spacing (GTK_GRID (*group_grid), 6);
+  gtk_container_add (GTK_CONTAINER (page_grid), *group_grid);
 
-  gtk_tree_view_row_activated (GTK_TREE_VIEW (widget), path, column);
-  gtk_tree_path_free (path);
+  markup = g_strdup_printf ("<b>%s</b>", name);
+  label = gtk_label_new (NULL);
+  gtk_widget_set_halign (label, GTK_ALIGN_START);
+  gtk_widget_set_hexpand (label, TRUE);
+  gtk_label_set_markup (GTK_LABEL (label), markup);
+  gtk_container_add (GTK_CONTAINER (*group_grid), label);
+  g_free (markup);
 
-  return TRUE;
+  sw = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_set_hexpand (sw, TRUE);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
+  gtk_container_add (GTK_CONTAINER (*group_grid), sw);
+
+  *list_box = egg_list_box_new ();
+  egg_list_box_add_to_scrolled (*list_box, GTK_SCROLLED_WINDOW (sw));
+  egg_list_box_set_selection_mode (*list_box, GTK_SELECTION_NONE);
+  egg_list_box_set_separator_funcs (*list_box, list_box_separator_cb, NULL, NULL);
+  g_signal_connect_swapped (*list_box, "child-activated",
+                            G_CALLBACK (list_box_child_activated_cb), add_account);
 }
 
 static void
-tree_view_row_activated_cb (GtkTreeView       *tree_view,
-                            GtkTreePath       *path,
-                            GtkTreeViewColumn *column,
-                            gpointer           user_data)
+add_account_dialog_create_provider_ui (GoaPanelAddAccountDialog *add_account,
+                                       GoaProvider *provider,
+                                       EggListBox *list_box)
 {
-  GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (user_data);
-  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+  GIcon *icon;
+  GtkWidget *row_grid;
+  GtkWidget *image;
+  GtkWidget *label;
+  gchar *markup;
+  gchar *name;
 
-  priv->path = gtk_tree_path_copy (path);
-  add_account_dialog_add_account (add_account);
-  gtk_dialog_response (GTK_DIALOG (add_account), GTK_RESPONSE_OK);
+  row_grid = gtk_grid_new ();
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (row_grid), GTK_ORIENTATION_HORIZONTAL);
+  gtk_grid_set_column_spacing (GTK_GRID (row_grid), 6);
+  gtk_container_add (GTK_CONTAINER (list_box), row_grid);
+
+  if (provider == NULL)
+    {
+      g_object_set_data (G_OBJECT (row_grid), "provider", NULL);
+      icon = g_themed_icon_new_with_default_fallbacks ("goa-account");
+      name = g_strdup (C_("Online Account", "Other"));
+    }
+  else
+    {
+      g_object_set_data_full (G_OBJECT (row_grid), "provider", g_object_ref (provider), g_object_unref);
+      icon = goa_provider_get_provider_icon (provider, NULL);
+      name = goa_provider_get_provider_name (provider, NULL);
+    }
+
+  image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
+  gtk_container_add (GTK_CONTAINER (row_grid), image);
+
+  markup = g_strdup_printf ("<b>%s</b>", name);
+  label = gtk_label_new (NULL);
+  gtk_label_set_markup (GTK_LABEL (label), markup);
+  gtk_container_add (GTK_CONTAINER (row_grid), label);
+  g_free (markup);
+
+  g_free (name);
+  g_object_unref (icon);
 }
 
 static void
 goa_panel_add_account_dialog_realize (GtkWidget *widget)
 {
   GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (widget);
-  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
   GtkWidget *button;
   GtkWindow *parent;
 
@@ -177,8 +227,6 @@ goa_panel_add_account_dialog_realize (GtkWidget *widget)
       gtk_widget_set_size_request (GTK_WIDGET (add_account), (gint) (0.5 * width), (gint) (0.9 * height));
     }
 
-  gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), GTK_TREE_MODEL (priv->list_store));
-
   GTK_WIDGET_CLASS (goa_panel_add_account_dialog_parent_class)->realize (widget);
 
   button = gtk_dialog_get_widget_for_response (GTK_DIALOG (add_account), GTK_RESPONSE_CANCEL);
@@ -191,12 +239,9 @@ goa_panel_add_account_dialog_dispose (GObject *object)
   GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (object);
   GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
 
-  if (priv->tree_view != NULL)
-    priv->tree_view = NULL;
-
-  g_clear_object (&priv->list_store);
   g_clear_object (&priv->object);
   g_clear_object (&priv->client);
+  g_clear_object (&priv->provider);
 
   G_OBJECT_CLASS (goa_panel_add_account_dialog_parent_class)->dispose (object);
 }
@@ -207,10 +252,7 @@ goa_panel_add_account_dialog_finalize (GObject *object)
   GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (object);
   GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
 
-  gtk_tree_path_free (priv->path);
-
-  if (priv->error != NULL)
-    g_error_free (priv->error);
+  g_clear_error (&priv->error);
 
   G_OBJECT_CLASS (goa_panel_add_account_dialog_parent_class)->finalize (object);
 }
@@ -236,9 +278,6 @@ static void
 goa_panel_add_account_dialog_init (GoaPanelAddAccountDialog *add_account)
 {
   GoaPanelAddAccountDialogPrivate *priv;
-  GtkCellRenderer *renderer;
-  GtkTreeSelection *selection;
-  GtkTreeViewColumn *column;
   GtkWidget *sw;
   GtkWidget *vbox;
   GtkWidget *grid;
@@ -262,41 +301,51 @@ goa_panel_add_account_dialog_init (GoaPanelAddAccountDialog *add_account)
 
   priv->list_store = gtk_list_store_new (N_COLUMNS, GOA_TYPE_PROVIDER, G_TYPE_ICON, G_TYPE_STRING);
 
+  priv->stack = gtk_stack_new ();
+  gtk_stack_set_transition_type (GTK_STACK (priv->stack), GTK_STACK_TRANSITION_TYPE_CROSSFADE);
+  gtk_container_add (GTK_CONTAINER (grid), priv->stack);
+
   sw = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
   gtk_widget_set_hexpand (sw, TRUE);
   gtk_widget_set_vexpand (sw, TRUE);
-  gtk_container_add (GTK_CONTAINER (grid), sw);
+  gtk_stack_add_named (GTK_STACK (priv->stack), sw, BRANDED_PAGE);
 
-  priv->tree_view = gtk_tree_view_new ();
-  gtk_widget_set_hexpand (priv->tree_view, TRUE);
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
-  gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
-  gtk_container_add (GTK_CONTAINER (sw), priv->tree_view);
+  priv->branded_list_box = egg_list_box_new ();
+  egg_list_box_add_to_scrolled (priv->branded_list_box, GTK_SCROLLED_WINDOW (sw));
+  egg_list_box_set_selection_mode (priv->branded_list_box, GTK_SELECTION_NONE);
+  egg_list_box_set_separator_funcs (priv->branded_list_box, list_box_separator_cb, NULL, NULL);
+  g_signal_connect_swapped (priv->branded_list_box, "child-activated",
+                            G_CALLBACK (list_box_child_activated_cb), add_account);
 
-  column = gtk_tree_view_column_new ();
-  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), column);
+  grid = gtk_grid_new ();
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
+  gtk_stack_add_named (GTK_STACK (priv->stack), grid, OTHER_PAGE);
 
-  renderer = gtk_cell_renderer_pixbuf_new ();
-  gtk_tree_view_column_pack_start (column, renderer, FALSE);
-  g_object_set (G_OBJECT (renderer), "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
-  gtk_tree_view_column_set_attributes (column, renderer, "gicon", COLUMN_ICON, NULL);
+  add_account_dialog_create_group_ui (add_account,
+                                      &priv->mail_list_box,
+                                      &priv->mail_grid,
+                                      grid,
+                                      _("Mail"));
 
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_column_pack_start (column, renderer, TRUE);
-  gtk_tree_view_column_set_attributes (column, renderer, "markup", COLUMN_MARKUP, NULL);
+  add_account_dialog_create_group_ui (add_account,
+                                      &priv->contacts_list_box,
+                                      &priv->contacts_grid,
+                                      grid,
+                                      _("Contacts"));
 
-  gtk_dialog_add_button (GTK_DIALOG (add_account), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-  gtk_dialog_set_default_response (GTK_DIALOG (add_account), GTK_RESPONSE_CANCEL);
+  add_account_dialog_create_group_ui (add_account,
+                                      &priv->ticketing_list_box,
+                                      &priv->ticketing_grid,
+                                      grid,
+                                      _("Resources"));
 
-  g_signal_connect (priv->tree_view, "button-press-event",
-                    G_CALLBACK (tree_view_button_press_event_cb), add_account);
-  g_signal_connect (priv->tree_view, "button-release-event",
-                    G_CALLBACK (tree_view_button_release_event_cb), add_account);
-  g_signal_connect (priv->tree_view, "row-activated", G_CALLBACK (tree_view_row_activated_cb), add_account);
+  gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), BRANDED_PAGE);
 
+  gtk_dialog_add_button (GTK_DIALOG (add_account), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+  gtk_dialog_set_default_response (GTK_DIALOG (add_account), GTK_RESPONSE_CANCEL);
 }
 
 static void
@@ -331,27 +380,83 @@ goa_panel_add_account_dialog_new (GoaClient *client)
 }
 
 void
+goa_panel_add_account_dialog_set_preseed_data (GoaPanelAddAccountDialog *add_account,
+                                               GoaProvider *provider,
+                                               GVariant *preseed)
+{
+  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+
+  g_clear_object (&priv->provider);
+
+  if (provider != NULL)
+    {
+      priv->provider = g_object_ref (provider);
+      goa_provider_set_preseed_data (provider, preseed);
+    }
+}
+
+void
 goa_panel_add_account_dialog_add_provider (GoaPanelAddAccountDialog *add_account, GoaProvider *provider)
 {
   GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
-  GIcon *icon;
-  GtkTreeIter iter;
-  gchar *markup;
-  gchar *name;
+  EggListBox *list_box;
+  GoaProviderGroup group;
+  GtkWidget *group_grid = NULL;
 
-  icon = goa_provider_get_provider_icon (provider, NULL);
-  name = goa_provider_get_provider_name (provider, NULL);
-  markup = g_strdup_printf ("<b>%s</b>", name);
-  g_free (name);
+  g_return_if_fail (provider != NULL);
 
-  gtk_list_store_append (priv->list_store, &iter);
-  gtk_list_store_set (priv->list_store, &iter,
-                      COLUMN_PROVIDER, provider,
-                      COLUMN_ICON, icon,
-                      COLUMN_MARKUP, markup,
-                      -1);
-  g_free (markup);
-  g_object_unref (icon);
+  group = goa_provider_get_provider_group (provider);
+
+  /* The list of providers returned by GOA are sorted such that all
+   * the branded providers are at the beginning of the list, followed
+   * by the others. Since this is the order in which they are added,
+   * we can rely on this fact, which helps to simplify the code.
+   */
+  if (group != GOA_PROVIDER_GROUP_BRANDED && !priv->add_other)
+    {
+      add_account_dialog_create_provider_ui (add_account, NULL, priv->branded_list_box);
+      priv->add_other = TRUE;
+    }
+
+  switch (group)
+    {
+    case GOA_PROVIDER_GROUP_BRANDED:
+      list_box = priv->branded_list_box;
+      break;
+    case GOA_PROVIDER_GROUP_CONTACTS:
+      group_grid = priv->contacts_grid;
+      list_box = priv->contacts_list_box;
+      break;
+    case GOA_PROVIDER_GROUP_MAIL:
+      group_grid = priv->mail_grid;
+      list_box = priv->mail_list_box;
+      break;
+    case GOA_PROVIDER_GROUP_TICKETING:
+      group_grid = priv->ticketing_grid;
+      list_box = priv->ticketing_list_box;
+      break;
+    default:
+      g_assert_not_reached ();
+      break;
+    }
+
+  add_account_dialog_create_provider_ui (add_account, provider, list_box);
+
+  if (group_grid != NULL)
+    {
+      gtk_widget_set_no_show_all (group_grid, FALSE);
+      gtk_widget_show_all (group_grid);
+    }
+}
+
+void
+goa_panel_add_account_dialog_run (GoaPanelAddAccountDialog *add_account)
+{
+  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+  if (priv->provider != NULL)
+    add_account_dialog_add_account (add_account, priv->provider);
+  else
+    gtk_dialog_run (GTK_DIALOG (add_account));
 }
 
 GoaObject *
diff --git a/gnome-initial-setup/pages/goa/cc-online-accounts-add-account-dialog.h 
b/gnome-initial-setup/pages/goa/cc-online-accounts-add-account-dialog.h
index 0f503cb..9338575 100644
--- a/gnome-initial-setup/pages/goa/cc-online-accounts-add-account-dialog.h
+++ b/gnome-initial-setup/pages/goa/cc-online-accounts-add-account-dialog.h
@@ -54,6 +54,10 @@ GType                  goa_panel_add_account_dialog_get_type               (void
 GtkWidget             *goa_panel_add_account_dialog_new                    (GoaClient *client);
 void                   goa_panel_add_account_dialog_add_provider           (GoaPanelAddAccountDialog 
*add_account,
                                                                             GoaProvider              
*provider);
+void                   goa_panel_add_account_dialog_set_preseed_data       (GoaPanelAddAccountDialog 
*add_account,
+                                                                            GoaProvider              
*provider,
+                                                                            GVariant                 
*preseed);
+void                   goa_panel_add_account_dialog_run                    (GoaPanelAddAccountDialog 
*add_account);
 GoaObject             *goa_panel_add_account_dialog_get_account            (GoaPanelAddAccountDialog 
*add_account,
                                                                             GError                   
**error);
 
diff --git a/gnome-initial-setup/pages/goa/gis-goa-page.c b/gnome-initial-setup/pages/goa/gis-goa-page.c
index 5bf9e8e..9731d04 100644
--- a/gnome-initial-setup/pages/goa/gis-goa-page.c
+++ b/gnome-initial-setup/pages/goa/gis-goa-page.c
@@ -84,39 +84,29 @@ show_online_account_dialog (GtkButton *button,
     }
 
   gtk_widget_show_all (dialog);
-  response = gtk_dialog_run (GTK_DIALOG (dialog));
-  if (response != GTK_RESPONSE_OK)
-    {
-      gtk_widget_destroy (dialog);
-      goto out;
-    }
+  goa_panel_add_account_dialog_run (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog));
 
   error = NULL;
   object = goa_panel_add_account_dialog_get_account (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), &error);
+  gtk_widget_destroy (dialog);
 
-  if (object == NULL)
+  if (error && !g_error_matches (error, GOA_ERROR, GOA_ERROR_DIALOG_DISMISSED))
     {
+      dialog = gtk_message_dialog_new (parent,
+                                       GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                       GTK_MESSAGE_ERROR,
+                                       GTK_BUTTONS_CLOSE,
+                                       _("Error creating account"));
+      gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                                "%s",
+                                                error->message);
+      gtk_widget_show_all (dialog);
+      gtk_dialog_run (GTK_DIALOG (dialog));
       gtk_widget_destroy (dialog);
-      if (!(error->domain == GOA_ERROR && error->code == GOA_ERROR_DIALOG_DISMISSED))
-        {
-          dialog = gtk_message_dialog_new (parent,
-                                           GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                           GTK_MESSAGE_ERROR,
-                                           GTK_BUTTONS_CLOSE,
-                                           _("Error creating account"));
-          gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                    "%s",
-                                                    error->message);
-          gtk_widget_show_all (dialog);
-          gtk_dialog_run (GTK_DIALOG (dialog));
-          gtk_widget_destroy (dialog);
-        }
       g_error_free (error);
     }
 
- out:
-  g_list_foreach (providers, (GFunc) g_object_unref, NULL);
-  g_list_free (providers);
+  g_list_free_full (providers, g_object_unref);
 }
 
 static void


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