[dconf-editor] Add parent_path in SettingObject.



commit 77bc894a542d160187a4db7e4c276bf318d8fad6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sun Jan 7 10:58:31 2018 +0100

    Add parent_path in SettingObject.

 editor/dconf-model.vala      |   18 ++++++++++++++----
 editor/key-list-box-row.vala |    4 ++--
 editor/registry-search.vala  |    2 +-
 editor/registry-view.vala    |    2 +-
 4 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/editor/dconf-model.vala b/editor/dconf-model.vala
index c91f30b..556d763 100644
--- a/editor/dconf-model.vala
+++ b/editor/dconf-model.vala
@@ -21,9 +21,22 @@ public abstract class SettingObject : Object
     public string full_name { get; construct; }
 
     public string casefolded_name { get; private construct; }
+    public string parent_path { get; private construct; }
     construct
     {
         casefolded_name = name.casefold ();
+
+        if (full_name.length < 2)
+            parent_path = "/";
+        else
+        {
+            string tmp_string = full_name.slice (0, full_name.last_index_of_char ('/'));
+
+            if (full_name.has_suffix ("/"))
+                parent_path = full_name.slice (0, tmp_string.last_index_of_char ('/') + 1);
+            else
+                parent_path = tmp_string + "/";
+        }
     }
 }
 
@@ -293,10 +306,7 @@ public class GSettingsKey : Key
     public override string descriptor {
         owned get {
             if (schema_path == null)
-            {
-                string schema_path = SettingsModel.get_parent_path (full_name);
-                return @"$schema_id:$schema_path $name";
-            }
+                return @"$schema_id:$parent_path $name";
             return @"$schema_id $name";
         }
     }
diff --git a/editor/key-list-box-row.vala b/editor/key-list-box-row.vala
index e3ad03a..026c731 100644
--- a/editor/key-list-box-row.vala
+++ b/editor/key-list-box-row.vala
@@ -358,7 +358,7 @@ private class KeyListBoxRowEditableNoSchema : KeyListBoxRow
 
         if (search_result_mode)
         {
-            variant = new Variant.string (SettingsModel.get_parent_path (key.full_name));
+            variant = new Variant.string (key.parent_path);
             popover.new_gaction ("open_parent", "ui.open-path(" + variant.print (false) + ")");    // TODO 
selection 2/3
             popover.new_section ();
         }
@@ -492,7 +492,7 @@ private class KeyListBoxRowEditable : KeyListBoxRow
 
         if (search_result_mode)
         {
-            variant = new Variant.string (SettingsModel.get_parent_path (key.full_name));
+            variant = new Variant.string (key.parent_path);
             popover.new_gaction ("open_parent", "ui.open-path(" + variant.print (false) + ")");    // TODO 
selection 3/3
             popover.new_section ();
         }
diff --git a/editor/registry-search.vala b/editor/registry-search.vala
index a67c805..da29483 100644
--- a/editor/registry-search.vala
+++ b/editor/registry-search.vala
@@ -146,7 +146,7 @@ class RegistrySearch : Grid, BrowsableView
 
         if (setting_object is Directory)
         {
-            row = new FolderListBoxRow (setting_object.name, setting_object.full_name, 
SettingsModel.get_parent_path (setting_object.full_name), !is_local_result);
+            row = new FolderListBoxRow (setting_object.name, setting_object.full_name, 
setting_object.parent_path, !is_local_result);
             on_delete_call_handler = row.on_delete_call.connect (() => browser_view.reset_directory 
((Directory) setting_object, true));
         }
         else
diff --git a/editor/registry-view.vala b/editor/registry-view.vala
index 36bf7aa..fa26813 100644
--- a/editor/registry-view.vala
+++ b/editor/registry-view.vala
@@ -179,7 +179,7 @@ class RegistryView : Grid, BrowsableView
 
         if (setting_object is Directory)
         {
-            row = new FolderListBoxRow (setting_object.name, setting_object.full_name, 
SettingsModel.get_parent_path (setting_object.full_name));
+            row = new FolderListBoxRow (setting_object.name, setting_object.full_name, 
setting_object.parent_path);
             on_delete_call_handler = row.on_delete_call.connect (() => browser_view.reset_directory 
((Directory) setting_object, true));
         }
         else


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