[dconf-editor] Make ModificationsRevealer work on small screen.



commit e1b15a3fff6e1abdee24afc3e4b66e24f2f66abf
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Nov 21 22:22:53 2018 +0100

    Make ModificationsRevealer work on small screen.

 editor/browser-headerbar.ui        | 124 ++++++++++++++++++++++++++++++++++---
 editor/browser-headerbar.vala      | 119 +++++++++++++++++++++++++++++++++--
 editor/browser-infobar.vala        |   2 +-
 editor/browser-view.ui             |  10 ++-
 editor/browser-view.vala           |  95 +++++++++++++++++++++++++++-
 editor/dconf-window.vala           | 102 +++++++++++++++++++++++++-----
 editor/modifications-revealer.vala |  15 ++++-
 7 files changed, 438 insertions(+), 29 deletions(-)
---
diff --git a/editor/browser-headerbar.ui b/editor/browser-headerbar.ui
index 5f3d829..29d8370 100644
--- a/editor/browser-headerbar.ui
+++ b/editor/browser-headerbar.ui
@@ -25,6 +25,55 @@
         <property name="visible">False</property>
       </object>
     </child>
+    <child>
+      <object class="GtkButton" id="hide_modifications_button">
+        <property name="visible">False</property>
+        <property name="action-name">ui.hide-in-window-modifications</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">go-previous-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <!-- child>
+      <object class="GtkButton" id="apply_modifications_button">
+        <property name="visible">False</property>
+        <property name="action-name">ui.apply-modifications</property>
+        <style>
+          <class name="image-button"/>
+          <class name="suggested-action"/>
+        </style>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">object-select-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+    </child -->
+    <!-- child>
+      <object class="GtkButton" id="dismiss_modification_button">
+        <property name="visible">False</property>
+        <property name="action-name">ui.dismiss-modifications</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">list-remove-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+    </child -->
     <child type="title">
       <object class="GtkBox">
         <property name="visible">True</property>
@@ -33,7 +82,7 @@
           <class name="centerwidget"/>
         </style>
         <child>
-          <object class="GtkStack" id="bookmarks_stack">
+          <object class="GtkStack" id="title_stack">
             <property name="visible">True</property>
             <property name="hhomogeneous">False</property>
             <child>
@@ -45,17 +94,29 @@
               </object>
             </child>
             <child>
-              <object class="GtkLabel" id="bookmarks_label">
+              <object class="GtkStack" id="bookmarks_stack">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Bookmarks</property>
+                <property name="hhomogeneous">False</property>
+                <child>
+                  <object class="GtkLabel" id="bookmarks_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Bookmarks</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="BookmarksController" id="bookmarks_controller">
+                    <property name="visible">True</property>
+                    <property name="hexpand">False</property>
+                    <property name="show-rows-size-button">False</property>
+                    <property name="controller-action-prefix">bmk</property>
+                  </object>
+                </child>
               </object>
             </child>
             <child>
-              <object class="BookmarksController" id="bookmarks_controller">
+              <object class="GtkLabel" id="modifications_label">
                 <property name="visible">True</property>
-                <property name="hexpand">False</property>
-                <property name="show-rows-size-button">False</property>
-                <property name="controller-action-prefix">bmk</property>
+                <property name="label" translatable="yes">Pending</property>
               </object>
             </child>
           </object>
@@ -84,6 +145,55 @@
         </child>
       </object>
     </child>
+    <child>
+      <object class="GtkButton" id="show_modifications_button">
+        <property name="visible">False</property>
+        <property name="action-name">ui.show-in-window-modifications</property>
+        <style>
+          <class name="titlebutton"/>
+        </style>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">document-open-recent-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkSeparator" id="modifications_separator">
+        <property name="visible">False</property>
+        <property name="orientation">vertical</property>
+        <style>
+          <class name="titlebutton"/>
+        </style>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkMenuButton" id="modifications_actions_button">
+        <property name="visible">False</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">view-more-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
     <child>
       <object class="GtkMenuButton" id="info_button">
         <property name="visible">True</property>
