summaryrefslogtreecommitdiffstats
path: root/pkgs/test
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2022-12-15 21:20:40 +0100
committerJan Tojnar <jtojnar@gmail.com>2022-12-19 17:38:57 +0100
commit4346dee4243e2f3b900b710cf800a1ee7309d2b1 (patch)
tree09f61b513244f919f37b5433aa973c7445262af9 /pkgs/test
parent98e84e79a97155cf748cbca8d1abbd56038c11f9 (diff)
makeHardcodeGsettingsPatch: Support other constructors
In addition to `g_settings_new`, there are three other GSettings constructors: https://docs.gtk.org/gio/ctor.Settings.new.html
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/make-hardcode-gsettings-patch/default.nix1
-rw-r--r--pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project-patched/main.c39
-rw-r--r--pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project/main.c21
3 files changed, 61 insertions, 0 deletions
diff --git a/pkgs/test/make-hardcode-gsettings-patch/default.nix b/pkgs/test/make-hardcode-gsettings-patch/default.nix
index a1339ffb2bc4..6c5d2318c6d8 100644
--- a/pkgs/test/make-hardcode-gsettings-patch/default.nix
+++ b/pkgs/test/make-hardcode-gsettings-patch/default.nix
@@ -51,6 +51,7 @@ in
schemaIdToVariableMapping = {
"org.gnome.evolution-data-server.addressbook" = "EDS";
"org.gnome.evolution.calendar" = "EVO";
+ "org.gnome.seahorse.nautilus.window" = "SEANAUT";
};
expected = ./fixtures/example-project-patched;
};
diff --git a/pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project-patched/main.c b/pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project-patched/main.c
index 42eeeca58494..7822a42b840a 100644
--- a/pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project-patched/main.c
+++ b/pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project-patched/main.c
@@ -37,10 +37,49 @@ void schema_id_autoptr() {
}
}
+void schema_id_with_backend() {
+ GSettings *settings;
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@EDS@", g_settings_schema_source_get_default(), TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source, "org.gnome.evolution-data-server.addressbook", FALSE);
+ settings = g_settings_new_full(schema, g_settings_backend_get_default(), NULL);
+ }
+ g_object_unref(settings);
+}
+
+void schema_id_with_backend_and_path() {
+ GSettings *settings;
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@SEANAUT@", g_settings_schema_source_get_default(), TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source, "org.gnome.seahorse.nautilus.window", FALSE);
+ settings = g_settings_new_full(schema, g_settings_backend_get_default(), "/org/gnome/seahorse/nautilus/windows/123/");
+ }
+ g_object_unref(settings);
+}
+
+void schema_id_with_path() {
+ GSettings *settings;
+ {
+ g_autoptr(GSettingsSchemaSource) schema_source;
+ g_autoptr(GSettingsSchema) schema;
+ schema_source = g_settings_schema_source_new_from_directory("@SEANAUT@", g_settings_schema_source_get_default(), TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source, "org.gnome.seahorse.nautilus.window", FALSE);
+ settings = g_settings_new_full(schema, NULL, "/org/gnome/seahorse/nautilus/windows/123/");
+ }
+ g_object_unref(settings);
+}
+
int main() {
schema_id_literal();
schema_id_from_constant();
schema_id_autoptr();
+ schema_id_with_backend();
+ schema_id_with_backend_and_path();
+ schema_id_with_path();
return 0;
}
diff --git a/pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project/main.c b/pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project/main.c
index d83dc09e124e..afcb3686ec84 100644
--- a/pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project/main.c
+++ b/pkgs/test/make-hardcode-gsettings-patch/fixtures/example-project/main.c
@@ -19,10 +19,31 @@ void schema_id_autoptr() {
settings = g_settings_new("org.gnome.evolution.calendar");
}
+void schema_id_with_backend() {
+ GSettings *settings;
+ settings = g_settings_new_with_backend("org.gnome.evolution-data-server.addressbook", g_settings_backend_get_default());
+ g_object_unref(settings);
+}
+
+void schema_id_with_backend_and_path() {
+ GSettings *settings;
+ settings = g_settings_new_with_backend_and_path("org.gnome.seahorse.nautilus.window", g_settings_backend_get_default(), "/org/gnome/seahorse/nautilus/windows/123/");
+ g_object_unref(settings);
+}
+
+void schema_id_with_path() {
+ GSettings *settings;
+ settings = g_settings_new_with_path("org.gnome.seahorse.nautilus.window", "/org/gnome/seahorse/nautilus/windows/123/");
+ g_object_unref(settings);
+}
+
int main() {
schema_id_literal();
schema_id_from_constant();
schema_id_autoptr();
+ schema_id_with_backend();
+ schema_id_with_backend_and_path();
+ schema_id_with_path();
return 0;
}