[dconf-editor] Do not use signal if not necessary.



commit 0ce76ef586d6c9435512563ed8c4312626928de4
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Jul 26 04:19:48 2016 +0200

    Do not use signal if not necessary.

 editor/bookmarks.vala    |   12 +++++++++---
 editor/dconf-window.vala |    3 +--
 2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index 7643294..62bc75a 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -25,7 +25,15 @@ public class Bookmarks : MenuButton
 
     [GtkChild] private Image bookmarks_icon;
     [GtkChild] private Switch bookmarked_switch;
-    public string current_path { get; set; }
+    private string _current_path = "/";
+    public string current_path {
+        private get { return _current_path; }
+        public set {
+            if (_current_path != value)
+                _current_path = value;
+            update_icon_and_switch ();
+        }
+    }
 
     public string schema_id { get; construct; }
     private GLib.Settings settings;
@@ -39,7 +47,6 @@ public class Bookmarks : MenuButton
         settings = new GLib.Settings (schema_id);
 
         switch_active_handler = bookmarked_switch.notify ["active"].connect (switch_changed_cb);
-        ulong current_path_changed_handler = notify ["current-path"].connect (update_icon_and_switch);
         ulong bookmarks_changed_handler = settings.changed ["bookmarks"].connect (() => {
                 update_bookmarks ();
                 update_icon_and_switch ();
@@ -49,7 +56,6 @@ public class Bookmarks : MenuButton
         bookmarked_switch.grab_focus ();
 
         destroy.connect (() => {
-                disconnect (current_path_changed_handler);
                 settings.disconnect (bookmarks_changed_handler);
             });
         bookmarked_switch.destroy.connect (() => {
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index f7321ec..367aee3 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -216,8 +216,7 @@ class DConfWindow : ApplicationWindow
     {
         GLib.Menu section;
 
-        if (bookmarks_button.current_path != current_path)
-            bookmarks_button.current_path = current_path;
+        bookmarks_button.current_path = current_path;
         pathbar.set_path (current_path);
 
         GLib.Menu menu = new GLib.Menu ();


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