[gnome-control-center/wip/cdavis/date-and-time-polish: 4/5] cc-datetime-panel: Use AdwPreferencesGroup




commit eb5749eee1590e90fe7eb6ad2a2226a515fa8062
Author: Christopher Davis <christopherdavis gnome org>
Date:   Fri Dec 31 00:09:37 2021 -0800

    cc-datetime-panel: Use AdwPreferencesGroup
    
    Lets us get rid of our manual listboxes.

 panels/datetime/cc-datetime-panel.c  |  23 -----
 panels/datetime/cc-datetime-panel.ui | 166 +++++++++++++++--------------------
 2 files changed, 69 insertions(+), 120 deletions(-)
---
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index bfc739c88..0524acb16 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -70,8 +70,6 @@ struct _CcDateTimePanel
 
   GtkWidget *map;
 
-  GList *listboxes;
-  GList *listboxes_reverse;
   GList *toplevels;
 
   TzLocation *current_location;
@@ -97,9 +95,6 @@ struct _CcDateTimePanel
   GtkWidget *day_spinbutton;
   GtkWidget *format_combobox;
   GtkWidget *h_spinbutton;
-  GtkWidget *listbox1;
-  GtkWidget *listbox2;
-  GtkWidget *listbox3;
   GtkLockButton *lock_button;
   GtkLabel  *month_label;
   GtkListBox *date_box;
@@ -159,9 +154,6 @@ cc_date_time_panel_dispose (GObject *object)
 
   g_clear_pointer (&panel->date, g_date_time_unref);
 
-  g_clear_pointer (&panel->listboxes, g_list_free);
-  g_clear_pointer (&panel->listboxes_reverse, g_list_free);
-
   G_OBJECT_CLASS (cc_date_time_panel_parent_class)->dispose (object);
 }
 
@@ -826,14 +818,6 @@ list_box_row_activated (CcDateTimePanel *self,
     }
 }
 
-static void
-setup_listbox (CcDateTimePanel *self,
-               GtkWidget       *listbox)
-{
-  self->listboxes = g_list_append (self->listboxes, listbox);
-  self->listboxes_reverse = g_list_prepend (self->listboxes_reverse, listbox);
-}
-
 static void
 time_changed_cb (CcDateTimePanel *self,
                  CcTimeEditor    *editor)
@@ -989,9 +973,6 @@ cc_date_time_panel_class_init (CcDateTimePanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, day_row);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, day_spinbutton);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, format_combobox);
-  gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, listbox1);
-  gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, listbox2);
-  gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, listbox3);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, lock_button);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, month_label);
   gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, month_popover);
@@ -1072,10 +1053,6 @@ cc_date_time_panel_init (CcDateTimePanel *self)
   setup_timezone_dialog (self);
   setup_datetime_dialog (self);
 
