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



commit 22f9ce923fbf7851fe8a7eb30efe7977d2e5a29b
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 07d6cea..ef22b4d 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
   GoaObject *edited_object;
   GoaObject *removed_object;
 
+  GtkWidget *accounts_frame;
   GtkWidget *accounts_listbox;
   GtkWidget *edit_account_dialog;
   GtkWidget *edit_account_headerbar;
@@ -487,6 +488,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);
@@ -699,6 +701,7 @@ on_account_added (GoaClient *client,
 
   /* Add to the listbox */
   gtk_container_add (GTK_CONTAINER (self->accounts_listbox), row);
+  gtk_widget_show (self->accounts_frame);
 
   g_clear_pointer (&title, g_free);
   g_clear_object (&gicon);
@@ -723,10 +726,14 @@ on_account_removed (GoaClient *client,
       if (row_object == object)
         {
           gtk_widget_destroy (l->data);
+          children = g_list_remove (children, l);
           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 3d01d05..c95051d 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]