[devhelp/wip/devhelp-next: 2/2] gsettings: split gschema.xml between the lib and the app



commit ff00542af89f652d1de796be1bee071ea881a790
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Mar 9 12:09:42 2018 +0100

    gsettings: split gschema.xml between the lib and the app
    
    For the new ID, have a more flat structure. "state.main.contents" is a
    bit long and not very useful, replace it by "contents".
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784351

 data/Makefile.am                        |    4 +++-
 data/org.gnome.devhelp.gschema.xml      |   13 -------------
 data/org.gnome.libdevhelp-3.gschema.xml |   17 +++++++++++++++++
 devhelp/dh-settings.c                   |   17 +++++++++++++++--
 po/POTFILES.in                          |    1 +
 5 files changed, 36 insertions(+), 16 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 3049cb5..7050086 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -8,7 +8,9 @@ assistant_DATA =                \
        assistant.js            \
        assistant.css
 
-gsettings_SCHEMAS = org.gnome.devhelp.gschema.xml
+gsettings_SCHEMAS =                            \
+       org.gnome.devhelp.gschema.xml           \
+       org.gnome.libdevhelp-3.gschema.xml
 @GSETTINGS_RULES@
 
 appstream_in_files = org.gnome.Devhelp.appdata.xml.in
diff --git a/data/org.gnome.devhelp.gschema.xml b/data/org.gnome.devhelp.gschema.xml
index 030f95c..e3d058a 100644
--- a/data/org.gnome.devhelp.gschema.xml
+++ b/data/org.gnome.devhelp.gschema.xml
@@ -10,7 +10,6 @@
   <schema id="org.gnome.devhelp.state.main" path="/org/gnome/devhelp/state/main/">
     <child name="window" schema="org.gnome.devhelp.state.main.window"/>
     <child name="paned" schema="org.gnome.devhelp.state.main.paned"/>
-    <child name="contents" schema="org.gnome.devhelp.state.main.contents"/>
   </schema>
   <schema id="org.gnome.devhelp.state.main.window" path="/org/gnome/devhelp/state/main/window/">
     <key name="maximized" type="b">
@@ -36,18 +35,6 @@
       <description>The width of the index and search pane.</description>
     </key>
   </schema>
-  <schema id="org.gnome.devhelp.state.main.contents" path="/org/gnome/devhelp/state/main/contents/">
-    <key name="books-disabled" type="as">
-      <default>[]</default>
-      <summary>Books disabled</summary>
-      <description>List of books disabled by the user.</description>
-    </key>
-    <key name="group-books-by-language" type="b">
-      <default>false</default>
-      <summary>Group by language</summary>
-      <description>Whether books should be grouped by language in the UI</description>
-    </key>
-  </schema>
   <schema id="org.gnome.devhelp.state.assistant" path="/org/gnome/devhelp/state/assistant/">
     <child name="window" schema="org.gnome.devhelp.state.assistant.window"/>
   </schema>
diff --git a/data/org.gnome.libdevhelp-3.gschema.xml b/data/org.gnome.libdevhelp-3.gschema.xml
new file mode 100644
index 0000000..f557b10
--- /dev/null
+++ b/data/org.gnome.libdevhelp-3.gschema.xml
@@ -0,0 +1,17 @@
+<schemalist gettext-domain="devhelp">
+  <schema id="org.gnome.libdevhelp-3">
+    <child name="contents" schema="org.gnome.libdevhelp-3.contents"/>
+  </schema>
+  <schema id="org.gnome.libdevhelp-3.contents">
+    <key name="books-disabled" type="as">
+      <default>[]</default>
+      <summary>Books disabled</summary>
+      <description>List of books disabled by the user.</description>
+    </key>
+    <key name="group-books-by-language" type="b">
+      <default>false</default>
+      <summary>Group by language</summary>
+      <description>Whether books should be grouped by language in the UI</description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/devhelp/dh-settings.c b/devhelp/dh-settings.c
index 4bc4845..a2b5223 100644
--- a/devhelp/dh-settings.c
+++ b/devhelp/dh-settings.c
@@ -21,9 +21,9 @@
 #include "dh-settings.h"
 
 /* Devhelp GSettings schema IDs */
+#define SETTINGS_SCHEMA_ID_CONTENTS             "org.gnome.libdevhelp-3.contents"
 #define SETTINGS_SCHEMA_ID_WINDOW               "org.gnome.devhelp.state.main.window"
 #define SETTINGS_SCHEMA_ID_PANED                "org.gnome.devhelp.state.main.paned"
-#define SETTINGS_SCHEMA_ID_CONTENTS             "org.gnome.devhelp.state.main.contents"
 #define SETTINGS_SCHEMA_ID_ASSISTANT            "org.gnome.devhelp.state.assistant.window"
 #define SETTINGS_SCHEMA_ID_FONTS                "org.gnome.devhelp.fonts"
 
@@ -119,9 +119,22 @@ dh_settings_init (DhSettings *self)
 {
         self->priv = dh_settings_get_instance_private (self);
 
+        /* The GSettings schemas provided by the libdevhelp are relocatable.
+         * Different major versions of libdevhelp must be parallel-installable,
+         * so the schema IDs must be different (they must contain the API/major
+         * version). But for users to not lose all their settings when there is
+         * a new major version of libdevhelp, the schemas – if still
+         * compatible – are relocated to an old common path.
+         *
+         * If a schema becomes incompatible, the compatible keys can be migrated
+         * with dconf, with the DhDconfMigration utility class.
+         */
+        self->priv->settings_contents = g_settings_new_with_path (SETTINGS_SCHEMA_ID_CONTENTS,
+                                                                  /* Must be compatible with Devhelp app 
version 3.28. */
+                                                                  "/org/gnome/devhelp/state/main/contents/");
+
         self->priv->settings_window = g_settings_new (SETTINGS_SCHEMA_ID_WINDOW);
         self->priv->settings_paned = g_settings_new (SETTINGS_SCHEMA_ID_PANED);
-        self->priv->settings_contents = g_settings_new (SETTINGS_SCHEMA_ID_CONTENTS);
         self->priv->settings_assistant = g_settings_new (SETTINGS_SCHEMA_ID_ASSISTANT);
         self->priv->settings_fonts = g_settings_new (SETTINGS_SCHEMA_ID_FONTS);
         self->priv->settings_desktop_interface = g_settings_new (SETTINGS_SCHEMA_ID_DESKTOP_INTERFACE);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 85cd99b..c92128e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
 data/org.gnome.Devhelp.appdata.xml.in
 data/org.gnome.Devhelp.desktop.in.in
 data/org.gnome.devhelp.gschema.xml
+data/org.gnome.libdevhelp-3.gschema.xml
 devhelp/dh-assistant-view.c
 devhelp/dh-book.c
 devhelp/dh-book-manager.c


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