[dconf-editor] Introduce WindowSize.



commit d3f17ccbbce1064a26b5580f33e7917ada6bdddb
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Nov 24 11:45:20 2018 +0100

    Introduce WindowSize.

 editor/adaptative-pathbar.vala     |  14 ++-
 editor/browser-headerbar.vala      |  57 +++++----
 editor/browser-stack.vala          |   6 +-
 editor/browser-view.vala           |  25 +++-
 editor/dconf-window.vala           | 232 +++++++++++++++++++++++--------------
 editor/key-list-box-row.vala       |  16 ++-
 editor/modifications-revealer.vala |  12 +-
 editor/pathentry.vala              |  10 +-
 editor/pathwidget.vala             |  28 +++--
 editor/registry-list.vala          |  10 +-
 editor/source-manager.vala         |   4 +-
 11 files changed, 264 insertions(+), 150 deletions(-)
---
diff --git a/editor/adaptative-pathbar.vala b/editor/adaptative-pathbar.vala
index b352df2..7cd1860 100644
--- a/editor/adaptative-pathbar.vala
+++ b/editor/adaptative-pathbar.vala
@@ -23,11 +23,15 @@ private class AdaptativePathbar : Stack, Pathbar, AdaptativeWidget
     [GtkChild] private LargePathbar large_pathbar;
     [GtkChild] private ShortPathbar short_pathbar;
 
-    private bool extra_small_window = false;
-    private void set_extra_small_window_state (bool new_value)
+    private bool thin_window = false;
+    private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        extra_small_window = new_value;
-        if (new_value)
+        bool _thin_window = AdaptativeWidget.WindowSize.is_thin (new_size);
+        if (_thin_window == thin_window)
+            return;
+        thin_window = _thin_window;
+
+        if (_thin_window)
             set_visible_child (short_pathbar);
         else
             set_visible_child (large_pathbar);
@@ -55,7 +59,7 @@ private class AdaptativePathbar : Stack, Pathbar, AdaptativeWidget
 
     internal void toggle_menu ()
     {
-        if (extra_small_window)
+        if (thin_window)
             short_pathbar.toggle_menu ();
         else
             large_pathbar.toggle_menu ();
diff --git a/editor/browser-headerbar.vala b/editor/browser-headerbar.vala
index bb7dd7e..0682461 100644
--- a/editor/browser-headerbar.vala
+++ b/editor/browser-headerbar.vala
@@ -35,28 +35,36 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
     internal signal void search_stopped ();
     internal signal void update_bookmarks_icons (Variant bookmarks_variant);
 
-    private bool extra_small_window = false;
-    private void set_extra_small_window_state (bool new_value)
+    private bool phone_window = false;
+    private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        extra_small_window = new_value;
-
-        bookmarks_button.active = false;
-        if (new_value)
+        bool _phone_window = AdaptativeWidget.WindowSize.is_phone (new_size);
+        if (phone_window != _phone_window)
         {
-            bookmarks_button.sensitive = false;
-            bookmarks_revealer.set_reveal_child (false);
-        }
-        else
-        {
-            bookmarks_button.sensitive = true;
-            bookmarks_revealer.set_reveal_child (true);
-            hide_in_window_bookmarks ();
-            hide_in_window_about ();
+            phone_window = _phone_window;
+            if (phone_window)
+            {
+                bookmarks_button.active = false;
+                bookmarks_button.sensitive = false;
+                bookmarks_revealer.set_reveal_child (false);
+            }
+            else
+            {
+                bookmarks_button.sensitive = true;
+                bookmarks_revealer.set_reveal_child (true);
+                if (in_window_bookmarks)
+                    hide_in_window_bookmarks ();
+                else if (in_window_modifications)
+                    hide_in_window_modifications ();
+                else if (in_window_about)
+                    hide_in_window_about ();
+            }
         }
+
         update_hamburger_menu (delay_mode);
         update_modifications_button ();
 
-        path_widget.set_extra_small_window_state (new_value);
+        path_widget.set_window_size (new_size);
     }
 
     internal bool search_mode_enabled   { get { return path_widget.search_mode_enabled; }}
