[gnome-control-center/wip/rishi/new-goa-panel: 5/5] online-accounts: Only show the accounts list when there are accounts



commit fd095e82e062eee5e3843de144f632473d04989a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Nov 10 19:27:44 2016 -0200

    online-accounts: Only show the accounts list when there are accounts
    
    When the user has no account set, the current implementation of the Online
    Accounts panel shows a weird 1px line that is the empty list.
    
    Fix that by only showing the list when there are accounts available.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774222

 panels/online-accounts/cc-online-accounts-panel.c |    7 +++++++
 panels/online-accounts/online-accounts.ui         |    1 -
 2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c 
b/panels/online-accounts/cc-online-accounts-panel.c
index ea3b349..05acc48 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -42,6 +42,7 @@ struct _CcGoaPanel
   GoaObject *active_object;
   GoaObject *removed_object;
 
+  GtkWidget *accounts_frame;
   GtkWidget *accounts_listbox;
   GtkWidget *edit_account_dialog;
   GtkWidget *edit_account_headerbar;
@@ -495,6 +496,7 @@ cc_goa_panel_class_init (CcGoaPanelClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/online-accounts/online-accounts.ui");
 
+  gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_frame);
   gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_listbox);
   gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_vbox);
   gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_dialog);
@@ -718,6 +720,7 @@ on_account_added (GoaClient *client,
   /* Add to the listbox */
   gtk_container_add (GTK_CONTAINER (self->accounts_listbox), row);
   gtk_widget_show_all (row);
+  gtk_widget_show (self->accounts_frame);
 
   g_clear_pointer (&title, g_free);
   g_clear_object (&gicon);
@@ -755,10 +758,14 @@ on_account_removed (GoaClient *client,
       if (row_object == object)
         {
           gtk_widget_destroy (l->data);
+          children = g_list_remove (children, l->data);
           break;
         }
     }
 
+  /* Hide the list if we removed the last account */
+  gtk_widget_set_visible (self->accounts_frame, children != NULL);
+
   g_list_free (children);
 }
 
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index ea423e6..049481c 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -139,7 +139,6 @@
                 </child>
                 <child>
                   <object class="GtkFrame" id="accounts_frame">
-                    <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
                       <object class="GtkListBox" id="accounts_listbox">


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]