Merge branch 'issue-1998-gsettings-schema-dir-env-var-multiple-dirs' into 'master'

Support multiple directories in GSETTINGS_SCHEMA_DIR

Closes #1998

See merge request GNOME/glib!1315
This commit is contained in:
Philip Withnall 2020-01-16 11:16:13 +00:00
commit 3499bd7713
2 changed files with 13 additions and 5 deletions

View File

@ -466,10 +466,9 @@ Gvfs is also heavily distributed and relies on a session bus to be present.
<title><envar>GSETTINGS_SCHEMA_DIR</envar></title> <title><envar>GSETTINGS_SCHEMA_DIR</envar></title>
<para> <para>
This variable can be set to the name of a directory that is This variable can be set to the names of directories to consider when looking for compiled schemas for #GSettings,
considered in addition to the <filename>glib-2.0/schemas</filename> in addition to the <filename>glib-2.0/schemas</filename>
subdirectories of the XDG system data dirs when looking subdirectories of the XDG system data dirs. To specify multiple directories, use <constant>G_SEARCHPATH_SEPARATOR_S</constant> as a separator.
for compiled schemas for #GSettings.
</para> </para>
</formalpara> </formalpara>

View File

@ -345,6 +345,7 @@ initialise_schema_sources (void)
{ {
const gchar * const *dirs; const gchar * const *dirs;
const gchar *path; const gchar *path;
gchar **extra_schema_dirs;
gint i; gint i;
/* iterate in reverse: count up, then count down */ /* 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 ()); try_prepend_data_dir (g_get_user_data_dir ());
if ((path = g_getenv ("GSETTINGS_SCHEMA_DIR")) != NULL) 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); g_once_init_leave (&initialised, TRUE);
} }