[dconf] Add change watching to dconf-editor



commit a15802bd044b93c02ecd880d0c2bcb5935b03d92
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Jun 22 11:46:40 2011 -0400

    Add change watching to dconf-editor
    
    Watch for changes to DConf and update the view.  This is not done in the
    most elegant or efficient way, but it's simple and it works.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=649443

 editor/dconf-model.vala |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index bb2213e..e03f530 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -118,6 +118,12 @@ public class Key : GLib.Object
 
     public signal void value_changed();
 
+	void item_changed (string key) {
+		if ((key.has_suffix ("/") && full_name.has_prefix (key)) || key == full_name) {
+			value_changed ();
+		}
+	}
+
     public Key(SettingsModel model, Directory parent, string name, string full_name)
     {
         this.model = model;
@@ -125,6 +131,8 @@ public class Key : GLib.Object
         this.name = name;
         this.full_name = full_name;
         this.schema = model.schemas.keys.lookup(full_name);
+
+		model.item_changed.connect (item_changed);
     }
 
     public void set_to_default()
@@ -556,10 +564,23 @@ public class SettingsModel: GLib.Object, Gtk.TreeModel
     public DConf.Client client;
     private Directory root;
 
+	public signal void item_changed (string key);
+
+	void watch_func (DConf.Client client, string path, string[] items, string tag) {
+		if (items.length == 0) {
+			item_changed (path);
+		} else {
+			foreach (var item in items) {
+				item_changed (path + item);
+			}
+		}
+	}
+
     public SettingsModel()
     {
-        client = new DConf.Client ();
+        client = new DConf.Client (null, watch_func);
         root = new Directory(this, null, "/", "/");
+		client.watch ("/");
 
         schemas = new SchemaList();
         try



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