@@ -181,12 +189,13 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
     }
 
     internal void hide_in_window_about ()
+        requires (in_window_about == true)
     {
         hide_about_button.hide ();
         bookmarks_stack.hexpand = false;    // hack 2/7
         title_stack.set_visible_child (path_widget);
         in_window_about = false;
-        if (extra_small_window)
+        if (phone_window)
             modifications_separator.show ();
         info_button.show ();
     }
@@ -222,7 +231,7 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
 
     private void update_modifications_button ()
     {
-        if (extra_small_window)
+        if (phone_window)
         {
             set_show_close_button (false);
             if (in_window_modifications)
@@ -279,10 +288,11 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
     }
 
     internal void hide_in_window_modifications ()
+        requires (in_window_modifications == true)
     {
         hide_modifications_button.hide ();
         modifications_actions_button.hide ();
-        if (extra_small_window)
+        if (phone_window)
         {
             show_modifications_button.show ();
             modifications_separator.show ();
@@ -331,6 +341,7 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
     }
 
     internal void hide_in_window_bookmarks ()
+        requires (in_window_bookmarks == true)
     {
         hide_in_window_bookmarks_button.hide ();
         bookmarks_actions_separator.hide ();
@@ -418,13 +429,13 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
         }
         else if (current_type != ViewType.SEARCH) */
 
-        if (extra_small_window)
+        if (phone_window)
             append_bookmark_section (current_type, current_path, BookmarksList.get_bookmark_name 
(current_path, current_type) in get_bookmarks (), in_window_bookmarks, ref menu);
 
         if (!in_window_bookmarks)
             append_or_not_delay_mode_section (delay_mode, current_type == ViewType.FOLDER, current_path, ref 
menu);
 
-        append_app_actions_section (night_time, dark_theme, automatic_night_mode, extra_small_window, ref 
menu);
+        append_app_actions_section (night_time, dark_theme, automatic_night_mode, phone_window, ref menu);
 
         menu.freeze ();
         info_button.set_menu_model ((MenuModel) menu);
@@ -467,11 +478,11 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
         menu.append_section (null, section);
     }
 
-    private static void append_app_actions_section (bool night_time, bool dark_theme, bool auto_night, bool 
extra_small_window, ref GLib.Menu menu)
+    private static void append_app_actions_section (bool night_time, bool dark_theme, bool auto_night, bool 
phone_window, ref GLib.Menu menu)
     {
         GLib.Menu section = new GLib.Menu ();
         append_or_not_night_mode_entry (night_time, dark_theme, auto_night, ref section);
-        if (!extra_small_window)    // TODO else...
+        if (!phone_window)    // TODO else...
             section.append (_("Keyboard Shortcuts"), "win.show-help-overlay");
         section.append (_("About Dconf Editor"), "ui.about");
         section.freeze ();
diff --git a/editor/browser-stack.vala b/editor/browser-stack.vala
index 868412c..6483223 100644
--- a/editor/browser-stack.vala
+++ b/editor/browser-stack.vala
@@ -36,10 +36,10 @@ private class BrowserStack : Grid, AdaptativeWidget
         }
     }
 
-    private void set_extra_small_window_state (bool new_value)
+    private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        folder_view.set_extra_small_window_state (new_value);
-        search_view.set_extra_small_window_state (new_value);
+        folder_view.set_window_size (new_size);
+        search_view.set_window_size (new_size);
     }
 
     internal ModificationsHandler modifications_handler
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 64fc7e7..0a064de 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -61,11 +61,23 @@ private class BrowserView : Stack, AdaptativeWidget
 
     internal bool small_keys_list_rows { set { current_child.small_keys_list_rows = value; }}
 
