Support multiple directories in GSETTINGS_SCHEMA_DIR

This adds support for specifying multiple directories in the
GSETTINGS_SCHEMA_DIR environment variable by separating the values
using G_SEARCHPATH_SEPARATOR_S (colon on UNIX-like systems).

While programs could already register multiple custom GSettings schema
directories, it was not possible to achieve the same without writing
custom code, e.g. when using the gsettings command line tool.

Fixes #1998.
This commit is contained in:
wouter bolsterlee
2020-01-10 19:39:10 +01:00
committed by Philip Withnall
parent 321fea1c5e
commit 809a9210c3
2 changed files with 13 additions and 5 deletions

View File

@@ -345,6 +345,7 @@ initialise_schema_sources (void)
{
const gchar * const *dirs;
const gchar *path;
gchar **extra_schema_dirs;
gint i;
/* iterate in reverse: count up, then count down */
@@ -357,7 +358,15 @@ initialise_schema_sources (void)
try_prepend_data_dir (g_get_user_data_dir ());
if ((path = g_getenv ("GSETTINGS_SCHEMA_DIR")) != NULL)
try_prepend_dir (path);
{
extra_schema_dirs = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 0);
for (i = 0; extra_schema_dirs[i]; i++);
while (i--)
try_prepend_dir (extra_schema_dirs[i]);
g_strfreev (extra_schema_dirs);
}
g_once_init_leave (&initialised, TRUE);
}