Commit 3bfc0a5f authored by Rohit Kaushik's avatar Rohit Kaushik Committed by Georges Basile Stavracas Neto
Browse files

todoist: Show accounts page only if todoist account is present

This patch enable empty page as default intial page and switches
the stack child to accounts page if any todoist account was added.
Incase, an account was removed, we need to check if no account is
present after this removal and switch to empty page, if true.
parent ba897006
......@@ -129,10 +129,12 @@ on_goa_account_added (GoaClient *client,
GtkWidget *box;
GtkWidget *logo;
GtkWidget *desc;
GList *child;
const gchar *provider_name;
const gchar *identity;
goa_account = goa_object_get_account (object);
child = NULL;
provider_name = goa_account_get_provider_name (goa_account);
if (g_strcmp0 (provider_name, "Todoist") != 0)
......@@ -153,7 +155,18 @@ on_goa_account_added (GoaClient *client,
gtk_container_add (GTK_CONTAINER (row), box);
gtk_widget_show_all (row);
child = gtk_container_get_children (GTK_CONTAINER (self->accounts_listbox));
/* If List Box was empty before this addition, the preferences
* panel should change to accounts_page.
if (!child)
gtk_stack_set_visible_child (GTK_STACK (self), self->accounts_page);
gtk_list_box_insert (GTK_LIST_BOX (self->accounts_listbox), GTK_WIDGET (row), -1);
g_list_free (child);
static void
......@@ -165,6 +178,7 @@ on_goa_account_removed (GoaClient *client,
GList *child;
GList *l;
const gchar *provider;
guint todoist_accounts;
goa_account = goa_object_get_account (object);
provider = goa_account_get_provider_name (goa_account);
......@@ -175,6 +189,7 @@ on_goa_account_removed (GoaClient *client,
child = gtk_container_get_children (GTK_CONTAINER (self->accounts_listbox));
todoist_accounts = g_list_length (child);
for (l = child; l != NULL; l = l->next)
......@@ -185,10 +200,19 @@ on_goa_account_removed (GoaClient *client,
if (row_account == object)
gtk_container_remove (GTK_CONTAINER (self->accounts_listbox),l->data);
/* Check if ListBox becomes empty after this removal.
* If true change to empty_page of preference panel.
if (!todoist_accounts)
gtk_stack_set_visible_child (GTK_STACK (self), self->empty_page);
g_list_free (child);
......@@ -277,7 +301,9 @@ gtd_todoist_preferences_panel_init (GtdTodoistPreferencesPanel *self)
gtk_widget_init_template (GTK_WIDGET (self));
/* Set Empty Page as the default initial preferences page */
gtk_stack_set_visible_child (GTK_STACK (self), self->empty_page);
label = gtk_label_new ("No Todoist account configured");
gtk_widget_show (label);
gtk_list_box_set_placeholder (GTK_LIST_BOX (self->accounts_listbox), GTK_WIDGET (label));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment