gnome-initial-setup/0001-gis-goa-page-Port-to-new-async-provider-API.patch

125 lines
3.6 KiB
Diff

From 74ce9a6005523558c6014e12efe3b03e91aaa187 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Thu, 22 Aug 2013 15:48:53 -0400
Subject: [PATCH] gis-goa-page: Port to new async provider API
The API changed with https://git.gnome.org/browse/gnome-online-accounts/commit/?id=1a8bfdf90fd24e9bbaeeae15ff9f16e847a6b48e
Update this page to be async. Ideally we'd have a loading API, but
eh.
https://bugzilla.gnome.org/show_bug.cgi?id=706608
---
gnome-initial-setup/pages/goa/gis-goa-page.c | 60 ++++++++++++++++++----------
1 file changed, 40 insertions(+), 20 deletions(-)
diff --git a/gnome-initial-setup/pages/goa/gis-goa-page.c b/gnome-initial-setup/pages/goa/gis-goa-page.c
index fa83734..df93195 100644
--- a/gnome-initial-setup/pages/goa/gis-goa-page.c
+++ b/gnome-initial-setup/pages/goa/gis-goa-page.c
@@ -47,6 +47,7 @@ G_DEFINE_TYPE (GisGoaPage, gis_goa_page, GIS_TYPE_PAGE);
struct _GisGoaPagePrivate {
GoaClient *goa_client;
+ GtkWidget *dialog;
gboolean accounts_exist;
};
@@ -54,6 +55,39 @@ struct _GisGoaPagePrivate {
#define WID(name) OBJ(GtkWidget*,name)
static void
+on_have_providers (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GList *providers;
+ GList *l;
+ GError *error = NULL;
+ GisGoaPage *page = GIS_GOA_PAGE (user_data);
+ GisGoaPagePrivate *priv = page->priv;
+
+ if (!goa_provider_get_all_finish (&providers, res, &error))
+ goto out;
+
+ 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);
+ }
+}
+
+static void
show_online_account_dialog (GtkButton *button,
gpointer user_data)
{
@@ -62,36 +96,24 @@ show_online_account_dialog (GtkButton *button,
GtkWindow *parent;
GtkWidget *dialog;
gint response;
- GList *providers;
- GList *l;
GoaObject *object;
GError *error;
- providers = NULL;
-
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);
-
- providers = goa_provider_get_all ();
- for (l = providers; l != NULL; l = l->next)
- {
- GoaProvider *provider;
+ priv->dialog = goa_panel_add_account_dialog_new (priv->goa_client);
+ gtk_window_set_transient_for (GTK_WINDOW (priv->dialog), parent);
- provider = GOA_PROVIDER (l->data);
- goa_panel_add_account_dialog_add_provider (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), provider);
- }
+ goa_provider_get_all (on_have_providers, page);
- gtk_widget_show_all (dialog);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
+ 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;
}
- error = NULL;
object = goa_panel_add_account_dialog_get_account (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), &error);
if (object == NULL)
@@ -113,10 +135,8 @@ show_online_account_dialog (GtkButton *button,
}
g_error_free (error);
}
-
out:
- g_list_foreach (providers, (GFunc) g_object_unref, NULL);
- g_list_free (providers);
+ return;
}
static void
--
1.8.3.1