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



commit 066f35bf2883edcb394f55bbb24fd2a326b99ddc
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Dec 1 02:55:31 2010 +0100

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

 gtk/gtkcssprovider.c   |    2 +-
 gtk/gtksettings.c      |   17 +++++++++--------
 gtk/gtkstylecontext.c  |    3 ++-
 gtk/gtkstyleprovider.h |    2 +-
 4 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 35e94e8..f178905 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -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
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 58fd2c1..f57924b 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -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,
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index c458c24..6525540 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -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>
diff --git a/gtk/gtkstyleprovider.h b/gtk/gtkstyleprovider.h
index 1e59989..731c346 100644
--- a/gtk/gtkstyleprovider.h
+++ b/gtk/gtkstyleprovider.h
@@ -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.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]