aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/frameworks/7 gnome/schemas/schemaprog.c
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/frameworks/7 gnome/schemas/schemaprog.c
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/frameworks/7 gnome/schemas/schemaprog.c')
-rw-r--r--meson/test cases/frameworks/7 gnome/schemas/schemaprog.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/meson/test cases/frameworks/7 gnome/schemas/schemaprog.c b/meson/test cases/frameworks/7 gnome/schemas/schemaprog.c
new file mode 100644
index 000000000..17dab6514
--- /dev/null
+++ b/meson/test cases/frameworks/7 gnome/schemas/schemaprog.c
@@ -0,0 +1,47 @@
+#include<gio/gio.h>
+#include<stdio.h>
+#include<string.h>
+
+int main(int argc, char **argv) {
+ GSettingsSchemaSource *src;
+ GSettingsSchema *schema;
+ GSettings *settings;
+ GVariant *value;
+
+ GError *error = NULL;
+ src = g_settings_schema_source_new_from_directory("schemas",
+ g_settings_schema_source_get_default(), TRUE, &error);
+ if(error) {
+ fprintf(stderr, "Fail: %s\n", error->message);
+ g_error_free(error);
+ return 1;
+ }
+
+ schema = g_settings_schema_source_lookup(src, "com.github.meson", FALSE);
+ if(!schema) {
+ fprintf(stderr, "Could not get schema from source.\n");
+ return 2;
+ }
+
+ settings = g_settings_new_full(schema, NULL, NULL);
+ if(!settings) {
+ fprintf(stderr, "Could not get settings object.\n");
+ return 3;
+ }
+
+ value = g_settings_get_value(settings, "greeting");
+ if(!value) {
+ fprintf(stderr, "Could not get value from settings.\n");
+ return 4;
+ }
+
+ if(strcmp("Hello", g_variant_get_string(value, NULL)) != 0) {
+ fprintf(stderr, "Value of setting is incorrect.\n");
+ return 5;
+ }
+ g_variant_unref(value);
+ g_object_unref(settings);
+ g_settings_schema_unref(schema);
+ g_settings_schema_source_unref(src);
+ return 0;
+}