summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2018-11-10 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2018-11-13 08:51:30 +0100
commit25aca2e7c3c13b298290148cfd55ab426f1c68d4 (patch)
treed35f486509007382d8531269b69e13e5b463da67 /bin
parentec46c2b3955d36a2a90741a48f2b426b341bbba0 (diff)
downloaddconf-25aca2e7c3c13b298290148cfd55ab426f1c68d4.tar.gz
bin: Sort output of list and dump commands
Diffstat (limited to 'bin')
-rw-r--r--bin/dconf-dump.vala13
-rw-r--r--bin/dconf.vala5
2 files changed, 16 insertions, 2 deletions
diff --git a/bin/dconf-dump.vala b/bin/dconf-dump.vala
index 135b230..d63e3eb 100644
--- a/bin/dconf-dump.vala
+++ b/bin/dconf-dump.vala
@@ -8,7 +8,18 @@ void add_to_keyfile (KeyFile kf, DConf.Client client, string topdir, string? rel
this_group = "/";
}
- foreach (var item in client.list (this_dir)) {
+ var items = client.list (this_dir);
+ GLib.qsort_with_data<string> (items, sizeof (string), (a, b) => {
+ var a_dir = a.has_suffix ("/");
+ var b_dir = b.has_suffix ("/");
+ if (a_dir != b_dir) {
+ return (int) a_dir - (int) b_dir;
+ } else {
+ return GLib.strcmp (a, b);
+ }
+ });
+
+ foreach (var item in items) {
if (item.has_suffix ("/")) {
add_to_keyfile (kf, client, topdir, rel + item);
} else {
diff --git a/bin/dconf.vala b/bin/dconf.vala
index 349e1ea..8b0f211 100644
--- a/bin/dconf.vala
+++ b/bin/dconf.vala
@@ -186,7 +186,10 @@ void dconf_list (string?[] args) throws Error {
DConf.verify_dir (dir);
- foreach (var item in client.list (dir)) {
+ var items = client.list (dir);
+ GLib.qsort_with_data<string> (items, sizeof (string), (a, b) => GLib.strcmp (a, b));
+
+ foreach (var item in items) {
print ("%s\n", item);
}
}