[gnome-builder] libide/core: add relocatable path-suffix settings loading
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/core: add relocatable path-suffix settings loading
- Date: Sun, 28 Aug 2022 18:30:37 +0000 (UTC)
commit 07b0f4dfc73c901e1478e547cfe0ce96a180846f
Author: Christian Hergert <chergert redhat com>
Date: Sun Aug 28 11:27:58 2022 -0700
libide/core: add relocatable path-suffix settings loading
src/libide/core/ide-settings.c | 34 ++++++++++++++++++++++++++++++++--
src/libide/core/ide-settings.h | 4 ++++
2 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/core/ide-settings.c b/src/libide/core/ide-settings.c
index 33a95e741..d55885c35 100644
--- a/src/libide/core/ide-settings.c
+++ b/src/libide/core/ide-settings.c
@@ -53,6 +53,7 @@ struct _IdeSettings
char *schema_id;
char *project_id;
char *path;
+ char *path_suffix;
};
static void action_group_iface_init (GActionGroupInterface *iface);
@@ -63,6 +64,7 @@ G_DEFINE_FINAL_TYPE_WITH_CODE (IdeSettings, ide_settings, G_TYPE_OBJECT,
enum {
PROP_0,
PROP_PATH,
+ PROP_PATH_SUFFIX,
PROP_PROJECT_ID,
PROP_SCHEMA_ID,
N_PROPS
@@ -201,7 +203,7 @@ ide_settings_constructed (GObject *object)
}
else
{
- if (!(self->path = ide_settings_resolve_schema_path (self->schema_id, NULL, NULL)))
+ if (!(self->path = ide_settings_resolve_schema_path (self->schema_id, NULL, self->path_suffix)))
g_error ("Failed to generate application path for %s", self->schema_id);
}
@@ -221,7 +223,7 @@ ide_settings_constructed (GObject *object)
/* Add project layer if we need one */
if (relocatable && self->project_id != NULL)
{
- g_autofree char *project_path = ide_settings_resolve_schema_path (self->schema_id, self->project_id,
NULL);
+ g_autofree char *project_path = ide_settings_resolve_schema_path (self->schema_id, self->project_id,
self->path_suffix);
g_autoptr(GSettings) project_settings = g_settings_new_with_path (self->schema_id, project_path);
ide_layered_settings_append (self->layered_settings, project_settings);
@@ -243,6 +245,7 @@ ide_settings_finalize (GObject *object)
g_clear_pointer (&self->schema_id, g_free);
g_clear_pointer (&self->project_id, g_free);
g_clear_pointer (&self->path, g_free);
+ g_clear_pointer (&self->path_suffix, g_free);
G_OBJECT_CLASS (ide_settings_parent_class)->finalize (object);
}
@@ -261,6 +264,10 @@ ide_settings_get_property (GObject *object,
g_value_set_string (value, self->path);
break;
+ case PROP_PATH_SUFFIX:
+ g_value_set_string (value, self->path_suffix);
+ break;
+
case PROP_PROJECT_ID:
g_value_set_string (value, self->project_id);
break;
@@ -288,6 +295,10 @@ ide_settings_set_property (GObject *object,
self->path = g_value_dup_string (value);
break;
+ case PROP_PATH_SUFFIX:
+ self->path_suffix = g_value_dup_string (value);
+ break;
+
case PROP_PROJECT_ID:
self->project_id = g_value_dup_string (value);
break;
@@ -318,6 +329,13 @@ ide_settings_class_init (IdeSettingsClass *klass)
NULL,
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ properties [PROP_PATH_SUFFIX] =
+ g_param_spec_string ("path-suffix",
+ "Path Suffix",
+ "A path suffix to append when generating schema paths",
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
properties [PROP_PROJECT_ID] =
g_param_spec_string ("project-id",
"Project Id",
@@ -728,3 +746,15 @@ action_group_iface_init (GActionGroupInterface *iface)
iface->change_action_state = ide_settings_change_action_state;
iface->activate_action = ide_settings_activate_action;
}
+
+IdeSettings *
+ide_settings_new_relocatable_with_suffix (const char *project_id,
+ const char *schema_id,
+ const char *path_suffix)
+{
+ return g_object_new (IDE_TYPE_SETTINGS,
+ "project-id", project_id,
+ "schema-id", schema_id,
+ "path-suffix", path_suffix,
+ NULL);
+}
diff --git a/src/libide/core/ide-settings.h b/src/libide/core/ide-settings.h
index b3c07748d..be88ebdb9 100644
--- a/src/libide/core/ide-settings.h
+++ b/src/libide/core/ide-settings.h
@@ -47,6 +47,10 @@ IdeSettings *ide_settings_new_with_path (const char *
const char *schema_id,
const char *path);
IDE_AVAILABLE_IN_ALL
+IdeSettings *ide_settings_new_relocatable_with_suffix (const char *project_id,
+ const char *schema_id,
+ const char *path_suffix);
+IDE_AVAILABLE_IN_ALL
const char *ide_settings_get_schema_id (IdeSettings *self);
IDE_AVAILABLE_IN_ALL
GVariant *ide_settings_get_default_value (IdeSettings *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]