[dconf-editor] Add some convenience methods to the model



commit d9740d05152e627dc52fec0b8ffa8bf148cc07d2
Author: Davi da Silva Böger <dsboger gmail com>
Date:   Sun Nov 26 01:05:48 2017 -0200

    Add some convenience methods to the model

 editor/dconf-model.vala |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index 228733a..2508c73 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -657,6 +657,24 @@ public class SettingsModel : Object
         return (Directory) (!) dir;
     }
 
+    public SettingObject? get_object (string path)
+    {
+        if (path.has_suffix ("/"))
+            return get_directory (path);
+        Directory? parent = get_directory (get_base_path (path));
+        if (parent == null)
+            return null;
+        string name = path [path.last_index_of_char ('/') + 1:path.length];
+        return get_key_from_path_and_name (((!) parent).key_model, name);
+    }
+
+    public string get_parent_path (string path)
+    {
+        if (path == "/")
+            return path;
+        return get_base_path (path.has_suffix ("/") ? path [0:-1] : path);
+    }
+
     private static string stripped_path (string path)
     {
         if (path.length <= 1)


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