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
This commit is contained in:
parent
e601ae74ee
commit
d50a07da56
2 changed files with 57 additions and 0 deletions
|
@ -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 {
|
||||
|
@ -84,6 +88,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");
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue