[gnome-control-center] online-accounts: Make adding an account inline to the edit dialog
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] online-accounts: Make adding an account inline to the edit dialog
- Date: Wed, 8 Feb 2017 16:34:12 +0000 (UTC)
commit d50a07da565a19a9cc8d11a07ebcfca4535c0f4d
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 | 56 +++++++++++++++++++++
panels/online-accounts/online-accounts.ui | 1 +
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 3a10347..249bc51 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,9 @@ static void get_all_providers_cb (GObject *source,
GAsyncResult *res,
gpointer user_data);
+static void show_page_account (CcGoaPanel *panel,
+ GoaObject *object);
+
CC_PANEL_REGISTER (CcGoaPanel, cc_goa_panel);
enum {
@@ -85,6 +89,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)
{
@@ -132,6 +152,39 @@ add_provider_row (CcGoaPanel *self,
g_object_unref (icon);
}
+static void
+on_provider_row_activated (CcGoaPanel *self,
+ GtkListBoxRow *activated_row)
+{
+ 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 == NULL)
+ gtk_widget_hide (self->edit_account_dialog);
+ else
+ show_page_account (self, object);
+}
+
/* ---------------------------------------------------------------------------------------------------- */
static gint
@@ -344,11 +397,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 +428,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..f5869ca 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="yes" />
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]