summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2011-06-22 11:46:40 -0400
committerRyan Lortie <desrt@desrt.ca>2011-06-22 11:47:28 -0400
commita15802bd044b93c02ecd880d0c2bcb5935b03d92 (patch)
treea987addbdd07fe5ba6ea1358109372c8c7143d34
parent8046ebb2cc9e84364a4f2f580499e7dbfa4e7b8a (diff)
downloaddconf-a15802bd044b93c02ecd880d0c2bcb5935b03d92.tar.gz
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
-rw-r--r--editor/dconf-model.vala23
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