-    private void set_extra_small_window_state (bool new_value)
+    private bool phone_window = false;
+    private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        current_child.set_extra_small_window_state (new_value);
-        if (!new_value)
-            hide_in_window_bookmarks ();
+        current_child.set_window_size (new_size);
+        bool _phone_window = AdaptativeWidget.WindowSize.is_phone (new_size);
+        if (phone_window == _phone_window)
+            return;
+        if (phone_window)
+        {
+            if (in_window_bookmarks)
+                hide_in_window_bookmarks ();
+            else if (in_window_modifications)
+                hide_in_window_modifications ();
+            else if (in_window_about)
+                hide_in_window_about ();
+        }
+        phone_window = _phone_window;
     }
 
     private ModificationsHandler _modifications_handler;
@@ -220,6 +232,7 @@ private class BrowserView : Stack, AdaptativeWidget
     }
 
     internal void hide_in_window_about ()
+        requires (in_window_about == true)
     {
         in_window_about = false;
         set_visible_child (current_child_grid);
@@ -245,6 +258,7 @@ private class BrowserView : Stack, AdaptativeWidget
     }
 
     internal void hide_in_window_modifications ()
+        requires (in_window_modifications == true)
     {
         in_window_modifications = false;
         set_visible_child (current_child_grid);
@@ -255,7 +269,7 @@ private class BrowserView : Stack, AdaptativeWidget
         GLib.ListStore modifications_liststore = modifications_handler.get_delayed_settings ();
         modifications_list.bind_model (modifications_liststore, delayed_setting_row_create);
 
-        if (modifications_handler.mode == ModificationsMode.NONE)
+        if (in_window_modifications && modifications_handler.mode == ModificationsMode.NONE)
             hide_in_window_modifications ();
     }
     private Widget delayed_setting_row_create (Object object)
@@ -352,6 +366,7 @@ private class BrowserView : Stack, AdaptativeWidget
     }
 
     internal void hide_in_window_bookmarks ()
