[devhelp] SettingsBuilder: have default paths
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] SettingsBuilder: have default paths
- Date: Mon, 2 Apr 2018 12:14:22 +0000 (UTC)
commit 031688a298e0bf575c36455ff4503394e48febc3
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Apr 2 14:00:15 2018 +0200
SettingsBuilder: have default paths
devhelp/dh-settings-builder.c | 34 ++++++++++++++++++++++++++++++----
devhelp/dh-settings.c | 17 ++---------------
2 files changed, 32 insertions(+), 19 deletions(-)
---
diff --git a/devhelp/dh-settings-builder.c b/devhelp/dh-settings-builder.c
index 28edc13..bc7745d 100644
--- a/devhelp/dh-settings-builder.c
+++ b/devhelp/dh-settings-builder.c
@@ -28,15 +28,28 @@
* #DhSettingsBuilder permits to build #DhSettings objects. Once a #DhSettings
* object is created, it is immutable.
*
- * The #GSettings schemas installed by the libdevhelp are relocatable. So the
- * paths need to be provided.
+ * The #GSettings schemas provided by the libdevhelp are relocatable. So the
+ * paths need to be provided. If a path for a certain schema is not provided to
+ * the #DhSettingsBuilder with the set function, the default path for that
+ * schema will be used. The default paths are the paths common with the Devhelp
+ * application.
+ *
+ * Why are the schemas relocatable? Because different major versions of
+ * libdevhelp must be parallel-installable, so the schema IDs must necessarily
+ * 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 – can be relocated to an old common path
+ * (common to several major versions of libdevhelp or to an application). If a
+ * schema becomes incompatible, the compatible keys can be migrated individually
+ * with dconf (see the DhDconfMigration utility class in the libdevhelp source
+ * code).
*/
/* API design:
*
- * Follow the builder pattern, see:
+ * It follows the builder pattern, see:
* https://blogs.gnome.org/otte/2018/02/03/builders/
- * but implement it in a simpler way, to have less boilerplate.
+ * but it is implemented in a simpler way, to have less boilerplate.
*/
struct _DhSettingsBuilderPrivate {
@@ -67,6 +80,14 @@ static void
dh_settings_builder_init (DhSettingsBuilder *builder)
{
builder->priv = dh_settings_builder_get_instance_private (builder);
+
+ /* Set default paths.
+ * Use all the set functions to test those code paths, instead of
+ * calling g_strdup() directly.
+ */
+
+ // Must be compatible with Devhelp app version 3.28:
+ dh_settings_builder_set_contents_path (builder, "/org/gnome/devhelp/state/main/contents/");
}
/**
@@ -86,6 +107,11 @@ dh_settings_builder_new (void)
* @builder: a #DhSettingsBuilder.
* @contents_path: the path for the "contents" schema.
*
+ * Sets the path for the "contents" schema.
+ *
+ * If this function is not called, the default path for this schema will be
+ * used.
+ *
* Since: 3.30
*/
void
diff --git a/devhelp/dh-settings.c b/devhelp/dh-settings.c
index 49a9f8a..46e7b7f 100644
--- a/devhelp/dh-settings.c
+++ b/devhelp/dh-settings.c
@@ -82,18 +82,9 @@ _dh_settings_new (const gchar *contents_path)
{
DhSettings *object;
- object = g_object_new (DH_TYPE_SETTINGS, NULL);
+ g_return_val_if_fail (contents_path != NULL, NULL);
- /* 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.
- */
+ object = g_object_new (DH_TYPE_SETTINGS, NULL);
object->priv->settings_contents = g_settings_new_with_path (SETTINGS_SCHEMA_ID_CONTENTS,
contents_path);
@@ -113,10 +104,6 @@ dh_settings_get_default (void)
DhSettingsBuilder *builder;
builder = dh_settings_builder_new ();
-
- /* Must be compatible with Devhelp app version 3.28: */
- dh_settings_builder_set_contents_path (builder, "/org/gnome/devhelp/state/main/contents/");
-
default_instance = dh_settings_builder_create_object (builder);
g_object_unref (builder);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]