···33 * where GSettings system could look for schemas, we need to point the software to a correct location somehow.
44 * For executables, we handle this using wrappers but this is not an option for libraries like e-d-s.
55 * Instead, we hardcode the schema path when creating the settings.
66+ * A schema path (ie org.gnome.evolution) can be replaced by @EVOLUTION_SCHEMA_PATH@
77+ * which is then replaced at build time by substituteAll.
88+ * The mapping is provided in a json file ./glib-schema-to-var.json
69 */
710811@initialize:python@
912@@
1313+import json
10141115cpp_constants = {}
1216···1620def resolve_cpp_constant(const_name):
1721 return cpp_constants.get(const_name, const_name)
18221919-e_s_d_schema_constants = [
2020- # The following are actually part of e-d-s, despite the name.
2121- # We rename the old ambiguos constant name in ./prepare-for-gsettings-patching.patch
2222- "\"org.gnome.Evolution.DefaultSources\"",
2323- "\"org.gnome.evolution.shell.network-config\"",
2424-]
2525-2626-g_d_s_schema_constants = [
2727-]
2323+with open("./glib-schema-to-var.json") as mapping_file:
2424+ schema_to_var = json.load(mapping_file);
28252926def get_schema_directory(schema_path):
3027 # Sometimes the schema id is referenced using C preprocessor #define constant in the same file
3128 # let’s try to resolve it first.
3232- schema_path = resolve_cpp_constant(schema_path.strip())
3333- if schema_path.startswith("\"org.gnome.evolution-data-server") or schema_path in e_s_d_schema_constants:
3434- return "\"@EDS_GSETTINGS_PATH@\""
3535- elif schema_path in g_d_s_schema_constants:
3636- return "\"@GDS_GSETTINGS_PATH@\""
3737- raise Exception(f"Unknown schema path {schema_path}")
2929+ schema_path = resolve_cpp_constant(schema_path.strip()).strip('"')
3030+ if schema_path in schema_to_var:
3131+ return f'"@{schema_to_var[schema_path]}@"'
3232+ raise Exception(f"Unknown schema path {schema_path!r}, please add it to ./glib-schema-to-var.json")
383339344035@find_cpp_constants@