[gnome-control-center/wip/cdavis/40-consistency: 5/5] online-accounts: Use libhandy preferences styling




commit 94b17cd0a4769435a39a07014c6368b665d3d198
Author: Christopher Davis <brainblasted disroot org>
Date:   Wed Feb 10 00:34:27 2021 -0800

    online-accounts: Use libhandy preferences styling
    
    See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1190

 panels/online-accounts/cc-online-accounts-panel.c |  47 ++++-----
 panels/online-accounts/online-accounts.ui         | 114 +++++++++-------------
 2 files changed, 68 insertions(+), 93 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c 
b/panels/online-accounts/cc-online-accounts-panel.c
index 642396cb3..eeeecb7bc 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -23,6 +23,7 @@
 #include <gio/gio.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
+#include <libhandy-1/handy.h>
 
 #define GOA_API_IS_SUBJECT_TO_CHANGE
 #include <goa/goa.h>
@@ -38,20 +39,20 @@ struct _CcGoaPanel
 {
   CcPanel parent_instance;
 
-  GtkFrame      *accounts_frame;
-  GtkListBox    *accounts_listbox;
-  GtkDialog     *edit_account_dialog;
-  GtkHeaderBar  *edit_account_headerbar;
-  GtkBox        *editor_box;
-  GtkListBoxRow *more_providers_row;
-  GtkBox        *new_account_vbox;
-  GtkLabel      *notification_label;
-  GtkRevealer   *notification_revealer;
-  GtkLabel      *offline_label;
-  GtkListBox    *providers_listbox;
-  GtkButton     *remove_account_button;
-  GtkStack      *stack;
-  GtkBox        *accounts_vbox;
+  HdyPreferencesGroup *accounts_group;
+  GtkListBox          *accounts_listbox;
+  GtkDialog           *edit_account_dialog;
+  GtkHeaderBar        *edit_account_headerbar;
+  GtkBox              *editor_box;
+  GtkListBoxRow       *more_providers_row;
+  GtkBox              *new_account_vbox;
+  GtkLabel            *notification_label;
+  GtkRevealer         *notification_revealer;
+  GtkLabel            *offline_label;
+  GtkListBox          *providers_listbox;
+  GtkButton           *remove_account_button;
+  GtkStack            *stack;
+  GtkBox              *accounts_vbox;
 
   GoaClient *client;
   GoaObject *active_object;
@@ -438,19 +439,11 @@ cc_goa_panel_init (CcGoaPanel *panel)
 
   gtk_widget_init_template (GTK_WIDGET (panel));
 
-  gtk_list_box_set_header_func (panel->accounts_listbox,
-                                cc_list_box_update_header_func,
-                                NULL,
-                                NULL);
   gtk_list_box_set_sort_func (panel->accounts_listbox,
                               sort_func,
                               panel,
                               NULL);
 
-  gtk_list_box_set_header_func (panel->providers_listbox,
-                                cc_list_box_update_header_func,
-                                NULL,
-                                NULL);
   gtk_list_box_set_sort_func (panel->providers_listbox,
                               sort_providers_func,
                               panel,
@@ -536,7 +529,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_group);
   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);
@@ -706,21 +699,21 @@ static void
 hide_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
 {
   gtk_widget_hide (row);
-  gtk_widget_set_visible (GTK_WIDGET (self->accounts_frame), other_rows != NULL);
+  gtk_widget_set_visible (GTK_WIDGET (self->accounts_group), other_rows != NULL);
 }
 
 static void
 remove_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
 {
   gtk_widget_destroy (row);
-  gtk_widget_set_visible (GTK_WIDGET (self->accounts_frame), other_rows != NULL);
+  gtk_widget_set_visible (GTK_WIDGET (self->accounts_group), other_rows != NULL);
 }
 
 static void
 show_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
 {
   gtk_widget_show (row);
-  gtk_widget_show (GTK_WIDGET (self->accounts_frame));
+  gtk_widget_show (GTK_WIDGET (self->accounts_group));
 }
 
 static void