diff --git a/editor/browser-headerbar.vala b/editor/browser-headerbar.vala
index df99749..32d2bdb 100644
--- a/editor/browser-headerbar.vala
+++ b/editor/browser-headerbar.vala
@@ -26,6 +26,8 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
     [GtkChild] private Revealer     bookmarks_revealer;
     [GtkChild] private Bookmarks    bookmarks_button;
 
+    [GtkChild] private Stack        title_stack;
+
     private ViewType current_type = ViewType.FOLDER;
     private string current_path = "/";
 
@@ -51,6 +53,7 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
             hide_in_window_bookmarks ();
         }
         update_hamburger_menu (delay_mode);
+        update_modifications_button ();
 
         path_widget.set_extra_small_window_state (new_value);
     }
@@ -149,6 +152,104 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
     construct
     {
         install_action_entries ();
+        construct_modifications_actions_button_menu ();
+    }
+
+    /*\
+    * * in-window modifications
+    \*/
+
+    [GtkChild] private Label        modifications_label;
+    [GtkChild] private Separator    modifications_separator;
+    [GtkChild] private Button       show_modifications_button;
+    [GtkChild] private Button       hide_modifications_button;
+    [GtkChild] private MenuButton   modifications_actions_button;
+
+    bool in_window_modifications = false;
+
+    GLib.Menu changes_pending_menu;
+    GLib.Menu quit_delayed_mode_menu;
+    private void construct_modifications_actions_button_menu ()
+    {
+        changes_pending_menu = new GLib.Menu ();
+        changes_pending_menu.append (_("Apply all"), "ui.apply-delayed-settings");
+        changes_pending_menu.append (_("Dismiss all"), "ui.dismiss-delayed-settings");
+        changes_pending_menu.freeze ();
+
+        quit_delayed_mode_menu = new GLib.Menu ();
+        quit_delayed_mode_menu.append (_("Quit mode"), "ui.dismiss-delayed-settings");
+        quit_delayed_mode_menu.freeze ();
+
+        modifications_actions_button.set_menu_model (changes_pending_menu);
+    }
+
+    private void update_modifications_button ()
+    {
+        if (extra_small_window && delay_mode)
+        {
+            set_show_close_button (false);
+            if (in_window_modifications)
+            {
+                show_modifications_button.hide ();
+                modifications_separator.hide ();
+            }
+            else if (in_window_bookmarks)
+            {
+                show_modifications_button.show ();
+                modifications_separator.hide ();
+            }
+            else
+            {
+                show_modifications_button.show ();
+                modifications_separator.show ();
+            }
+        }
+        else
+        {
+            if (in_window_modifications)
+                hide_in_window_modifications ();
+            show_modifications_button.hide ();
+            modifications_separator.hide ();
+            set_show_close_button (true);
+        }
+    }
+
+    internal void show_in_window_modifications ()
+    {
+        if (in_window_bookmarks)
+            hide_in_window_bookmarks ();
+
+        in_window_modifications = true;
+        info_button.hide ();
+        modifications_separator.hide ();
+        show_modifications_button.hide ();
+        modifications_actions_button.show ();
+        hide_modifications_button.show ();
+        bookmarks_stack.hexpand = false;    // hack 1/5
+        title_stack.set_visible_child (modifications_label);
+    }
+
+    internal void hide_in_window_modifications ()
+    {
+        hide_modifications_button.hide ();
+        modifications_actions_button.hide ();
+        if (extra_small_window)
+        {
+            show_modifications_button.show ();
+            modifications_separator.show ();
+        }
+        bookmarks_stack.hexpand = false;    // hack 2/5
+        title_stack.set_visible_child (path_widget);
+        in_window_modifications = false;
+        info_button.show ();
+    }
+
+    internal void set_apply_modifications_button_sensitive (bool new_value)
+    {
+        if (new_value)
+            modifications_actions_button.set_menu_model (changes_pending_menu);
+        else
+            modifications_actions_button.set_menu_model (quit_delayed_mode_menu);
     }
 
     /*\
@@ -165,10 +266,15 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
 
     internal void show_in_window_bookmarks ()
     {
+        if (in_window_modifications)
+            hide_in_window_modifications ();
+
         in_window_bookmarks = true;
+        update_modifications_button ();
         info_button.hide ();
         bookmarks_actions_separator.hide ();
-        bookmarks_stack.hexpand = false;    // hack 1/3
+        bookmarks_stack.hexpand = false;    // hack 3/5
+        title_stack.set_visible_child (bookmarks_stack);
         bookmarks_stack.set_visible_child (bookmarks_label);
         hide_in_window_bookmarks_button.show ();
     }
@@ -178,8 +284,10 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
         hide_in_window_bookmarks_button.hide ();
         bookmarks_actions_separator.hide ();
         in_window_bookmarks = false;
-        bookmarks_stack.hexpand = false;    // hack 2/3
-        bookmarks_stack.set_visible_child (path_widget);
+        update_modifications_button ();
+        bookmarks_stack.hexpand = false;    // hack 4/5
+        title_stack.set_visible_child (path_widget);
+        bookmarks_stack.set_visible_child (bookmarks_label);
         info_button.show ();
         update_hamburger_menu ();
     }
@@ -187,7 +295,7 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
     internal void edit_in_window_bookmarks ()
         requires (in_window_bookmarks == true)
     {
-        bookmarks_stack.hexpand = true;     // hack 3/3
+        bookmarks_stack.hexpand = true;     // hack 5/5
         bookmarks_actions_separator.show ();
         bookmarks_stack.set_visible_child (bookmarks_controller);
     }
@@ -242,7 +350,10 @@ private class BrowserHeaderBar : HeaderBar, AdaptativeWidget
     internal void update_hamburger_menu (bool? new_delay_mode = null)
     {
         if (new_delay_mode != null)
+        {
             delay_mode = (!) new_delay_mode;
+            update_modifications_button ();
+        }
 
         GLib.Menu menu = new GLib.Menu ();
 
diff --git a/editor/browser-infobar.vala b/editor/browser-infobar.vala
index 5a9148d..a684c38 100644
--- a/editor/browser-infobar.vala
+++ b/editor/browser-infobar.vala
@@ -20,7 +20,7 @@ using Gtk;
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/browser-infobar.ui")]
 private class BrowserInfoBar : Revealer
 {
-    [GtkChild] Stack content;
+    [GtkChild] private Stack content;
 
     internal void add_label (string name, string text_label, string? button_label = null, string 
button_action = "")
     {
diff --git a/editor/browser-view.ui b/editor/browser-view.ui
index 2fc95ce..0a4f3f9 100644
--- a/editor/browser-view.ui
+++ b/editor/browser-view.ui
@@ -27,9 +27,17 @@
         <property name="big-placeholder">True</property>
         <property name="edit-mode-action-prefix">bmk</property>
         <property name="schema-path">/ca/desrt/dconf-editor/</property>
-        <signal name="selection-changed" handler="on_selection_changed"/>
+        <signal name="selection-changed" handler="on_bookmarks_selection_changed"/>
         <signal name="update_bookmarks_icons" handler="on_update_bookmarks_icons"/>
       </object>
     </child>
+    <child>
+      <object class="ModificationsList" id="modifications_list">
+        <property name="visible">True</property>
+        <property name="big-placeholder">True</property>
+        <property name="edit-mode-action-prefix">bmk</property>
+        <signal name="selection-changed" handler="on_modifications_selection_changed"/>
+      </object>
+    </child>
   </template>
 </interface>
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 85184df..db9b3d8 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -77,6 +77,7 @@ private class BrowserView : Stack, AdaptativeWidget
             current_child.modifications_handler = value;
             sorting_options = new SortingOptions (value.model);
             sorting_options.notify ["case-sensitive"].connect (on_case_sensitive_changed);
+            _modifications_handler.delayed_changes_changed.connect (update_in_window_modifications);
         }
     }
     private void on_case_sensitive_changed ()
@@ -198,6 +199,95 @@ private class BrowserView : Stack, AdaptativeWidget
             modifications_handler.set_gsettings_key_value (full_name, context_id, new Variant.boolean 
(key_value_request));
     }
 
+    /*\
+    * * modifications
+    \*/
+
+    internal bool in_window_modifications           { internal get; private set; default = false; }
+
+    [GtkChild] private ModificationsList modifications_list;
+
+    internal void show_in_window_modifications ()
+    {
+        if (in_window_bookmarks)
+            hide_in_window_bookmarks ();
+
+        set_visible_child (modifications_list);
+        in_window_modifications = true;
+    }
+
+    internal void hide_in_window_modifications ()
+    {
+        in_window_modifications = false;
+        set_visible_child (current_child_grid);
+    }
+
+    private void update_in_window_modifications ()
+    {
+        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)
+            hide_in_window_modifications ();
+    }
+    private Widget delayed_setting_row_create (Object object)
+    {
+        string full_name = ((SimpleSettingObject) object).full_name;
+        uint16 context_id = ((SimpleSettingObject) object).context_id;
+
+        SettingsModel model = modifications_handler.model;
+
+        RegistryVariantDict properties = new RegistryVariantDict.from_aqv (model.get_key_properties 
(full_name, context_id, (uint16) (PropertyQuery.HAS_SCHEMA & PropertyQuery.IS_DEFAULT & 
PropertyQuery.DEFAULT_VALUE & PropertyQuery.KEY_VALUE)));
+
+        bool has_schema;
+        if (!properties.lookup (PropertyQuery.HAS_SCHEMA,               "b",    out has_schema))
+            assert_not_reached ();
+
+        bool has_schema_and_is_default;
+        if (!has_schema)
+            has_schema_and_is_default = false;
+        else if (!properties.lookup (PropertyQuery.IS_DEFAULT,          "b",    out 
has_schema_and_is_default))
+            assert_not_reached ();
+
+        Variant? planned_value = modifications_handler.get_key_planned_value (full_name);
+        string? cool_planned_value = null;
+        if (planned_value != null)
+            cool_planned_value = Key.cool_text_value_from_variant ((!) planned_value);
+
+        string? cool_default_value = null;
+        if (has_schema
+         && !properties.lookup (PropertyQuery.DEFAULT_VALUE,            "s",    out cool_default_value))
+            assert_not_reached ();
+
+        Variant key_value;
+        if (!properties.lookup (PropertyQuery.KEY_VALUE,                "v",    out key_value))
+            assert_not_reached ();
+
+        properties.clear ();
+
+        DelayedSettingView view = new DelayedSettingView (((SimpleSettingObject) object).name,
+                                                          full_name,
+                                                          context_id,
+                                                          has_schema_and_is_default,    // at row creation, 
key is never ghost
+                                                          key_value,
+                                                          cool_planned_value,
+                                                          cool_default_value);
+
+        ListBoxRow wrapper = new ListBoxRow ();
+        wrapper.add (view);
+        if (modifications_handler.get_current_delay_mode ())
+        {
+            Variant variant = new Variant ("(sq)", full_name, context_id);
+            wrapper.set_detailed_action_name ("ui.open-object(" + variant.print (true) + ")");
+        }
+        return wrapper;
+    }
+
+    [GtkCallback]
+    private void on_modifications_selection_changed ()
+    {
+    }
+
     /*\
     * * bookmarks
     \*/
