parent
d2cb344c91
commit
8ae740bb83
5 changed files with 88 additions and 1 deletions
@ -0,0 +1,12 @@ |
||||
<schemalist> |
||||
<schema id="com.github.meson" path="/com/github/meson/" gettext-domain="test"> |
||||
|
||||
<key name="greeting" type="s"> |
||||
<default l10n="messages">"Hello"</default> |
||||
<summary>A greeting</summary> |
||||
<description> |
||||
Sample text to test schema compilation |
||||
</description> |
||||
</key> |
||||
</schema> |
||||
</schemalist> |
@ -1 +1,2 @@ |
||||
usr/typelibdir/Meson-1.0.typelib |
||||
usr/typelibdir/Meson-1.0.typelib |
||||
usr/share/glib-2.0/schemas/com.github.meson.gschema.xml |
||||
|
@ -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(".", |
||||
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; |
||||
} |
Loading…
Reference in new issue