[dconf-editor] Simplify Bookmarks more.



commit 8be9f4c8543ef7aa7f63dc12e3a3ac0535008a47
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Jul 26 14:25:29 2016 +0200

    Simplify Bookmarks more.

 editor/bookmarks.vala    |   27 +++++++++++----------------
 editor/dconf-window.vala |    2 +-
 2 files changed, 12 insertions(+), 17 deletions(-)
---
diff --git a/editor/bookmarks.vala b/editor/bookmarks.vala
index 62bc75a..5f59511 100644
--- a/editor/bookmarks.vala
+++ b/editor/bookmarks.vala
@@ -25,14 +25,13 @@ public class Bookmarks : MenuButton
 
     [GtkChild] private Image bookmarks_icon;
     [GtkChild] private Switch bookmarked_switch;
-    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 ();
-        }
+
+    private string current_path = "/";
+    public void set_path (string path)
+    {
+        if (current_path != path)
+            current_path = path;
+        update_icon_and_switch ();
     }
 
     public string schema_id { get; construct; }
@@ -90,16 +89,17 @@ public class Bookmarks : MenuButton
 
     private void update_bookmarks ()
     {
-        GLib.ListStore bookmarks_model = new GLib.ListStore (typeof (Bookmark));    // TODO use the binding 
to add/remove rows
+        bookmarks_list_box.@foreach ((widget) => { widget.destroy (); });
+
         string [] bookmarks = settings.get_strv ("bookmarks");
         foreach (string bookmark in bookmarks)
         {
             Bookmark bookmark_row = new Bookmark (bookmark);
             ulong destroy_button_clicked_handler = bookmark_row.destroy_button.clicked.connect (() => { 
remove_bookmark (bookmark); });
             bookmark_row.destroy_button.destroy.connect (() => { bookmark_row.destroy_button.disconnect 
(destroy_button_clicked_handler); });
-            bookmarks_model.append (bookmark_row);
+            bookmark_row.show ();
+            bookmarks_list_box.add (bookmark_row);
         }
-        bookmarks_list_box.bind_model (bookmarks_model, new_bookmark_row);
     }
 
     private void switch_changed_cb ()
@@ -123,11 +123,6 @@ public class Bookmarks : MenuButton
             bookmarked_switch.set_active (new_state);
     }
 
-    private Widget new_bookmark_row (Object item)
-    {
-        return (Bookmark) item;
-    }
-
     [GtkCallback]
     private void bookmark_activated_cb (ListBoxRow list_box_row)
     {
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index 367aee3..37204c8 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -216,7 +216,7 @@ class DConfWindow : ApplicationWindow
     {
         GLib.Menu section;
 
-        bookmarks_button.current_path = current_path;
+        bookmarks_button.set_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]