[gnome-control-center/wip/gbsneto/new-goa-panel: 63/76] online-accounts: make adding an account inline to the edit dialog
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/gbsneto/new-goa-panel: 63/76] online-accounts: make adding an account inline to the edit dialog
- Date: Wed, 25 Jan 2017 22:53:07 +0000 (UTC)
commit 0ce7b94e70be1e64acf6e92167c8a4b57ad36340
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Nov 10 11:17:46 2016 -0200
online-accounts: make adding an account inline to the edit dialog
When adding an account, the old proccess was: use the (removed) toolbar
to open the New Account dialog, select a provider in that dialog, add
the account and see the newly created account in the panel itself.
That approach had issues, e.g. the user would have to close the dialog
if she mistakenly selected a provider. After moving the provider list
to the panel itself, it doesn't make sense anymore to have another
provider list inside the dialog.
Fix this by moving the new account view to the accounts dialog.
https://bugzilla.gnome.org/show_bug.cgi?id=774222
panels/online-accounts/cc-online-accounts-panel.c | 60 ++++++++++++++++++++-
panels/online-accounts/online-accounts.ui | 2 +
2 files changed, 61 insertions(+), 1 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c
b/panels/online-accounts/cc-online-accounts-panel.c
index 084a765..743cce6 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -44,6 +44,7 @@ struct _CcGoaPanel
GtkWidget *accounts_listbox;
GtkWidget *edit_account_dialog;
GtkWidget *edit_account_headerbar;
+ GtkWidget *new_account_vbox;
GtkWidget *providers_listbox;
GtkWidget *stack;
GtkWidget *accounts_vbox;
@@ -75,6 +76,12 @@ static void get_all_providers_cb (GObject *source,
GAsyncResult *res,
gpointer user_data);
+static void add_provider_row (CcGoaPanel *self,
+ GoaProvider *provider);
+
+static void show_page_account (CcGoaPanel *panel,
+ GoaObject *object);
+
CC_PANEL_REGISTER (CcGoaPanel, cc_goa_panel);
enum {
@@ -85,6 +92,22 @@ enum {
/* ---------------------------------------------------------------------------------------------------- */
static void
+reset_headerbar (CcGoaPanel *self)
+{
+ gtk_header_bar_set_title (GTK_HEADER_BAR (self->edit_account_headerbar), NULL);
+ gtk_header_bar_set_subtitle (GTK_HEADER_BAR (self->edit_account_headerbar), NULL);
+ gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self->edit_account_headerbar), TRUE);
+
+ /* Remove any leftover widgets */
+ gtk_container_foreach (GTK_CONTAINER (self->edit_account_headerbar),
+ (GtkCallback) gtk_widget_destroy,
+ NULL);
+
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
add_provider_row (CcGoaPanel *self,
GoaProvider *provider)
{
@@ -106,7 +129,7 @@ add_provider_row (CcGoaPanel *self,
if (provider == NULL)
{
- g_object_set_data (G_OBJECT (row), "provider", NULL);
+ g_object_set_data (G_OBJECT (row), "goa-provider", NULL);
icon = g_themed_icon_new_with_default_fallbacks ("goa-account");
name = g_strdup (C_("Online Account", "Other"));
}
@@ -132,6 +155,38 @@ add_provider_row (CcGoaPanel *self,
g_object_unref (icon);
}
+static void
+on_provider_row_activated (GtkListBox *listbox,
+ GtkListBoxRow *activated_row,
+ CcGoaPanel *self)
+{
+ GoaProvider *provider;
+ GoaObject *object;
+ GError *error;
+
+ 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,
+ NULL);
+
+ reset_headerbar (self);
+
+ /* Move to the new account page */
+ gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "new-account");
+
+ /* This spins gtk_dialog_run() */
+ object = goa_provider_add_account (provider,
+ self->client,
+ GTK_DIALOG (self->edit_account_dialog),
+ GTK_BOX (self->new_account_vbox),
+ &error);
+
+ if (object)
+ show_page_account (self, object);
+}
+
/* ---------------------------------------------------------------------------------------------------- */
static gint
@@ -344,11 +399,13 @@ cc_goa_panel_class_init (CcGoaPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_vbox);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_dialog);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_headerbar);
+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, new_account_vbox);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, providers_listbox);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, stack);
gtk_widget_class_bind_template_callback (widget_class, on_edit_account_dialog_delete_event);
gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
+ gtk_widget_class_bind_template_callback (widget_class, on_provider_row_activated);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -373,6 +430,7 @@ show_page_account (CcGoaPanel *panel,
provider = NULL;
panel->active_object = object;
+ reset_headerbar (panel);
/* Move to the account editor page */
gtk_stack_set_visible_child_name (GTK_STACK (panel->stack), "editor");
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index 13f03ee..deccc41 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -63,6 +63,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
+ <signal name="row-activated" handler="on_provider_row_activated" object="CcGoaPanel"
swapped="no" />
</object>
</child>
</object>
@@ -79,6 +80,7 @@
<property name="resizable">False</property>
<property name="modal">True</property>
<signal name="delete-event" handler="on_edit_account_dialog_delete_event" object="CcGoaPanel"
swapped="yes" />
+ <signal name="response" handler="gtk_widget_hide" object="edit_account_dialog" swapped="no" />
<child type="titlebar">
<object class="GtkHeaderBar" id="edit_account_headerbar">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]