[gnome-initial-setup] goa-page: Import new add-account-dialog from g-c-c



commit 1a49fdeedd07eb48e10f54b5631a69aa35e8bff4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jun 12 11:38:29 2012 -0400

    goa-page: Import new add-account-dialog from g-c-c

 gnome-initial-setup/Makefile.am                    |    1 +
 .../cc-online-accounts-add-account-dialog.c        |  367 ++++++++++++++++++++
 .../cc-online-accounts-add-account-dialog.h        |   62 ++++
 gnome-initial-setup/gis-goa-page.c                 |  155 ++------
 gnome-initial-setup/setup.ui                       |   11 -
 5 files changed, 469 insertions(+), 127 deletions(-)
---
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index 671e60f..1a42cd7 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -39,6 +39,7 @@ gnome_initial_setup_SOURCES =	\
 	gis-location-page.c gis-location-page.h \
 	gis-network-page.c gis-network-page.h \
 	gis-goa-page.c gis-goa-page.h \
+	cc-online-accounts-add-account-dialog.c cc-online-accounts-add-account-dialog.h \
 	panel-cell-renderer-signal.c panel-cell-renderer-signal.h \
 	panel-cell-renderer-mode.c panel-cell-renderer-mode.h \
 	panel-cell-renderer-security.c panel-cell-renderer-security.h \
diff --git a/gnome-initial-setup/cc-online-accounts-add-account-dialog.c b/gnome-initial-setup/cc-online-accounts-add-account-dialog.c
new file mode 100644
index 0000000..d3a71e1
--- /dev/null
+++ b/gnome-initial-setup/cc-online-accounts-add-account-dialog.c
@@ -0,0 +1,367 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2012 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Debarshi Ray <debarshir gnome org>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+
+#define GOA_API_IS_SUBJECT_TO_CHANGE
+#define GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE
+#include <goabackend/goabackend.h>
+
+#include "cc-online-accounts-add-account-dialog.h"
+
+struct _GoaPanelAddAccountDialogPrivate
+{
+  GError *error;
+  GoaClient *client;
+  GoaObject *object;
+  GtkListStore *list_store;
+  GtkTreePath *path;
+  GtkWidget *tree_view;
+  gboolean ignore_release;
+};
+
+#define GOA_ADD_ACCOUNT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG, GoaPanelAddAccountDialogPrivate))
+
+enum
+{
+  PROP_0,
+  PROP_CLIENT,
+};
+
+enum
+{
+  COLUMN_PROVIDER,
+  COLUMN_ICON,
+  COLUMN_MARKUP,
+  N_COLUMNS
+};
+
+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)
+{
+  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));
+  for (l = children; l != NULL; l = l->next)
+    {
+      GtkWidget *child = l->data;
+      if (child != action_area)
+        gtk_container_remove (GTK_CONTAINER (vbox), child);
+    }
+  g_list_free (children);
+
+  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)
+{
+  GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (user_data);
+  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+
+  /* be sure to ignore double and triple clicks */
+  priv->ignore_release = (event->type != GDK_BUTTON_PRESS);
+
+  return FALSE;
+}
+
+static gboolean
+tree_view_button_release_event_cb (GtkWidget      *widget,
+                                   GdkEventButton *event,
+                                   gpointer       *user_data)
+{
+  GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (user_data);
+  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+  GtkTreePath *path;
+  GtkTreeViewColumn *column;
+
+  if (event->button != 1 || priv->ignore_release)
+    return TRUE;
+
+  gtk_tree_view_get_cursor (GTK_TREE_VIEW (widget), &path, &column);
+  if (path == NULL)
+    return TRUE;
+
+  gtk_tree_view_row_activated (GTK_TREE_VIEW (widget), path, column);
+  gtk_tree_path_free (path);
+
+  return TRUE;
+}
+
+static void
+tree_view_row_activated_cb (GtkTreeView       *tree_view,
+                            GtkTreePath       *path,
+                            GtkTreeViewColumn *column,
+                            gpointer           user_data)
+{
+  GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (user_data);
+  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+
+  priv->path = gtk_tree_path_copy (path);
+  add_account_dialog_add_account (add_account);
+  gtk_dialog_response (GTK_DIALOG (add_account), GTK_RESPONSE_OK);
+}
+
+static void
+goa_panel_add_account_dialog_realize (GtkWidget *widget)
+{
+  GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (widget);
+  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+  GtkWindow *parent;
+
+  parent = gtk_window_get_transient_for (GTK_WINDOW (add_account));
+  if (parent != NULL)
+    {
+      gint width;
+      gint height;
+
+      gtk_window_get_size (parent, &width, &height);
+      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);
+}
+
+static void
+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_OBJECT_CLASS (goa_panel_add_account_dialog_parent_class)->dispose (object);
+}
+
+static void
+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_OBJECT_CLASS (goa_panel_add_account_dialog_parent_class)->finalize (object);
+}
+
+static void
+goa_panel_add_account_dialog_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+  GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (object);
+  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+
+  switch (prop_id)
+    {
+    case PROP_CLIENT:
+      priv->client = GOA_CLIENT (g_value_dup_object (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+goa_panel_add_account_dialog_init (GoaPanelAddAccountDialog *add_account)
+{
+  GoaPanelAddAccountDialogPrivate *priv;
+  GtkCellRenderer *renderer;
+  GtkTreeSelection *selection;
+  GtkTreeViewColumn *column;
+  GtkWidget *label;
+  GtkWidget *sw;
+  GtkWidget *vbox;
+  gchar *markup;
+
+  add_account->priv = GOA_ADD_ACCOUNT_DIALOG_GET_PRIVATE (add_account);
+  priv = add_account->priv;
+
+  gtk_container_set_border_width (GTK_CONTAINER (add_account), 12);
+  gtk_window_set_modal (GTK_WINDOW (add_account), TRUE);
+  gtk_window_set_resizable (GTK_WINDOW (add_account), FALSE);
+  /* translators: This is the title of the "Add Account" dialogue.
+   * The title is not visible when using GNOME Shell */
+  gtk_window_set_title (GTK_WINDOW (add_account), _("Add Account"));
+
+  vbox = gtk_dialog_get_content_area (GTK_DIALOG (add_account));
+  gtk_box_set_spacing (GTK_BOX (vbox), 12);
+
+  label = gtk_label_new (NULL);
+  markup = g_strconcat ("<b>", _("Add Account"), "</b>", NULL);
+  gtk_label_set_markup (GTK_LABEL (label), markup);
+  g_free (markup);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+  priv->list_store = gtk_list_store_new (N_COLUMNS, GOA_TYPE_PROVIDER, G_TYPE_ICON, G_TYPE_STRING);
+
+  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_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
+
+  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);
+
+  column = gtk_tree_view_column_new ();
+  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), column);
+
+  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);
+
+  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);
+
+  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);
+
+  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);
+
+}
+
+static void
+goa_panel_add_account_dialog_class_init (GoaPanelAddAccountDialogClass *klass)
+{
+  GObjectClass *object_class;
+  GtkWidgetClass *widget_class;
+
+  object_class = G_OBJECT_CLASS (klass);
+  object_class->dispose = goa_panel_add_account_dialog_dispose;
+  object_class->finalize = goa_panel_add_account_dialog_finalize;
+  object_class->set_property = goa_panel_add_account_dialog_set_property;
+
+  widget_class = GTK_WIDGET_CLASS (klass);
+  widget_class->realize = goa_panel_add_account_dialog_realize;
+
+  g_type_class_add_private (object_class, sizeof (GoaPanelAddAccountDialogPrivate));
+
+  g_object_class_install_property (object_class,
+                                   PROP_CLIENT,
+                                   g_param_spec_object ("client",
+							"Goa Client",
+							"A Goa client for talking to the Goa daemon.",
+							GOA_TYPE_CLIENT,
+							G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+GtkWidget *
+goa_panel_add_account_dialog_new (GoaClient *client)
+{
+  return g_object_new (GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG, "client", client, NULL);
+}
+
+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;
+
+  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);
+
+  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);
+}
+
+GoaObject *
+goa_panel_add_account_dialog_get_account (GoaPanelAddAccountDialog *add_account, GError **error)
+{
+  GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
+
+  if (error != NULL && priv->error != NULL)
+    *error = g_error_copy (priv->error);
+
+  if (priv->object != NULL)
+    g_object_ref (priv->object);
+
+  return priv->object;
+}
diff --git a/gnome-initial-setup/cc-online-accounts-add-account-dialog.h b/gnome-initial-setup/cc-online-accounts-add-account-dialog.h
new file mode 100644
index 0000000..0f503cb
--- /dev/null
+++ b/gnome-initial-setup/cc-online-accounts-add-account-dialog.h
@@ -0,0 +1,62 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2012 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Debarshi Ray <debarshir gnome org>
+ */
+
+#ifndef __GOA_PANEL_ADD_ACCOUNT_DIALOG_H__
+#define __GOA_PANEL_ADD_ACCOUNT_DIALOG_H__
+
+#include <goa/goa.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG            (goa_panel_add_account_dialog_get_type ())
+#define GOA_PANEL_ADD_ACCOUNT_DIALOG(object)         (G_TYPE_CHECK_INSTANCE_CAST ((object), GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG, GoaPanelAddAccountDialog))
+#define GOA_PANEL_ADD_ACCOUNT_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG, GoaPanelAddAccountDialogClass))
+#define GOA_IS_PANEL_ADD_ACCOUNT_DIALOG(object)      (G_TYPE_CHECK_INSTANCE_TYPE ((object), GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG))
+#define GOA_IS_PANEL_ADD_ACCOUNT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG))
+#define GOA_PANEL_ADD_ACCOUNT_DIALOG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG, GoaPanelAddAccountDialogClass))
+
+typedef struct _GoaPanelAddAccountDialog        GoaPanelAddAccountDialog;
+typedef struct _GoaPanelAddAccountDialogClass   GoaPanelAddAccountDialogClass;
+typedef struct _GoaPanelAddAccountDialogPrivate GoaPanelAddAccountDialogPrivate;
+
+struct _GoaPanelAddAccountDialog
+{
+  GtkDialog parent_instance;
+  GoaPanelAddAccountDialogPrivate *priv;
+};
+
+struct _GoaPanelAddAccountDialogClass
+{
+  GtkDialogClass parent_class;
+};
+
+GType                  goa_panel_add_account_dialog_get_type               (void) G_GNUC_CONST;
+GtkWidget             *goa_panel_add_account_dialog_new                    (GoaClient *client);
+void                   goa_panel_add_account_dialog_add_provider           (GoaPanelAddAccountDialog *add_account,
+                                                                            GoaProvider              *provider);
+GoaObject             *goa_panel_add_account_dialog_get_account            (GoaPanelAddAccountDialog *add_account,
+                                                                            GError                   **error);
+
+G_END_DECLS
+
+#endif /* __GOA_PANEL_ADD_ACCOUNT_DIALOG_H__ */
diff --git a/gnome-initial-setup/gis-goa-page.c b/gnome-initial-setup/gis-goa-page.c
index bfb41fa..199ab7e 100644
--- a/gnome-initial-setup/gis-goa-page.c
+++ b/gnome-initial-setup/gis-goa-page.c
@@ -4,6 +4,7 @@
 
 #include "config.h"
 #include "gis-goa-page.h"
+#include "cc-online-accounts-add-account-dialog.h"
 
 #include <glib/gi18n.h>
 #include <gio/gio.h>
@@ -16,88 +17,52 @@ struct _GoaData {
   GoaClient *goa_client;
 };
 
-static GtkWidget *
-create_provider_button (const gchar *type, const gchar *name, GIcon *icon)
-{
-  GtkWidget *button;
-  GtkWidget *box;
-  GtkWidget *image;
-  GtkWidget *label;
-
-  button = gtk_button_new ();
-
-  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-  gtk_widget_set_halign (box, GTK_ALIGN_START);
-  gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
-  gtk_container_add (GTK_CONTAINER (button), box);
-
-  image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_BUTTON);
-  gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
-
-  label = gtk_label_new (name);
-  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
-
-  gtk_widget_show (box);
-  gtk_widget_show (image);
-  gtk_widget_show (label);
-
-  g_object_set_data (G_OBJECT (button), "provider-type", (gpointer)type);
-
-  return button;
-}
-
 static void
-add_account (GtkButton *button, gpointer user_data)
+show_online_account_dialog (GtkButton *button,
+                            gpointer   user_data)
 {
   GoaData *data = user_data;
+  GtkWindow *parent;
   GtkWidget *dialog;
-  GtkWidget *goa_dialog;
-  GtkWidget *vbox;
-  const gchar *provider_type;
-  GoaProvider *provider;
+  gint response;
+  GList *providers;
+  GList *l;
+  GoaObject *object;
   GError *error;
-  SetupData *setup = data->setup;
-
-  dialog = WID("online-accounts-dialog");
-  gtk_widget_hide (dialog);
-
-  provider_type = g_object_get_data (G_OBJECT (button), "provider-type");
 
-  g_debug ("Adding online account: %s", provider_type);
+  providers = NULL;
 
-  provider = goa_provider_get_for_provider_type (provider_type);
+  parent = GTK_WINDOW (gis_get_assistant (data->setup));
 
-  goa_dialog = gtk_dialog_new ();
+  dialog = goa_panel_add_account_dialog_new (data->goa_client);
+  gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
 
-  gtk_container_set_border_width (GTK_CONTAINER (goa_dialog), 12);
-  gtk_window_set_modal (GTK_WINDOW (goa_dialog), TRUE);
-  gtk_window_set_resizable (GTK_WINDOW (goa_dialog), TRUE);
-  gtk_window_set_transient_for (GTK_WINDOW (goa_dialog), GTK_WINDOW (gis_get_assistant (setup)));
-  /* translators: This is the title of the "Add Account" dialogue.
-   * The title is not visible when using GNOME Shell
-   */
-  gtk_window_set_title (GTK_WINDOW (goa_dialog), _("Add Account"));
-  gtk_dialog_add_button (GTK_DIALOG (goa_dialog),
-                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+  providers = goa_provider_get_all ();
+  for (l = providers; l != NULL; l = l->next)
+    {
+      GoaProvider *provider;
 
-  vbox = gtk_dialog_get_content_area (GTK_DIALOG (goa_dialog));
-  gtk_widget_set_vexpand (vbox, TRUE);
+      provider = GOA_PROVIDER (l->data);
+      goa_panel_add_account_dialog_add_provider (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), provider);
+    }
 
-  gtk_widget_show_all (goa_dialog);
-  gtk_window_present (GTK_WINDOW (goa_dialog));
+  gtk_widget_show_all (dialog);
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+  if (response != GTK_RESPONSE_OK)
+    {
+      gtk_widget_destroy (dialog);
+      goto out;
+    }
 
   error = NULL;
-  goa_provider_add_account (provider,
-                            data->goa_client,
-                            GTK_DIALOG (goa_dialog),
-                            GTK_BOX (vbox),
-                            &error);
-  gtk_widget_destroy (goa_dialog);
-
-  if (error &&
-      !(error->domain == GOA_ERROR && error->code == GOA_ERROR_DIALOG_DISMISSED))
+  object = goa_panel_add_account_dialog_get_account (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), &error);
+
+  if (object == NULL)
+    {
+      gtk_widget_destroy (dialog);
+      if (!(error->domain == GOA_ERROR && error->code == GOA_ERROR_DIALOG_DISMISSED))
         {
-          dialog = gtk_message_dialog_new (GTK_WINDOW (gis_get_assistant (setup)),
+          dialog = gtk_message_dialog_new (parent,
                                            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                            GTK_MESSAGE_ERROR,
                                            GTK_BUTTONS_CLOSE,
@@ -105,57 +70,16 @@ add_account (GtkButton *button, gpointer user_data)
           gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                                     "%s",
                                                     error->message);
-          gtk_widget_show (dialog);
+          gtk_widget_show_all (dialog);
           gtk_dialog_run (GTK_DIALOG (dialog));
           gtk_widget_destroy (dialog);
+        }
+      g_error_free (error);
     }
-}
-
-static void
-populate_online_account_dialog (GoaData *data)
-{
-  GtkWidget *dialog;
-  GtkWidget *content_area;
-  GList *providers, *l;
-  GoaProvider *provider;
-  gchar *provider_name;
-  const gchar *provider_type;
-  GIcon *provider_icon;
-  GtkWidget *button;
-  SetupData *setup = data->setup;
-
-  dialog = WID("online-accounts-dialog");
-  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-
-  providers = goa_provider_get_all ();
-  for (l = providers; l; l = l->next)
-    {
-      provider = GOA_PROVIDER (l->data);
-      provider_type = goa_provider_get_provider_type (provider);
-      provider_name = goa_provider_get_provider_name (provider, NULL);
-      provider_icon = goa_provider_get_provider_icon (provider, NULL);
-      button = create_provider_button (provider_type, provider_name, provider_icon);
-      gtk_container_add (GTK_CONTAINER (content_area), button);
-      gtk_widget_show (button);
-      g_free (provider_name);
-
-      g_signal_connect (button, "clicked", G_CALLBACK (add_account), setup);
-    }
-
-  g_signal_connect (dialog, "delete-event",
-                    G_CALLBACK (gtk_widget_hide_on_delete), NULL);
-}
-
-static void
-show_online_account_dialog (GtkButton *button, gpointer user_data)
-{
-  GoaData *data = user_data;
-  SetupData *setup = data->setup;
-  GtkWidget *dialog;
-
-  dialog = WID("online-accounts-dialog");
 
-  gtk_window_present (GTK_WINDOW (dialog));
+ out:
+  g_list_foreach (providers, (GFunc) g_object_unref, NULL);
+  g_list_free (providers);
 }
 
 static void
@@ -353,7 +277,6 @@ gis_prepare_online_page (SetupData *setup)
        return;
     }
 
-  populate_online_account_dialog (data);
   populate_account_list (data);
 
   button = WID("online-add-button");
diff --git a/gnome-initial-setup/setup.ui b/gnome-initial-setup/setup.ui
index 7e19fbc..d4642ff 100644
--- a/gnome-initial-setup/setup.ui
+++ b/gnome-initial-setup/setup.ui
@@ -36,17 +36,6 @@
       <column type="gchararray"/>
     </columns>
   </object>
-  <object class="GtkDialog" id="online-accounts-dialog">
-    <property name="title"></property>
-    <property name="transient-for">gnome-setup-assistant</property>
-    <property name="modal">True</property>
-    <property name="resizable">False</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="online-accounts-dialog-content-area">
-        <property name="margin">12</property>
-      </object>
-    </child>
-  </object>
   <object class="GtkDialog" id="local-account-dialog">
     <property name="title"></property>
     <property name="transient-for">gnome-setup-assistant</property>



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