-  setup_listbox (self, self->listbox1);
-  setup_listbox (self, self->listbox2);
-  setup_listbox (self, self->listbox3);
-
   /* set up network time switch */
   bind_switch_to_row (self,
                       self->network_time_switch,
diff --git a/panels/datetime/cc-datetime-panel.ui b/panels/datetime/cc-datetime-panel.ui
index 30115348b..4e5c07373 100644
--- a/panels/datetime/cc-datetime-panel.ui
+++ b/panels/datetime/cc-datetime-panel.ui
@@ -299,112 +299,84 @@
   </object>
   <template class="CcDateTimePanel" parent="CcPanel">
     <child>
-      <object class="GtkScrolledWindow">
-        <property name="hscrollbar-policy">never</property>
+      <object class="AdwPreferencesPage">
         <child>
-          <object class="AdwClamp">
-            <property name="margin_top">32</property>
-            <property name="margin_bottom">32</property>
-            <property name="margin_start">12</property>
-            <property name="margin_end">12</property>
-
+          <object class="AdwPreferencesGroup">
             <child>
-              <object class="GtkBox">
-                <property name="orientation">vertical</property>
-                <property name="spacing">32</property>
+              <object class="AdwActionRow" id="auto_datetime_row">
+                <property name="title" translatable="yes">Automatic _Date &amp;amp; Time</property>
+                <property name="subtitle" translatable="yes">Requires internet access</property>
+                <property name="use_underline">True</property>
+                <property name="activatable_widget">network_time_switch</property>
                 <child>
-                  <object class="GtkListBox" id="listbox2">
-                    <property name="selection_mode">none</property>
-                    <style>
-                      <class name="boxed-list"/>
-                    </style>
-                    <child>
-                      <object class="AdwActionRow" id="auto_datetime_row">
-                        <property name="title" translatable="yes">Automatic _Date &amp;amp; Time</property>
-                        <property name="subtitle" translatable="yes">Requires internet access</property>
-                        <property name="use_underline">True</property>
-                        <property name="activatable_widget">network_time_switch</property>
-                        <child>
-                          <object class="GtkSwitch" id="network_time_switch">
-                            <property name="valign">center</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="AdwActionRow" id="datetime_button">
-                        <property name="title" translatable="yes">Date &amp;amp; _Time</property>
-                        <property name="use_underline">True</property>
-                        <property name="activatable">True</property>
-                        <signal name="activated" handler="list_box_row_activated" swapped="yes"/>
-                        <child>
-                          <object class="GtkLabel" id="datetime_label">
-                            <property name="xalign">0</property>
-                            <property name="label">20 June 2012, 6:45 AM</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
+                  <object class="GtkSwitch" id="network_time_switch">
+                    <property name="valign">center</property>
                   </object>
                 </child>
+              </object>
+            </child>
+            <child>
+              <object class="AdwActionRow" id="datetime_button">
+                <property name="title" translatable="yes">Date &amp;amp; _Time</property>
+                <property name="use_underline">True</property>
+                <property name="activatable">True</property>
+                <signal name="activated" handler="list_box_row_activated" swapped="yes"/>
                 <child>
-                  <object class="GtkListBox" id="listbox1">
-                    <property name="selection_mode">none</property>
-                    <style>
-                      <class name="boxed-list"/>
-                    </style>
-                    <child>
-                      <object class="AdwActionRow" id="auto_timezone_row">
-                        <property name="title" translatable="yes">Automatic Time _Zone</property>
-                        <property name="subtitle" translatable="yes">Requires location services enabled and 
internet access</property>
-                        <property name="use_underline">True</property>
-                        <property name="activatable_widget">auto_timezone_switch</property>
-                        <child>
-                          <object class="GtkSwitch" id="auto_timezone_switch">
-                            <property name="valign">center</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="AdwActionRow" id="timezone_button">
-                        <property name="title" translatable="yes">Time Z_one</property>
-                        <property name="use_underline">True</property>
-                        <property name="activatable">True</property>
-                        <signal name="activated" handler="list_box_row_activated" swapped="yes"/>
-                        <child>
-                          <object class="GtkLabel" id="timezone_label">
-                            <property name="ellipsize">end</property>
-                            <property name="xalign">0</property>
-                            <property name="label">GMT+1 (London, United Kingdom)</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
+                  <object class="GtkLabel" id="datetime_label">
+                    <property name="xalign">0</property>
+                    <property name="label">20 June 2012, 6:45 AM</property>
                   </object>
                 </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="AdwPreferencesGroup">
+            <child>
+              <object class="AdwActionRow" id="auto_timezone_row">
+                <property name="title" translatable="yes">Automatic Time _Zone</property>
+                <property name="subtitle" translatable="yes">Requires location services enabled and internet 
access</property>
+                <property name="use_underline">True</property>
+                <property name="activatable_widget">auto_timezone_switch</property>
                 <child>
-                  <object class="GtkListBox" id="listbox3">
-                    <property name="selection_mode">none</property>
-                    <style>
-                      <class name="boxed-list"/>
-                    </style>
-                    <child>
-                      <object class="AdwActionRow" id="timeformat_row">
-                        <property name="title" translatable="yes">Time _Format</property>
-                        <property name="use_underline">True</property>
-                        <child>
-                          <object class="GtkComboBoxText" id="format_combobox">
-                            <property name="valign">center</property>
-                            <signal name="notify::active-id" handler="change_clock_settings" 
object="CcDateTimePanel" swapped="no"/>
-                            <items>
-                              <item id="24h" translatable="yes">24-hour</item>
-                              <item id="12h" translatable="yes">AM / PM</item>
-                            </items>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
+                  <object class="GtkSwitch" id="auto_timezone_switch">
+                    <property name="valign">center</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="AdwActionRow" id="timezone_button">
+                <property name="title" translatable="yes">Time Z_one</property>
+                <property name="use_underline">True</property>
+                <property name="activatable">True</property>
+                <signal name="activated" handler="list_box_row_activated" swapped="yes"/>
+                <child>
+                  <object class="GtkLabel" id="timezone_label">
+                    <property name="ellipsize">end</property>
+                    <property name="xalign">0</property>
+                    <property name="label">GMT+1 (London, United Kingdom)</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="AdwPreferencesGroup">
+            <child>
+              <object class="AdwActionRow" id="timeformat_row">
+                <property name="title" translatable="yes">Time _Format</property>
+                <property name="use_underline">True</property>
+                <child>
+                  <object class="GtkComboBoxText" id="format_combobox">
+                    <property name="valign">center</property>
+                    <signal name="notify::active-id" handler="change_clock_settings" 
object="CcDateTimePanel" swapped="no"/>
+                    <items>
+                      <item id="24h" translatable="yes">24-hour</item>
+                      <item id="12h" translatable="yes">AM / PM</item>
+                    </items>
                   </object>
                 </child>
               </object>


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