[gnome-control-center] online-accounts: Fix parameter parsing
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] online-accounts: Fix parameter parsing
- Date: Sat, 19 Aug 2017 14:31:42 +0000 (UTC)
commit a9bf8b5b04a195d70639747ad35ca0455b80e7dd
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Aug 19 11:23:12 2017 -0300
online-accounts: Fix parameter parsing
The Online Accounts panel supports two commands: 'add'
and 'show-account'. The 'add' command must receive an
additional parameter, the 'provider' name, and an
optional 'preseed' parameter.
In the past, Settings would just push all the parameters
to a GVariant and pass to the panels. Now, however, it
skips the first one, making the parameter parsing code
in Online Accounts panel wrong.
This patch fix that by refactoring add_account() code,
and fixing the GVariant parameter parsing.
panels/online-accounts/cc-online-accounts-panel.c | 47 +++++++++++++--------
1 files changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c
b/panels/online-accounts/cc-online-accounts-panel.c
index 0715a0c..edd140e 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -233,22 +233,14 @@ show_non_branded_providers (CcGoaPanel *self)
}
static void
-on_provider_row_activated (CcGoaPanel *self,
- GtkListBoxRow *activated_row)
+add_account (CcGoaPanel *self,
+ GoaProvider *provider,
+ GVariant *preseed)
{
- GoaProvider *provider;
GoaObject *object;
GError *error;
- /* Show More row */
- if (activated_row == GTK_LIST_BOX_ROW (self->more_providers_row))
- {
- show_non_branded_providers (self);
- return;
- }
-
error = NULL;
- provider = g_object_get_data (G_OBJECT (activated_row), "goa-provider");
gtk_container_foreach (GTK_CONTAINER (self->new_account_vbox),
(GtkCallback) gtk_widget_destroy,
@@ -269,12 +261,33 @@ on_provider_row_activated (CcGoaPanel *self,
GTK_BOX (self->new_account_vbox),
&error);
+ if (preseed)
+ goa_provider_set_preseed_data (provider, preseed);
+
if (object == NULL)
gtk_widget_hide (self->edit_account_dialog);
else
show_page_account (self, object);
}
+static void
+on_provider_row_activated (CcGoaPanel *self,
+ GtkListBoxRow *activated_row)
+{
+ GoaProvider *provider;
+
+ /* Show More row */
+ if (activated_row == GTK_LIST_BOX_ROW (self->more_providers_row))
+ {
+ show_non_branded_providers (self);
+ return;
+ }
+
+ provider = g_object_get_data (G_OBJECT (activated_row), "goa-provider");
+
+ add_account (self, provider, NULL);
+}
+
/* ---------------------------------------------------------------------------------------------------- */
static gint
@@ -307,20 +320,16 @@ command_add (CcGoaPanel *panel,
switch (g_variant_n_children (parameters))
{
- case 4:
- g_variant_get_child (parameters, 3, "v", &preseed);
case 3:
- g_variant_get_child (parameters, 2, "v", &v);
+ g_variant_get_child (parameters, 2, "v", &preseed);
+ case 2:
+ g_variant_get_child (parameters, 1, "v", &v);
if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
provider_name = g_variant_get_string (v, NULL);
else
g_warning ("Wrong type for the second argument (provider name) GVariant, expected 's' but got
'%s'",
(gchar *)g_variant_get_type (v));
g_variant_unref (v);
- case 2:
- /* Nothing to see here, move along */
- case 1:
- /* No flag to handle here */
break;
default:
g_warning ("Unexpected parameters found, ignore request");
@@ -335,6 +344,8 @@ command_add (CcGoaPanel *panel,
g_warning ("Unable to get a provider for type '%s'", provider_name);
goto out;
}
+
+ add_account (panel, provider, preseed);
}
out:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]