[dconf-editor] Move mods. handler instantiation to DConfWindow



commit cdac527971d8a58c50cc60a5da547ba0650523e8
Author: Davi da Silva Böger <dsboger gmail com>
Date:   Mon Dec 4 02:37:49 2017 -0200

    Move mods. handler instantiation to DConfWindow

 editor/browser-view.vala |   34 ++++++++++++++++++----------------
 editor/dconf-window.vala |    5 ++++-
 2 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/editor/browser-view.vala b/editor/browser-view.vala
index 8f21af8..085b6d6 100644
--- a/editor/browser-view.vala
+++ b/editor/browser-view.vala
@@ -53,7 +53,24 @@ class BrowserView : Grid, PathElement
 
     [GtkChild] private ModificationsRevealer revealer;
 
-    private ModificationsHandler modifications_handler;
+    private ModificationsHandler _modifications_handler;
+    public ModificationsHandler modifications_handler
+    {
+        private get { return _modifications_handler; }
+        set {
+            _modifications_handler = value;
+            revealer.modifications_handler = value;
+            browse_view.modifications_handler = value;
+            properties_view.modifications_handler = value;
+            search_results_view.modifications_handler = value;
+
+            settings.bind ("behaviour", modifications_handler, "behaviour", 
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
+            ulong modifications_handler_reload_handler = modifications_handler.reload.connect 
(invalidate_popovers);
+            destroy.connect (() => {
+                modifications_handler.disconnect (modifications_handler_reload_handler);
+            });
+        }
+    }
 
     private DConfWindow? _window = null;
     private DConfWindow window {
@@ -66,16 +83,7 @@ class BrowserView : Grid, PathElement
 
     construct
     {
-        modifications_handler = new ModificationsHandler ();
-        revealer.modifications_handler = modifications_handler;
-        browse_view.modifications_handler = modifications_handler;
-        properties_view.modifications_handler = modifications_handler;
-        search_results_view.modifications_handler = modifications_handler;
-
-        ulong modifications_handler_reload_handler = modifications_handler.reload.connect 
(invalidate_popovers);
-
         ulong behaviour_changed_handler = settings.changed ["behaviour"].connect (invalidate_popovers);
-        settings.bind ("behaviour", modifications_handler, "behaviour", 
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
         settings.bind ("behaviour", browse_view, "behaviour", 
SettingsBindFlags.GET|SettingsBindFlags.NO_SENSITIVITY);
 
         sorting_options = new SortingOptions ();
@@ -90,7 +98,6 @@ class BrowserView : Grid, PathElement
 
         destroy.connect (() => {
                 settings.disconnect (behaviour_changed_handler);
-                modifications_handler.disconnect (modifications_handler_reload_handler);
                 base.destroy ();
             });
     }
@@ -187,11 +194,6 @@ class BrowserView : Grid, PathElement
         invalidate_popovers ();
     }
 
-    public bool get_current_delay_mode ()
-    {
-        return modifications_handler.get_current_delay_mode ();
-    }
-
     public string? get_copy_text ()
     {
         return ((BrowsableView) stack.get_visible_child ()).get_copy_text ();
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 92e3842..6349ac9 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -32,6 +32,7 @@ class DConfWindow : ApplicationWindow
     public string current_path { get; set; default = "/"; } // not synced bidi, needed for saving on 
destroy, even after child destruction
 
     public SettingsModel model { get; private set; }
+    public ModificationsHandler modifications_handler { get; private set; }
 
     private int window_width = 0;
     private int window_height = 0;
@@ -74,6 +75,8 @@ class DConfWindow : ApplicationWindow
 
     public DConfWindow (bool disable_warning, string? schema, string? path, string? key_name)
     {
+        modifications_handler = new ModificationsHandler ();
+        browser_view.modifications_handler = modifications_handler;
         model = new SettingsModel (settings);
 
         if (!disable_warning && settings.get_boolean ("show-warning"))
@@ -367,7 +370,7 @@ class DConfWindow : ApplicationWindow
             menu.append_section (null, section);
         }
 
-        if (!browser_view.get_current_delay_mode ())
+        if (!modifications_handler.get_current_delay_mode ())
         {
             section = new GLib.Menu ();
             section.append (_("Enter delay mode"), "win.enter-delay-mode");


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