[baobab/wip/cdavis/hdy-restyle] preferences: Use HdyPreferencesWindow



commit 498f02033025e99a1700b4bd0e236a98543acf3e
Author: Christopher Davis <brainblasted disroot org>
Date:   Fri Feb 5 15:20:41 2021 -0800

    preferences: Use HdyPreferencesWindow
    
    Gives us a nice styled preferences window
    to match other GNOME apps.

 data/ui/baobab-preferences-dialog.ui | 40 +++++++++---------------------------
 src/baobab-preferences-dialog.vala   | 18 ++--------------
 2 files changed, 12 insertions(+), 46 deletions(-)
---
diff --git a/data/ui/baobab-preferences-dialog.ui b/data/ui/baobab-preferences-dialog.ui
index 582e9d0..4e683a9 100644
--- a/data/ui/baobab-preferences-dialog.ui
+++ b/data/ui/baobab-preferences-dialog.ui
@@ -2,50 +2,30 @@
 <!-- Generated with glade 3.22.0 -->
 <interface>
   <requires lib="gtk+" version="3.22"/>
-  <template class="BaobabPreferencesDialog" parent="GtkDialog">
+  <template class="BaobabPreferencesDialog" parent="HdyPreferencesWindow">
     <property name="can_focus">False</property>
     <property name="type_hint">dialog</property>
     <property name="title" translatable="yes">Preferences</property>
-    <child internal-child="vbox">
-      <object class="GtkBox">
+    <property name="search_enabled">False</property>
+    <child>
+      <object class="HdyPreferencesPage">
+        <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="margin">12</property>
         <child>
-          <object class="GtkLabel" id="locations_label">
+          <object class="HdyPreferencesGroup">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="halign">start</property>
-            <property name="margin-bottom">12</property>
-            <property name="use_markup">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="shadow_type">in</property>
-            <property name="hscrollbar-policy">never</property>
-            <property name="width_request">500</property>
-            <property name="height_request">300</property>
+            <property name="title" translatable="yes">Locations to Ignore</property>
             <child>
               <object class="GtkListBox" id="excluded_list_box">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="selection_mode">none</property>
+                <style>
+                  <class name="content"/>
+                </style>
               </object>
             </child>
           </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
         </child>
       </object>
     </child>
diff --git a/src/baobab-preferences-dialog.vala b/src/baobab-preferences-dialog.vala
index 27cbf1f..91327f0 100644
--- a/src/baobab-preferences-dialog.vala
+++ b/src/baobab-preferences-dialog.vala
@@ -39,21 +39,15 @@ namespace Baobab {
     }
 
     [GtkTemplate (ui = "/org/gnome/baobab/ui/baobab-preferences-dialog.ui")]
-    public class PreferencesDialog : Gtk.Dialog {
+    public class PreferencesDialog : Hdy.PreferencesWindow {
         [GtkChild]
         private Gtk.ListBox excluded_list_box;
-        [GtkChild]
-        private Gtk.Label locations_label;
 
         private Settings prefs_settings;
 
         construct {
-            locations_label.label = "<b>%s</b>".printf (_("Locations to ignore"));
-
             prefs_settings = new Settings ("org.gnome.baobab.preferences");
 
-            excluded_list_box.set_header_func (update_header);
-
             excluded_list_box.row_activated.connect (() => {
                 // The only activatable row is "Add location"
                 var file_chooser = new Gtk.FileChooserDialog (_("Select Location to Ignore"), this,
@@ -94,7 +88,7 @@ namespace Baobab {
                 });
             }
 
-            var label = new Gtk.Label (_("Add location…"));
+            var label = new Gtk.Label (_("Add Location…"));
             label.margin = 12;
             label.show ();
             excluded_list_box.insert (label, -1);
@@ -117,13 +111,5 @@ namespace Baobab {
             }
             prefs_settings.set_strv ("excluded-uris", uris);
         }
-
-        void update_header (Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row) {
-            if (before_row != null && row.get_header () == null) {
-                row.set_header (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
-            } else {
-                row.set_header (null);
-            }
-        }
     }
 }


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