From b1cf066711a06526e66bd0b271ec49c9416add9d Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Tue, 10 Jul 2012 14:16:48 -0400 Subject: Fix up the "changed" signal for Vala Fix the vapi file to properly describe the changed signal (including the possibility of NULL tag). Change the dconf tool's implementation of the signal handler (and simplify it due to the changed semantics of the signal). Do the same for the editor. --- bin/dconf.vala | 21 ++++++++------------- client/dconf.vapi | 2 +- editor/dconf-model.vala | 10 +++------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/bin/dconf.vala b/bin/dconf.vala index 88db9e6..646b275 100644 --- a/bin/dconf.vala +++ b/bin/dconf.vala @@ -205,29 +205,24 @@ void show_path (DConf.Client client, string path) { } } -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 watch_function (DConf.Client client, string path, string[] items, string? tag) { + 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 (); - client.changed.connect (watch_function); var path = args[2]; DConf.verify_path (path); + client.changed.connect (watch_function); client.watch_sync (path); + new MainLoop (null, false).run (); } diff --git a/client/dconf.vapi b/client/dconf.vapi index af293aa..7e5cdae 100644 --- a/client/dconf.vapi +++ b/client/dconf.vapi @@ -3,7 +3,7 @@ namespace DConf { [CCode (cheader_filename = "dconf.h")] public class Client : GLib.Object { - public signal void changed (string prefix, string[] changes, string tag); + public signal void changed (string prefix, [CCode (array_length = false, array_null_terminated = true)] string[] changes, string? tag); public Client (); public GLib.Variant? read (string key); diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala index fc772a6..ff45a29 100644 --- a/editor/dconf-model.vala +++ b/editor/dconf-model.vala @@ -570,13 +570,9 @@ public class SettingsModel: GLib.Object, Gtk.TreeModel 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); - } + void watch_func (DConf.Client client, string path, string[] items, string? tag) { + foreach (var item in items) { + item_changed (path + item); } } -- cgit v1.2.1