[gnome-control-center/wip/gbsneto/new-goa-panel: 11/25] 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: 11/25] online-accounts: make adding an account inline to the edit dialog
- Date: Sat, 26 Nov 2016 10:09:32 +0000 (UTC)
commit a0e1213339658e7afc70a4672f1b6903138ea8d6
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 | 55 +++++++++++++++++++++
panels/online-accounts/online-accounts.ui | 2 +
2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c
b/panels/online-accounts/cc-online-accounts-panel.c
index 2555fe7..499da78 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -43,6 +43,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;
@@ -72,6 +73,9 @@ static void get_all_providers_cb (GObject *source,
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 {
@@ -82,6 +86,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)
{
@@ -145,6 +165,37 @@ sort_providers_func (GtkListBoxRow *a,
goa_provider_get_provider_name (b_provider, NULL));
}
+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), "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);
+}
/* ---------------------------------------------------------------------------------------------------- */
@@ -357,10 +408,12 @@ 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_listbox_row_activated);
+ gtk_widget_class_bind_template_callback (widget_class, on_provider_row_activated);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -377,6 +430,8 @@ show_page_account (CcGoaPanel *panel,
provider = NULL;
+ 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 f2e79f8..05bcea8 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -62,6 +62,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>
@@ -77,6 +78,7 @@
<property name="use_header_bar">1</property>
<property name="resizable">False</property>
<property name="modal">True</property>
+ <signal name="response" handler="gtk_widget_hide" object="edit_account_dialog" swapped="no" />
<signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no" />
<child type="titlebar">
<object class="GtkHeaderBar" id="edit_account_headerbar">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]