@@ -212,6 +302,9 @@ private class BrowserView : Stack, AdaptativeWidget
 
     internal void show_in_window_bookmarks (string [] bookmarks)
     {
+        if (in_window_modifications)
+            hide_in_window_modifications ();
+
         if (bookmarks != old_bookmarks)
         {
             Variant variant = new Variant.strv (bookmarks);
@@ -281,7 +374,7 @@ private class BrowserView : Stack, AdaptativeWidget
     }
 
     [GtkCallback]
-    private void on_selection_changed ()
+    private void on_bookmarks_selection_changed ()
     {
         if (!in_window_bookmarks)
             return;
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 87c909d..5bd55df 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -147,6 +147,20 @@ private class DConfWindow : ApplicationWindow
         modifications_handler = new ModificationsHandler (model);
         revealer.modifications_handler = modifications_handler;
         browser_view.modifications_handler = modifications_handler;
+        modifications_handler.delayed_changes_changed.connect (() => {
+                if (!extra_small_window)
+                    return;
+
+                uint total_changes_count = modifications_handler.dconf_changes_count + 
modifications_handler.gsettings_changes_count;
+                if (total_changes_count == 0)
+                    headerbar.set_apply_modifications_button_sensitive (false);
+                else
+                {
+                    if (modifications_handler.mode == ModificationsMode.TEMPORARY && total_changes_count != 
1)
+                        assert_not_reached ();
+                    headerbar.set_apply_modifications_button_sensitive (true);
+                }
+            });
 
         behaviour_changed_handler = settings.changed ["behaviour"].connect_after 
(invalidate_popovers_with_ui_reload);
         settings.bind ("behaviour", modifications_handler, "behaviour", 
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
@@ -442,6 +456,7 @@ private class DConfWindow : ApplicationWindow
                 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");
@@ -458,6 +473,7 @@ private class DConfWindow : ApplicationWindow
                 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);
             }
             notification_revealer.hexpand = true;
             notification_revealer.halign = Align.FILL;
@@ -471,6 +487,7 @@ private class DConfWindow : ApplicationWindow
                 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");
             notification_revealer.hexpand = true;
@@ -486,6 +503,7 @@ private class DConfWindow : ApplicationWindow
                 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);
             }
             notification_revealer.hexpand = false;
             notification_revealer.halign = Align.CENTER;
