[dconf-editor] Handle empty relocatable schemas.



commit 2dca20ee6c5e21a6ffc2a828775ad4365ef30852
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sun Feb 25 05:44:41 2018 +0100

    Handle empty relocatable schemas.

 editor/ca.desrt.dconf-editor.gschema.xml |    4 ++-
 editor/dconf-editor.vala                 |    4 ++-
 editor/source-manager.vala               |   34 +++++++++++++++++------------
 3 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/editor/ca.desrt.dconf-editor.gschema.xml b/editor/ca.desrt.dconf-editor.gschema.xml
index a92eeaa..aeb7ccc 100644
--- a/editor/ca.desrt.dconf-editor.gschema.xml
+++ b/editor/ca.desrt.dconf-editor.gschema.xml
@@ -343,7 +343,9 @@ If you are not interacting with D-Bus, then there is no reason to make use of th
       <description>A range could limit an integer key to only allow one value, but that’s probably an error. 
Dconf Editor warns you in that case.</description>
     </key>
   </schema>
-  <schema id="ca.desrt.dconf-editor.DemoEmpty" path="/ca/desrt/dconf-editor/Demo/Empty/">
+  <schema id="ca.desrt.dconf-editor.Demo.Empty" path="/ca/desrt/dconf-editor/Demo/Empty/">
+  </schema>
+  <schema id="ca.desrt.dconf-editor.Demo.EmptyRelocatable">
   </schema>
   <schema id="ca.desrt.dconf-editor.Demo.Relocatable">
     <key name="boolean" type="b">
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 794c44d..da038c7 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -19,7 +19,9 @@ class ConfigurationEditor : Gtk.Application
 {
     public static string [,] internal_mappings = {
             {"ca.desrt.dconf-editor.Bookmarks",
-                "/ca/desrt/dconf-editor/"}
+                "/ca/desrt/dconf-editor/"},
+            {"ca.desrt.dconf-editor.Demo.EmptyRelocatable",
+                "/ca/desrt/dconf-editor/Demo/EmptyRelocatable/"}
         };
     public static string [,] known_mappings = {
             {"com.gexperts.Tilix.Profile",
diff --git a/editor/source-manager.vala b/editor/source-manager.vala
index 5e62fc6..bdf2abf 100644
--- a/editor/source-manager.vala
+++ b/editor/source-manager.vala
@@ -38,7 +38,7 @@ public class SourceManager : Object
         return (!) settings_schema_source;
     }
 
-    private string [] previous_empty_schemas = { "ca.desrt.dconf-editor.DemoEmpty" };
+    private string [] previous_empty_schemas = { "ca.desrt.dconf-editor.Demo.Empty", 
"ca.desrt.dconf-editor.Demo.EmptyRelocatable" };
     public void refresh_schema_source ()
     {
         SettingsSchemaSource? settings_schema_source = create_schema_source ();
@@ -67,6 +67,25 @@ public class SourceManager : Object
             cached_schemas.add_schema ((!) settings_schema, modified_path_specs);
         }
 
+        foreach (string schema_id in relocatable_schemas)
+        {
+            GenericSet<string>? path_specs = relocatable_schema_paths.lookup (schema_id);
+            if (path_specs == null)
+                continue;
+
+            SettingsSchema? settings_schema = ((!) settings_schema_source).lookup (schema_id, true);
+            if (settings_schema == null || ((string?) ((!) settings_schema).get_path ()) != null)
+                continue;       // TODO better
+
+            if (((!) settings_schema).list_keys ().length == 0 && ((!) settings_schema).list_children 
().length == 0)
+            {
+                empty_schemas += schema_id;
+                continue;
+            }
+
+            cached_schemas.add_schema_with_path_specs ((!) settings_schema, (!) path_specs, 
modified_path_specs);
+        }
+
         string [] empty_schemas_needing_warning = {};
         if (empty_schemas.length > 0)
             foreach (string test_string in empty_schemas)
@@ -90,19 +109,6 @@ public class SourceManager : Object
             previous_empty_schemas = empty_schemas;
         }
 
-        foreach (string schema_id in relocatable_schemas)
-        {
-            GenericSet<string>? path_specs = relocatable_schema_paths.lookup (schema_id);
-            if (path_specs == null)
-                continue;
-
-            SettingsSchema? settings_schema = ((!) settings_schema_source).lookup (schema_id, true);
-            if (settings_schema == null || ((string?) ((!) settings_schema).get_path ()) != null)
-                continue;       // TODO better
-
-            cached_schemas.add_schema_with_path_specs ((!) settings_schema, (!) path_specs, 
modified_path_specs);
-        }
-
         cached_schemas.remove_unmarked (modified_path_specs);
 
         this.settings_schema_source = settings_schema_source;


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