@@ -824,7 +817,7 @@ on_account_added (GoaClient *client,
 
   /* Add to the listbox */
   gtk_container_add (GTK_CONTAINER (self->accounts_listbox), row);
-  gtk_widget_show (GTK_WIDGET (self->accounts_frame));
+  gtk_widget_show (GTK_WIDGET (self->accounts_group));
 
   g_clear_pointer (&title, g_free);
   g_clear_object (&gicon);
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index c101964d9..ab5e91031 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -64,19 +64,11 @@
           </object>
         </child>
         <child>
-          <object class="GtkScrolledWindow">
+          <object class="HdyPreferencesPage">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">never</property>
-            <property name="min_content_height">500</property>
             <child>
-              <object class="HdyClamp">
+              <object class="HdyPreferencesGroup">
                 <property name="visible">True</property>
-                <property name="margin_top">32</property>
-                <property name="margin_bottom">32</property>
-                <property name="margin_start">12</property>
-                <property name="margin_end">12</property>
-
                 <child>
                   <object class="GtkBox">
                     <property name="visible">True</property>
@@ -84,7 +76,6 @@
                     <property name="spacing">12</property>
                     <property name="orientation">vertical</property>
                     <property name="hexpand">True</property>
-
                     <child>
                       <object class="GtkLabel" id="accounts_label">
                         <property name="visible">True</property>
@@ -109,69 +100,60 @@
                         <property name="label" translatable="yes">No internet connection — connect to set up 
new online accounts</property>
                       </object>
                     </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="HdyPreferencesGroup" id="accounts_group">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkListBox" id="accounts_listbox">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="selection_mode">none</property>
+                    <signal name="row-activated" handler="on_listbox_row_activated" object="CcGoaPanel" 
swapped="yes" />
+                    <accessibility>
+                      <relation target="accounts_label" type="labelled-by"/>
+                    </accessibility>
+                    <style>
+                      <class name="content"/>
+                    </style>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="HdyPreferencesGroup" id="providers_group">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes">Add an account</property>
+                <child>
+                  <object class="GtkListBox" id="providers_listbox">
+                    <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" />
+                    <accessibility>
+                      <relation target="providers_group" type="labelled-by"/>
+                    </accessibility>
                     <child>
-                      <object class="GtkFrame" id="accounts_frame">
-                        <property name="can_focus">False</property>
-                        <child>
-                          <object class="GtkListBox" id="accounts_listbox">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="selection_mode">none</property>
-                            <signal name="row-activated" handler="on_listbox_row_activated" 
object="CcGoaPanel" swapped="yes" />
-                            <accessibility>
-                              <relation target="accounts_label" type="labelled-by"/>
-                            </accessibility>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="providers_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="margin-top">20</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Add an account</property>
-                        <attributes>
-                          <attribute name="weight" value="bold" />
-                        </attributes>
-                        <accessibility>
-                          <relation target="providers_listbox" type="label-for"/>
-                        </accessibility>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkFrame">
+                      <object class="GtkListBoxRow" id="more_providers_row">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
+                        <property name="can_focus">True</property>
                         <child>
-                          <object class="GtkListBox" id="providers_listbox">
+                          <object class="GtkImage">
                             <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" />
-                            <accessibility>
-                              <relation target="providers_label" type="labelled-by"/>
-                            </accessibility>
-                            <child>
-                              <object class="GtkListBoxRow" id="more_providers_row">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <child>
-                                  <object class="GtkImage">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="hexpand">True</property>
-                                    <property name="margin">22</property>
-                                    <property name="icon-name">view-more-symbolic</property>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
+                            <property name="can_focus">False</property>
+                            <property name="hexpand">True</property>
+                            <property name="margin">22</property>
+                            <property name="icon-name">view-more-symbolic</property>
                           </object>
                         </child>
                       </object>
                     </child>
+                    <style>
+                      <class name="content"/>
+                    </style>
                   </object>
                 </child>
               </object>


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