Parse user CSS from $XDG_CONFIG_HOME/gtk-3.0/gtk.css

This commit is contained in:
Carlos Garnacho 2010-12-01 02:55:31 +01:00
parent 9bdb7e6945
commit 066f35bf28
4 changed files with 13 additions and 11 deletions

View File

@ -47,7 +47,7 @@
* calling gtk_css_provider_load_from_file() and adding the provider with
* gtk_style_context_add_provider() or gtk_style_context_add_provider_for_screen().
* In addition, certain files will be read when GTK+ is initialized. First,
* the file <filename><replaceable>HOME</replaceable>/.gtk-3.0.css</filename>
* the file <filename><replaceable>XDG_CONFIG_HOME</replaceable>/gtk-3.0/gtk.css</filename>
* is loaded if it exists. Then, GTK+ tries to load
* <filename><replaceable>HOME</replaceable>/.themes/<replaceable>theme-name</replaceable>/gtk-3.0/gtk.css</filename>,
* falling back to

View File

@ -1354,18 +1354,19 @@ settings_init_style (GtkSettings *settings)
/* Add provider for user file */
if (G_UNLIKELY (!css_provider))
{
GFile *home_dir, *css_file;
gchar *css_path;
css_provider = gtk_css_provider_new ();
css_path = g_build_filename (g_get_user_config_dir (),
"gtk-3.0",
"gtk.css",
NULL);
home_dir = g_file_new_for_path (g_get_home_dir ());
css_file = g_file_get_child (home_dir, ".gtk-3.0.css");
if (g_file_test (css_path,
G_FILE_TEST_IS_REGULAR))
gtk_css_provider_load_from_path (css_provider, css_path, NULL);
if (g_file_query_exists (css_file, NULL))
gtk_css_provider_load_from_file (css_provider, css_file, NULL);
g_object_unref (home_dir);
g_object_unref (css_file);
g_free (css_path);
}
gtk_style_context_add_provider_for_screen (settings->screen,

View File

@ -390,7 +390,8 @@
* If you are using custom styling on an applications, you probably want then
* to make your style information prevail to the theme's, so you must use
* a #GtkStyleProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
* priority, keep in mind that the user settings in $HOME/.gtk-3.0.css will
* priority, keep in mind that the user settings in
* <filename><replaceable>XDG_CONFIG_HOME</replaceable>/gtk-3.0/gtk.css</filename> will
* still take precedence over your changes, as it uses the
* %GTK_STYLE_PROVIDER_PRIORITY_USER priority.
* </para>

View File

@ -72,7 +72,7 @@ G_BEGIN_DECLS
* GTK_STYLE_PROVIDER_PRIORITY_USER:
*
* The priority used for the style information from
* <filename>~/.gtk-3.0.css</filename>.
* <filename><replaceable>XDG_CONFIG_HOME</replaceable>/gtk-3.0/gtk.css</filename>
*
* You should not use priorities higher than this, to
* give the user the last word.