[gnome-initial-setup] Accounts: really pick up data from online accounts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] Accounts: really pick up data from online accounts
- Date: Tue, 25 Feb 2014 05:04:25 +0000 (UTC)
commit af75c3e964738d7e595cfcb9f17b635fda73ebcf
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Feb 24 23:37:12 2014 -0500
Accounts: really pick up data from online accounts
The prepopulate code was only run at the time the page is
constructed, which is before the goa page is shown. Instead,
listen for goa accounts that are added, and update the information.
.../pages/account/gis-account-page-local.c | 67 +++++++++++++-------
1 files changed, 45 insertions(+), 22 deletions(-)
---
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.c
b/gnome-initial-setup/pages/account/gis-account-page-local.c
index 3d273e1..24d2b6a 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.c
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.c
@@ -49,6 +49,8 @@ struct _GisAccountPageLocalPrivate
ActUser *act_user;
ActUserManager *act_client;
+ GoaClient *goa_client;
+
gboolean valid_name;
gboolean valid_username;
ActUserAccountType account_type;
@@ -148,22 +150,13 @@ static void
prepopulate_account_page (GisAccountPageLocal *page)
{
GisAccountPageLocalPrivate *priv = gis_account_page_local_get_instance_private (page);
- GoaClient *client;
- GError *error = NULL;
gchar *name = NULL;
gchar *picture = NULL;
GdkPixbuf *pixbuf = NULL;
- priv->valid_name = FALSE;
- priv->valid_username = FALSE;
-
- /* FIXME: change this for a large deployment scenario; maybe through a GSetting? */
- priv->account_type = ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR;
-
- client = goa_client_new_sync (NULL, &error);
- if (client) {
+ if (priv->goa_client) {
GList *accounts, *l;
- accounts = goa_client_get_accounts (client);
+ accounts = goa_client_get_accounts (priv->goa_client);
for (l = accounts; l != NULL; l = l->next) {
GoaOAuth2Based *oa2;
oa2 = goa_object_get_oauth2_based (GOA_OBJECT (l->data));
@@ -178,18 +171,12 @@ prepopulate_account_page (GisAccountPageLocal *page)
}
}
g_list_free_full (accounts, (GDestroyNotify) g_object_unref);
- g_object_unref (client);
}
if (name) {
gtk_label_set_text (GTK_LABEL (priv->subtitle), _("Are these the right details? You can change them if
you want."));
gtk_entry_set_text (GTK_ENTRY (priv->fullname_entry), name);
}
- else {
- gtk_label_set_text (GTK_LABEL (priv->subtitle), _("We need a few details to complete setup."));
- gtk_entry_set_text (GTK_ENTRY (priv->fullname_entry), "");
- gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (priv->username_combo))));
- }
if (picture) {
GFile *file;
@@ -204,16 +191,20 @@ prepopulate_account_page (GisAccountPageLocal *page)
if (pixbuf) {
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->avatar_image), pixbuf);
}
- else {
- gtk_image_set_pixel_size (GTK_IMAGE (priv->avatar_image), 96);
- gtk_image_set_from_icon_name (GTK_IMAGE (priv->avatar_image), "avatar-default-symbolic", 1);
- }
g_free (name);
g_free (picture);
}
static void
+accounts_changed (GoaClient *client, GoaObject *object, gpointer data)
+{
+ GisAccountPageLocal *page = data;
+
+ prepopulate_account_page (page);
+}
+
+static void
fullname_changed (GtkWidget *w,
GParamSpec *pspec,
GisAccountPageLocal *page)
@@ -285,7 +276,38 @@ gis_account_page_local_constructed (GObject *object)
g_signal_connect (priv->username_combo, "changed",
G_CALLBACK (username_changed), page);
- prepopulate_account_page (page);
+ priv->goa_client = goa_client_new_sync (NULL, NULL);
+ if (priv->goa_client) {
+ g_signal_connect (priv->goa_client, "account-added",
+ G_CALLBACK (accounts_changed), page);
+ g_signal_connect (priv->goa_client, "account-removed",
+ G_CALLBACK (accounts_changed), page);
+
+ }
+
+ priv->valid_name = FALSE;
+ priv->valid_username = FALSE;
+
+ /* FIXME: change this for a large deployment scenario; maybe through a GSetting? */
+ priv->account_type = ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR;
+
+ gtk_label_set_text (GTK_LABEL (priv->subtitle), _("We need a few details to complete setup."));
+ gtk_entry_set_text (GTK_ENTRY (priv->fullname_entry), "");
+ gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (priv->username_combo))));
+
+ gtk_image_set_pixel_size (GTK_IMAGE (priv->avatar_image), 96);
+ gtk_image_set_from_icon_name (GTK_IMAGE (priv->avatar_image), "avatar-default-symbolic", 1);
+}
+
+static void
+gis_account_page_local_dispose (GObject *object)
+{
+ GisAccountPageLocal *page = GIS_ACCOUNT_PAGE_LOCAL (object);
+ GisAccountPageLocalPrivate *priv = gis_account_page_local_get_instance_private (page);
+
+ g_clear_object (&priv->goa_client);
+
+ G_OBJECT_CLASS (gis_account_page_local_parent_class)->dispose (object);
}
static void
@@ -325,6 +347,7 @@ gis_account_page_local_class_init (GisAccountPageLocalClass *klass)
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisAccountPageLocal,
username_combo);
object_class->constructed = gis_account_page_local_constructed;
+ object_class->dispose = gis_account_page_local_dispose;
signals[VALIDATION_CHANGED] = g_signal_new ("validation-changed", GIS_TYPE_ACCOUNT_PAGE_LOCAL,
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]