[dconf] cli: make 'dconf watch' actually write output



commit 8046ebb2cc9e84364a4f2f580499e7dbfa4e7b8a
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue May 10 12:18:10 2011 +0200

    cli: make 'dconf watch' actually write output

 bin/dconf.vala |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/bin/dconf.vala b/bin/dconf.vala
index a2d7a60..071d39e 100644
--- a/bin/dconf.vala
+++ b/bin/dconf.vala
@@ -215,8 +215,31 @@ void dconf_unlock (string?[] args) throws Error {
 	client.set_locked (key, false);
 }
 
+void show_path (DConf.Client client, string path) {
+	if (DConf.is_key (path)) {
+		var value = client.read (path);
+
+		print ("  %s\n", value != null ? value.print (true) : "unset");
+	}
+}
+
+void watch_function (DConf.Client client, string path, string[] items, string tag) {
+	if (items.length == 0) {
+		print ("%s\n", path);
+		show_path (client, path);
+		print ("\n");
+	} else {
+		foreach (var item in items) {
+			var full = path + item;
+			print ("%s\n", full);
+			show_path (client, full);
+		}
+		print ("\n");
+	}
+}
+
 void dconf_watch (string?[] args) throws Error {
-	var client = new DConf.Client ();
+	var client = new DConf.Client (null, watch_function);
 	var path = args[2];
 
 	DConf.verify_path (path);



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