diff --git a/subprojects/extensions-tool/src/command-create.c b/subprojects/extensions-tool/src/command-create.c index 722a9f4c7..879047cb2 100644 --- a/subprojects/extensions-tool/src/command-create.c +++ b/subprojects/extensions-tool/src/command-create.c @@ -182,6 +182,42 @@ create_metadata (GFile *target_dir, error); } +static gboolean +create_settings_schema (GFile *target_dir, + const char *settings_schema, + GError **error) +{ + g_autoptr (GFile) schema_dir = NULL; + g_autoptr (GFile) schema = NULL; + g_autofree char *schema_filename = NULL; + g_autofree char *schema_path = NULL; + g_autofree char *xml = NULL; + + schema_dir = g_file_get_child (target_dir, "schemas"); + if (!g_file_make_directory (schema_dir, NULL, error)) + return FALSE; + + schema_filename = g_strdup_printf ("%s.gschema.xml", settings_schema); + schema = g_file_get_child (schema_dir, schema_filename); + + schema_path = g_strconcat ("/", settings_schema, "/", NULL); + g_strdelimit (schema_path, ".", '/'); + + xml = g_strdup_printf ("\n" + " \n" + " \n" + "\n", settings_schema, schema_path); + + return g_file_replace_contents (schema, + xml, + strlen (xml), + NULL, + FALSE, + 0, + NULL, + NULL, + error); +} static gboolean copy_extension_template (const char *template, GFile *target_dir, GError **error) @@ -272,6 +308,12 @@ create_extension (const char *uuid, return FALSE; } + if (settings_schema && !create_settings_schema (dir, settings_schema, &error)) + { + g_printerr ("%s\n", error->message); + return FALSE; + } + if (!copy_extension_template (template, dir, &error)) { g_printerr ("%s\n", error->message);