+        requires (in_window_bookmarks == true)
     {
         if (in_window_bookmarks_edit_mode)
             leave_bookmarks_edit_mode ();
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index dee591d..b9fb8d3 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -86,8 +86,44 @@ internal enum ViewType {
 }
 
 private interface AdaptativeWidget
-{
-    internal abstract void set_extra_small_window_state (bool new_value);
+{ /*
+     ┏━━━━━━━┳━━━━━━━┳━━━━━──╴
+     ┃       ┃       ┃
+     ┃ phone ┃ phone ┃ extra
+     ┃ vert. ┃ hztl. ┃ flat
+     ┠╌╌╌╌╌╌╌╊━━━━━━━┻━━━━╾──╴
+     ┃       ┃
+     ┃       ┃
+     ┣━━━━━━━┫     usual
+     ┃ extra ┃     size
+     ╿ thin  │
+     ╵       ╵             */
+
+    internal enum WindowSize {
+        START_SIZE,
+        USUAL_SIZE,
+        PHONE_VERT,
+        PHONE_HZTL,
+        EXTRA_THIN,
+        EXTRA_FLAT;
+
+        internal static inline bool is_phone (WindowSize window_size)
+        {
+            return (window_size != USUAL_SIZE) && (window_size != EXTRA_FLAT);
+        }
+
+        internal static inline bool is_thin (WindowSize window_size)
+        {
+            return (window_size == PHONE_VERT) || (window_size == EXTRA_THIN);
+        }
+
+        internal static inline bool is_fun (WindowSize window_size)
+        {
+            return (window_size == PHONE_HZTL) || (window_size == EXTRA_FLAT);
+        }
+    }
+
+    internal abstract void set_window_size (WindowSize new_size);
 }
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/dconf-editor.ui")]
@@ -148,7 +184,7 @@ private class DConfWindow : ApplicationWindow
         revealer.modifications_handler = modifications_handler;
         browser_view.modifications_handler = modifications_handler;
         modifications_handler.delayed_changes_changed.connect (() => {
-                if (!extra_small_window)
+                if (!AdaptativeWidget.WindowSize.is_phone (window_size))
                     return;
 
                 uint total_changes_count = modifications_handler.dconf_changes_count + 
modifications_handler.gsettings_changes_count;
@@ -442,69 +478,91 @@ private class DConfWindow : ApplicationWindow
         return false;
     }
 
-    private bool extra_small_window = false;
+    private AdaptativeWidget.WindowSize window_size = AdaptativeWidget.WindowSize.START_SIZE;
+    private void set_window_size (AdaptativeWidget.WindowSize new_window_size)
+        requires (new_window_size != AdaptativeWidget.WindowSize.START_SIZE)
+    {
+        if (window_size == new_window_size)
+            return;
+        window_size = new_window_size;
+        headerbar.set_window_size (new_window_size);
+        browser_view.set_window_size (new_window_size);
+        revealer.set_window_size (new_window_size);
+    }
+
+    private bool has_extra_small_window_class = false;
+    private bool has_small_window_class = false;
+    private bool has_large_window_class = false;
+    private void set_style_classes (bool extra_small_window, bool small_window, bool large_window)
+    {
+        // remove first
+        if (has_extra_small_window_class && !extra_small_window)
+            set_style_class ("extra-small-window", extra_small_window, ref has_extra_small_window_class);
+        if (has_small_window_class && !small_window)
+            set_style_class ("small-window", small_window, ref has_small_window_class);
+
+        if (large_window != has_large_window_class)
+            set_style_class ("large-window", large_window, ref has_large_window_class);
+        if (small_window != has_small_window_class)
+            set_style_class ("small-window", small_window, ref has_small_window_class);
+        if (extra_small_window != has_extra_small_window_class)
+            set_style_class ("extra-small-window", extra_small_window, ref has_extra_small_window_class);
+    }
+    private inline void set_style_class (string class_name, bool new_state, ref bool old_state)
+    {
+        old_state = new_state;
+        if (new_state)
+            context.add_class (class_name);
+        else
+            context.remove_class (class_name);
+    }
+
     [GtkCallback]
     private void on_size_allocate (Allocation allocation)
     {
         /* responsive design */
 
-        if (allocation.width > MAX_ROW_WIDTH + 42)
+        int height = allocation.height;
+        int width = allocation.width;
+        bool is_thin_window = width < 787;
+
+        if (width < 590)
         {
-            if (extra_small_window)
-            {
-                extra_small_window = false;
-                context.remove_class ("extra-small-window");
-                headerbar.set_extra_small_window_state (false);
-                browser_view.set_extra_small_window_state (false);
-                revealer.set_extra_small_window_state (false);
-            }
-            context.remove_class ("small-window");
-            context.add_class ("large-window");
+            if (height < 787)   set_window_size (AdaptativeWidget.WindowSize.PHONE_VERT);
+            else                set_window_size (AdaptativeWidget.WindowSize.EXTRA_THIN);
+        }
+        else if (height < 400)
+        {
+            if (is_thin_window) set_window_size (AdaptativeWidget.WindowSize.PHONE_HZTL);
+            else                set_window_size (AdaptativeWidget.WindowSize.EXTRA_FLAT);
+        }
+        else                    set_window_size (AdaptativeWidget.WindowSize.USUAL_SIZE);
+
+        if (width > MAX_ROW_WIDTH + 42)
+        {
+            set_style_classes (false, false, true);
+
             notification_revealer.hexpand = false;
             notification_revealer.halign = Align.CENTER;
         }
-        else if (allocation.width < 590)
+        else if (width < 590)
         {
-            context.remove_class ("large-window");
-            context.add_class ("small-window");
-            if (!extra_small_window)
-            {
-                extra_small_window = true;
-                context.add_class ("extra-small-window");
-                headerbar.set_extra_small_window_state (true);
-                browser_view.set_extra_small_window_state (true);
-                revealer.set_extra_small_window_state (true);
-            }
+            set_style_classes (true, true, false);
+
             notification_revealer.hexpand = true;
             notification_revealer.halign = Align.FILL;
         }
-        else if (allocation.width < 787)
+        else if (is_thin_window)
         {
-            context.remove_class ("large-window");
-            if (extra_small_window)
-            {
-                extra_small_window = false;
-                context.remove_class ("extra-small-window");
-                headerbar.set_extra_small_window_state (false);
-                browser_view.set_extra_small_window_state (false);
-                revealer.set_extra_small_window_state (false);
-            }
-            context.add_class ("small-window");
+            set_style_classes (false, true, false);
+
             notification_revealer.hexpand = true;
             notification_revealer.halign = Align.FILL;
         }
         else
         {
-            context.remove_class ("large-window");
-            context.remove_class ("small-window");
-            if (extra_small_window)
-            {
-                extra_small_window = false;
-                context.remove_class ("extra-small-window");
-                headerbar.set_extra_small_window_state (false);
-                browser_view.set_extra_small_window_state (false);
-                revealer.set_extra_small_window_state (false);
-            }
+            set_style_classes (false, false, false);
+
             notification_revealer.hexpand = false;
             notification_revealer.halign = Align.CENTER;
         }
@@ -658,8 +716,9 @@ private class DConfWindow : ApplicationWindow
     private void open_folder (SimpleAction action, Variant? path_variant)
         requires (path_variant != null)
     {
-        hide_in_window_bookmarks ();
         headerbar.close_popovers ();
+        if (browser_view.in_window_bookmarks)
+            hide_in_window_bookmarks ();
 
         string full_name = ((!) path_variant).get_string ();
 
@@ -669,11 +728,12 @@ private class DConfWindow : ApplicationWindow
     private void open_object (SimpleAction action, Variant? path_variant)
         requires (path_variant != null)
     {
-        hide_in_window_bookmarks ();
         headerbar.close_popovers ();
         revealer.hide_modifications_list ();
-        hide_in_window_modifications ();
-        hide_in_window_about ();
+        if (browser_view.in_window_bookmarks)
+            hide_in_window_bookmarks ();
+        else if (browser_view.in_window_modifications)
+            hide_in_window_modifications ();
 
         string full_name;
         uint16 context_id;
@@ -695,8 +755,9 @@ private class DConfWindow : ApplicationWindow
     private void open_search (SimpleAction action, Variant? search_variant)
         requires (search_variant != null)
     {
-        hide_in_window_bookmarks ();
         headerbar.close_popovers ();
+        if (browser_view.in_window_bookmarks)
+            hide_in_window_bookmarks ();
 
         string search = ((!) search_variant).get_string ();
 
@@ -706,7 +767,8 @@ private class DConfWindow : ApplicationWindow
     private void open_parent (SimpleAction action, Variant? path_variant)
         requires (path_variant != null)
     {
-        hide_in_window_bookmarks ();
+        if (browser_view.in_window_bookmarks)
+            hide_in_window_bookmarks ();
 
         string full_name = ((!) path_variant).get_string ();
         request_folder (ModelUtils.get_parent_path (full_name), full_name);
@@ -715,11 +777,12 @@ private class DConfWindow : ApplicationWindow
     private void open_path (SimpleAction action, Variant? path_variant)
         requires (path_variant != null)
     {
-        hide_in_window_bookmarks ();
         headerbar.close_popovers ();
         revealer.hide_modifications_list ();
-        hide_in_window_modifications ();
-        hide_in_window_about ();
+        if (browser_view.in_window_bookmarks)
+            hide_in_window_bookmarks ();
+        else if (browser_view.in_window_modifications)
+            hide_in_window_modifications ();
 
         string full_name;
         uint16 context_id;
@@ -825,7 +888,7 @@ private class DConfWindow : ApplicationWindow
     }
     private void update_bookmark_icon (string bookmark, BookmarkIcon icon)
     {
-        if (extra_small_window)
+        if (AdaptativeWidget.WindowSize.is_phone (window_size))
             browser_view.update_bookmark_icon (bookmark, icon);
         else
             headerbar.update_bookmark_icon (bookmark, icon);
@@ -840,6 +903,7 @@ private class DConfWindow : ApplicationWindow
     }
 
     private void hide_in_window_bookmarks (/* SimpleAction action, Variant? path_variant */)
+        requires (browser_view.in_window_bookmarks == true)
     {
         if (browser_view.in_window_bookmarks_edit_mode)
             leave_edit_mode ();     // TODO place after
@@ -854,12 +918,14 @@ private class DConfWindow : ApplicationWindow
     }
 
     private void hide_in_window_modifications (/* SimpleAction action, Variant? path_variant */)
+        requires (browser_view.in_window_modifications == true)
     {
         headerbar.hide_in_window_modifications ();
         browser_view.hide_in_window_modifications ();
     }
 
     private void hide_in_window_about (/* SimpleAction action, Variant? path_variant */)
+        requires (browser_view.in_window_about == true)
     {
         headerbar.hide_in_window_about ();
         browser_view.hide_in_window_about ();
@@ -891,14 +957,16 @@ private class DConfWindow : ApplicationWindow
 
     private void apply_delayed_settings (/* SimpleAction action, Variant? path_variant */)
     {
-        modifications_handler.apply_delayed_settings ();
-        if (extra_small_window)
+        if (browser_view.in_window_modifications)
             hide_in_window_modifications ();
+        modifications_handler.apply_delayed_settings ();
         invalidate_popovers_with_ui_reload ();
     }
 
     private void dismiss_delayed_settings (/* SimpleAction action, Variant? path_variant */)
     {
+        if (browser_view.in_window_modifications)
+            hide_in_window_modifications ();
         modifications_handler.dismiss_delayed_settings ();
         invalidate_popovers_with_ui_reload ();
     }
@@ -925,18 +993,8 @@ private class DConfWindow : ApplicationWindow
 
     private void about_cb ()    // register as "win.about"?
     {
-        if (extra_small_window)
-        {
-            if (browser_view.in_window_about)
-                hide_in_window_about ();
-            else
-            {
-                headerbar.show_in_window_about ();
-                browser_view.show_in_window_about ();
-            }
-        }
-        else    // TODO hide the dialog if visible
-        {
+        if (!AdaptativeWidget.WindowSize.is_phone (window_size))
+        {   // TODO hide the dialog if visible
             string [] authors = AboutDialogInfos.authors;
             Gtk.show_about_dialog (this,
                                    "program-name",          AboutDialogInfos.program_name,
@@ -952,6 +1010,15 @@ private class DConfWindow : ApplicationWindow
                                    "website-label",         AboutDialogInfos.website_label,
                                    null);
         }
+        else if (browser_view.in_window_about)
+            hide_in_window_about ();
+        else
+            show_in_window_about ();
+    }
+    private inline void show_in_window_about ()
+    {
+        headerbar.show_in_window_about ();
+        browser_view.show_in_window_about ();
     }
 
     /*\
@@ -1134,7 +1201,7 @@ private class DConfWindow : ApplicationWindow
     private void toggle_bookmark                        (/* SimpleAction action, Variant? variant */)
     {
         browser_view.discard_row_popover ();
-        if (!extra_small_window)
+        if (!AdaptativeWidget.WindowSize.is_phone (window_size))
             headerbar.click_bookmarks_button ();
         else if (browser_view.in_window_bookmarks)
             hide_in_window_bookmarks ();
@@ -1246,18 +1313,15 @@ private class DConfWindow : ApplicationWindow
 
     private void modifications_list                     (/* SimpleAction action, Variant? variant */)
     {
-        if (modifications_handler.get_current_delay_mode ())
-        {
-            if (extra_small_window)
-            {
-                if (browser_view.in_window_modifications)
-                    hide_in_window_modifications ();
-                else
-                    show_in_window_modifications ();
-            }
-            else
-                revealer.toggle_modifications_list ();
-        }
+        if (!modifications_handler.get_current_delay_mode ())
+            return;
+
+        if (!AdaptativeWidget.WindowSize.is_phone (window_size))
+            revealer.toggle_modifications_list ();
+        else if (browser_view.in_window_modifications)
+            hide_in_window_modifications ();
+        else
+            show_in_window_modifications ();
     }
 
     private void edit_path_end                          (/* SimpleAction action, Variant? variant */)
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index b210949..1ff0b32 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -174,7 +174,7 @@ private class SearchListBoxRow : ClickableListBoxRow
 }
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/key-list-box-row.ui")]
-private class KeyListBoxRow : ClickableListBoxRow
+private class KeyListBoxRow : ClickableListBoxRow, AdaptativeWidget
 {
     [GtkChild] private Grid key_name_and_value_grid;
     [GtkChild] private Label key_name_label;
@@ -219,11 +219,15 @@ private class KeyListBoxRow : ClickableListBoxRow
         }
     }
 
-    private bool extra_small_window = false;
-    internal void set_extra_small_window_state (bool new_value)
+    private bool thin_window = false;
+    internal void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        extra_small_window = new_value;
-        if (new_value)
+        bool _thin_window = AdaptativeWidget.WindowSize.is_thin (new_size);
+        if (thin_window == _thin_window)
+            return;
+        thin_window = _thin_window;
+
+        if (thin_window)
         {
             if (boolean_switch != null)
                 ((!) boolean_switch).hide ();
@@ -386,7 +390,7 @@ private class KeyListBoxRow : ClickableListBoxRow
     private void hide_or_show_switch ()
         requires (boolean_switch != null)
     {
-        if (extra_small_window)
+        if (thin_window)
         {
             key_value_label.hide ();
             ((!) boolean_switch).hide ();
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index 96adc2c..9265e23 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -31,10 +31,14 @@ private class ModificationsRevealer : Revealer, AdaptativeWidget
         }
     }
 
-    private bool extra_small_window = false;
-    private void set_extra_small_window_state (bool new_value)
+    private bool phone_window = false;
+    private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        extra_small_window = new_value;
+        bool _phone_window = AdaptativeWidget.WindowSize.is_phone (new_size);
+        if (phone_window == _phone_window)
+            return;
+        phone_window = _phone_window;
+
         update ();
     }
 
@@ -244,7 +248,7 @@ private class ModificationsRevealer : Revealer, AdaptativeWidget
 
     private void update ()
     {
-        if (extra_small_window)
+        if (phone_window)
         {
             set_reveal_child (false);
             return;
diff --git a/editor/pathentry.vala b/editor/pathentry.vala
index 5ccfbe4..23ffcb1 100644
--- a/editor/pathentry.vala
+++ b/editor/pathentry.vala
@@ -31,9 +31,15 @@ private class PathEntry : Box, AdaptativeWidget
     internal bool entry_has_focus { get { return search_entry.has_focus; }}
 
     private ulong can_reload_handler = 0;
-    private void set_extra_small_window_state (bool new_value)
+    private bool thin_window = false;
+    private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        if (new_value)
+        bool _thin_window = AdaptativeWidget.WindowSize.is_thin (new_size);
+        if (_thin_window == thin_window)
+            return;
+        thin_window = _thin_window;
+
+        if (thin_window)
         {
             search_entry.set_icon_from_pixbuf (EntryIconPosition.PRIMARY, null);
 
diff --git a/editor/pathwidget.vala b/editor/pathwidget.vala
index 3f1b63e..b6ede44 100644
--- a/editor/pathwidget.vala
+++ b/editor/pathwidget.vala
@@ -37,22 +37,28 @@ private class PathWidget : Box, AdaptativeWidget
         search_button.icon = search_icon;
     }
 
-    private void set_extra_small_window_state (bool new_value)
+    private bool thin_window;
+    private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        pathbar.set_extra_small_window_state (new_value);
+        pathbar.set_window_size (new_size);
 
-        if (new_value)
+        bool _thin_window = AdaptativeWidget.WindowSize.is_thin (new_size);
+        if (thin_window != _thin_window)
         {
-            search_toggle.hide ();
-            search_button.show ();
-        }
-        else
-        {
-            search_button.hide ();
-            search_toggle.show ();
+            thin_window = _thin_window;
+            if (thin_window)
+            {
+                search_toggle.hide ();
+                search_button.show ();
+            }
+            else
+            {
+                search_button.hide ();
+                search_toggle.show ();
+            }
         }
 
-        searchentry.set_extra_small_window_state (new_value);
+        searchentry.set_window_size (new_size);
     }
 
     /*\
diff --git a/editor/registry-list.vala b/editor/registry-list.vala
index a0d205d..f8dcb74 100644
--- a/editor/registry-list.vala
+++ b/editor/registry-list.vala
@@ -54,14 +54,14 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
         }
     }
 
-    private bool extra_small_window = false;
-    private void set_extra_small_window_state (bool new_value)
+    private AdaptativeWidget.WindowSize window_size = AdaptativeWidget.WindowSize.START_SIZE;
+    private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        extra_small_window = new_value;
+        window_size = new_size;
         key_list_box.@foreach ((row) => {
                 Widget? row_child = ((ListBoxRow) row).get_child ();
                 if (row_child != null && (!) row_child is KeyListBoxRow)
-                    ((KeyListBoxRow) (!) row_child).set_extra_small_window_state (new_value);
+                    ((KeyListBoxRow) (!) row_child).set_window_size (new_size);
             });
     }
 
@@ -391,7 +391,7 @@ private abstract class RegistryList : Grid, BrowsableView, AdaptativeWidget
 
             KeyListBoxRow key_row = create_key_list_box_row (full_name, context_id, properties, 
modifications_handler.get_current_delay_mode (), search_mode_non_local_result);
             key_row.small_keys_list_rows = _small_keys_list_rows;
-            key_row.set_extra_small_window_state (extra_small_window);
+            key_row.set_window_size (window_size);
 
             ulong delayed_modifications_changed_handler = 
modifications_handler.delayed_changes_changed.connect ((_modifications_handler) => set_delayed_icon 
(_modifications_handler, key_row));
             set_delayed_icon (modifications_handler, key_row);
diff --git a/editor/source-manager.vala b/editor/source-manager.vala
index a37e038..273f6a4 100644
--- a/editor/source-manager.vala
+++ b/editor/source-manager.vala
@@ -89,7 +89,7 @@ private class SourceManager : Object
         // TODO i18n but big warning with plurals; and suggest to report a bug?
         if (empty_schemas_needing_warning.length == 1)
         {
-            warning ("Schema with id “" + empty_schemas_needing_warning [0] + "” contains neither keys nor 
children.");
+            info ("Schema with id “" + empty_schemas_needing_warning [0] + "” contains neither keys nor 
children.");
             previous_empty_schemas = empty_schemas;
         }
         else if (empty_schemas_needing_warning.length > 1)
@@ -99,7 +99,7 @@ private class SourceManager : Object
                 warning_string += @"  $warning_id\n";
             warning_string += "contain neither keys nor children.";
 
-            warning (warning_string);
+            info (warning_string);
             previous_empty_schemas = empty_schemas;
         }
 


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