@@ -595,8 +613,11 @@ private class DConfWindow : ApplicationWindow
         { "toggle-search", toggle_search, "b", "false" },
         { "update-bookmarks-icons", update_bookmarks_icons, "as" },
 
-        { "show-in-window-bookmarks", show_in_window_bookmarks },
-        { "hide-in-window-bookmarks", hide_in_window_bookmarks },
+        { "show-in-window-bookmarks",       show_in_window_bookmarks },
+        { "hide-in-window-bookmarks",       hide_in_window_bookmarks },
+
+        { "show-in-window-modifications",   show_in_window_modifications },
+        { "hide-in-window-modifications",   hide_in_window_modifications },
 
         { "reset-recursive", reset_recursively, "s" },
         { "reset-visible", reset_visible, "s" },
@@ -648,6 +669,7 @@ private class DConfWindow : ApplicationWindow
         hide_in_window_bookmarks ();
         headerbar.close_popovers ();
         revealer.hide_modifications_list ();
+        hide_in_window_modifications ();
 
         string full_name;
         uint16 context_id;
@@ -692,6 +714,7 @@ private class DConfWindow : ApplicationWindow
         hide_in_window_bookmarks ();
         headerbar.close_popovers ();
         revealer.hide_modifications_list ();
+        hide_in_window_modifications ();
 
         string full_name;
         uint16 context_id;
