Load settings.ini also from XDG_CONFIG_DIRS

https://bugzilla.gnome.org/show_bug.cgi?id=683874
This commit is contained in:
Ignacio Casal Quinteiro 2012-09-12 16:10:56 +02:00 committed by Matthias Clasen
parent e64317f8e1
commit 909873bc6f

View File

@ -71,7 +71,9 @@
* utilities that let the user change these settings. In the absence of * utilities that let the user change these settings. In the absence of
* an Xsettings manager, GTK+ reads default values for settings from * an Xsettings manager, GTK+ reads default values for settings from
* <filename>settings.ini</filename> files in * <filename>settings.ini</filename> files in
* <filename>/etc/gtk-3.0</filename> and <filename>$XDG_CONFIG_HOME/gtk-3.0</filename>. These files must be valid key files (see #GKeyFile), and have * <filename>/etc/gtk-3.0</filename>, <filename>$XDG_CONFIG_DIRS/gtk-3.0</filename>
* and <filename>$XDG_CONFIG_HOME/gtk-3.0</filename>.
* These files must be valid key files (see #GKeyFile), and have
* a section called Settings. Themes can also provide default values * a section called Settings. Themes can also provide default values
* for settings by installing a <filename>settings.ini</filename> file * for settings by installing a <filename>settings.ini</filename> file
* next to their <filename>gtk.css</filename> file. * next to their <filename>gtk.css</filename> file.
@ -277,6 +279,8 @@ gtk_settings_init (GtkSettings *settings)
GParamSpec **pspecs, **p; GParamSpec **pspecs, **p;
guint i = 0; guint i = 0;
gchar *path; gchar *path;
const gchar * const *config_dirs;
const gchar *config_dir;
priv = G_TYPE_INSTANCE_GET_PRIVATE (settings, priv = G_TYPE_INSTANCE_GET_PRIVATE (settings,
GTK_TYPE_SETTINGS, GTK_TYPE_SETTINGS,
@ -319,6 +323,15 @@ gtk_settings_init (GtkSettings *settings)
gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT); gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
g_free (path); g_free (path);
config_dirs = g_get_system_config_dirs ();
for (config_dir = *config_dirs; *config_dirs != NULL; config_dirs++)
{
path = g_build_filename (config_dir, "gtk-3.0", "settings.ini", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
g_free (path);
}
path = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "settings.ini", NULL); path = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "settings.ini", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS)) if (g_file_test (path, G_FILE_TEST_EXISTS))
gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT); gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);