@@ -819,6 +842,18 @@ private class DConfWindow : ApplicationWindow
         browser_view.hide_in_window_bookmarks ();
     }
 
+    private void show_in_window_modifications (/* SimpleAction action, Variant? path_variant */)
+    {
+        headerbar.show_in_window_modifications ();
+        browser_view.show_in_window_modifications ();
+    }
+
+    private void hide_in_window_modifications (/* SimpleAction action, Variant? path_variant */)
+    {
+        headerbar.hide_in_window_modifications ();
+        browser_view.hide_in_window_modifications ();
+    }
+
     private void reset_recursively (SimpleAction action, Variant? path_variant)
         requires (path_variant != null)
     {
@@ -846,6 +881,8 @@ private class DConfWindow : ApplicationWindow
     private void apply_delayed_settings (/* SimpleAction action, Variant? path_variant */)
     {
         modifications_handler.apply_delayed_settings ();
+        if (extra_small_window)
+            hide_in_window_modifications ();
         invalidate_popovers_with_ui_reload ();
     }
 
@@ -1065,7 +1102,9 @@ private class DConfWindow : ApplicationWindow
 
     private void copy_path                              (/* SimpleAction action, Variant? path_variant */)
     {
-        if (browser_view.in_window_bookmarks) // TODO better
+        if (browser_view.in_window_bookmarks)       // TODO better
+            return;
+        if (browser_view.in_window_modifications)   // TODO better
             return;
 
         browser_view.discard_row_popover ();
@@ -1086,7 +1125,9 @@ private class DConfWindow : ApplicationWindow
 
     private void bookmark                               (/* SimpleAction action, Variant? variant */)
     {
-        if (browser_view.in_window_bookmarks) // TODO better
+        if (browser_view.in_window_bookmarks)       // TODO better
+            return;
+        if (browser_view.in_window_modifications)   // TODO better
             return;
 
         browser_view.discard_row_popover ();
@@ -1095,7 +1136,9 @@ private class DConfWindow : ApplicationWindow
 
     private void unbookmark                             (/* SimpleAction action, Variant? variant */)
     {
-        if (browser_view.in_window_bookmarks) // TODO better
+        if (browser_view.in_window_bookmarks)       // TODO better
+            return;
+        if (browser_view.in_window_modifications)   // TODO better
             return;
 
         browser_view.discard_row_popover ();
@@ -1104,7 +1147,9 @@ private class DConfWindow : ApplicationWindow
 
     private void _toggle_search                         (/* SimpleAction action, Variant? variant */)
     {
-        if (browser_view.in_window_bookmarks) // TODO better
+        if (browser_view.in_window_bookmarks)       // TODO better
+            return;
+        if (browser_view.in_window_modifications)   // TODO better
             return;
 
         headerbar.close_popovers ();    // should never be needed if headerbar.search_mode_enabled
@@ -1124,7 +1169,7 @@ private class DConfWindow : ApplicationWindow
     {
         if (headerbar.has_popover ()) // for bookmarks popover, let headerbar handle that
             headerbar.down_pressed ();
-        else if (!revealer.get_modifications_list_state ())
+        else if (!revealer.get_modifications_list_state () && !browser_view.in_window_modifications)
             browser_view.down_pressed ();               // FIXME returns bool
     }
 
@@ -1132,13 +1177,15 @@ private class DConfWindow : ApplicationWindow
     {
         if (headerbar.has_popover ()) // for bookmarks popover, let headerbar handle that
             headerbar.up_pressed ();
-        else if (!revealer.get_modifications_list_state ())
+        else if (!revealer.get_modifications_list_state () && !browser_view.in_window_modifications)
             browser_view.up_pressed ();                 // FIXME returns bool
     }
 
     private void _request_config                        (/* SimpleAction action, Variant? variant */)  // 
TODO unduplicate method name
     {
-        if (browser_view.in_window_bookmarks) // TODO better
+        if (browser_view.in_window_bookmarks)       // TODO better
+            return;
+        if (browser_view.in_window_modifications)   // TODO better
             return;
 
         if (browser_view.current_view == ViewType.FOLDER)
@@ -1147,17 +1194,26 @@ private class DConfWindow : ApplicationWindow
 
     private void modifications_list                     (/* SimpleAction action, Variant? variant */)
     {
-        if (browser_view.in_window_bookmarks)
-            return;
-
-        if (revealer.reveal_child)
-            revealer.toggle_modifications_list ();
+        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 ();
+        }
     }
 
     private void edit_path_end                          (/* SimpleAction action, Variant? variant */)
     {
         if (browser_view.in_window_bookmarks)
             return;
+        if (browser_view.in_window_modifications)
+            return;
 
         if (!headerbar.search_mode_enabled)
             request_search (true, PathEntry.SearchMode.EDIT_PATH_MOVE_END);
@@ -1167,6 +1223,8 @@ private class DConfWindow : ApplicationWindow
     {
         if (browser_view.in_window_bookmarks)
             return;
+        if (browser_view.in_window_modifications)
+            return;
 
         if (!headerbar.search_mode_enabled)
             request_search (true, PathEntry.SearchMode.EDIT_PATH_SELECT_LAST_WORD);
@@ -1176,6 +1234,8 @@ private class DConfWindow : ApplicationWindow
     {
         if (browser_view.in_window_bookmarks)
             return;
+        if (browser_view.in_window_modifications)
+            return;
 
         go_backward (true);
     }
@@ -1184,6 +1244,8 @@ private class DConfWindow : ApplicationWindow
     {
         if (browser_view.in_window_bookmarks)
             return;
+        if (browser_view.in_window_modifications)
+            return;
 
         if (browser_view.current_view == ViewType.CONFIG)
             request_folder (current_path);
@@ -1195,6 +1257,8 @@ private class DConfWindow : ApplicationWindow
     {
         if (browser_view.in_window_bookmarks)
             return;
+        if (browser_view.in_window_modifications)
+            return;
 
         go_forward (false);
     }
@@ -1203,6 +1267,8 @@ private class DConfWindow : ApplicationWindow
     {
         if (browser_view.in_window_bookmarks)
             return;
+        if (browser_view.in_window_modifications)
+            return;
 
         go_forward (true);
     }
@@ -1221,6 +1287,8 @@ private class DConfWindow : ApplicationWindow
             else
                 hide_in_window_bookmarks ();
         }
+        else if (browser_view.in_window_modifications)
+            hide_in_window_modifications ();
         else if (headerbar.search_mode_enabled)
             stop_search ();
         else if (current_type == ViewType.CONFIG)
@@ -1244,6 +1312,8 @@ private class DConfWindow : ApplicationWindow
             return;
         if (browser_view.in_window_bookmarks)
             return;
+        if (browser_view.in_window_modifications)
+            return;
 
         browser_view.discard_row_popover ();
         browser_view.toggle_boolean_key ();
@@ -1255,6 +1325,8 @@ private class DConfWindow : ApplicationWindow
             return;
         if (browser_view.in_window_bookmarks)
             return;
+        if (browser_view.in_window_modifications)
+            return;
 
         if (revealer.dismiss_selected_modification ())
         {
@@ -1486,6 +1558,8 @@ private class DConfWindow : ApplicationWindow
     {
         if (browser_view.in_window_bookmarks)
             return false;
+        if (browser_view.in_window_modifications)
+            return false;
 
         uint keyval = event.keyval;
         string name = (!) (Gdk.keyval_name (keyval) ?? "");
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index da44f44..96adc2c 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -18,7 +18,7 @@
 using Gtk;
 
 [GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/modifications-revealer.ui")]
-private class ModificationsRevealer : Revealer
+private class ModificationsRevealer : Revealer, AdaptativeWidget
 {
     private ModificationsHandler _modifications_handler;
     internal ModificationsHandler modifications_handler
@@ -31,6 +31,13 @@ private class ModificationsRevealer : Revealer
         }
     }
 
+    private bool extra_small_window = false;
+    private void set_extra_small_window_state (bool new_value)
+    {
+        extra_small_window = new_value;
+        update ();
+    }
+
     [GtkChild] private Label label;
     [GtkChild] private ModelButton apply_button;
     [GtkChild] private MenuButton delayed_list_button;
@@ -237,6 +244,12 @@ private class ModificationsRevealer : Revealer
 
     private void update ()
     {
+        if (extra_small_window)
+        {
+            set_reveal_child (false);
+            return;
+        }
+
         GLib.ListStore modifications_liststore = modifications_handler.get_delayed_settings ();
         modifications_list.bind_model (modifications_liststore, delayed_setting_row_create);
 


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