[gtk+] Also look in system data dirs for themes



commit 475d916eb92c0106d09525bcca938f05fd6a81b5
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Mar 17 00:32:53 2016 -0400

    Also look in system data dirs for themes
    
    With this change, we now look in
    $XDG_DATA_HOME/themes/THEME/gtk-3.x
    $HOME/.themes/THEME/gtk-3.x
    $XDG_DATA_DIRS/themes/THEME/gtk-3.x
    GTK_DATA_PREFIX/themes/THEME/gtk-3.x
    
    https://bugzilla.gnome.org/show_bug.cgi?id=641354

 gtk/gtkcssprovider.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index ec2982b..0057ad2 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -61,12 +61,15 @@
  * gtk_style_context_add_provider_for_screen().
 
  * In addition, certain files will be read when GTK+ is initialized. First, the
- * file $XDG_CONFIG_HOME/gtk-3.0/gtk.css` is loaded if it exists. Then, GTK+ tries
- * to load `$HOME/.themes/theme-name/gtk-3.0/gtk.css`, falling back to
+ * file $XDG_CONFIG_HOME/gtk-3.0/gtk.css` is loaded if it exists. Then, GTK+
+ * loads the first existing file among
+ * `XDG_DATA_HOME/themes/theme-name/gtk-VERSION/gtk.css`,
+ * `$HOME/.themes/theme-name/gtk-VERSION/gtk.css`,
+ * `$XDG_DATA_DIRS/themes/theme-name/gtk-VERSION/gtk.css` and
  * `DATADIR/share/themes/THEME/gtk-VERSION/gtk.css`, where THEME is the name of
  * the current theme (see the #GtkSettings:gtk-theme-name setting), DATADIR
- * is the prefix configured when GTK+ was compiled, unless overridden by the
- * `GTK_DATA_PREFIX` environment variable, and VERSION is the GTK+ version number.
+ * is the prefix configured when GTK+ was compiled (unless overridden by the
+ * `GTK_DATA_PREFIX` environment variable), and VERSION is the GTK+ version number.
  * If no file is found for the current version, GTK+ tries older versions all the
  * way back to 3.0.
  *
@@ -2056,8 +2059,10 @@ _gtk_css_find_theme (const gchar *name,
 {
   gchar *path;
   const gchar *var;
+  const char *const *dirs;
+  int i;
 
-  /* First look in the user's config directory */
+  /* First look in the user's data directory */
   path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name, variant);
   if (path)
     return path;
@@ -2067,6 +2072,15 @@ _gtk_css_find_theme (const gchar *name,
   if (path)
     return path;
 
+  /* Look in system data directories */
+  dirs = g_get_system_data_dirs ();
+  for (i = 0; dirs[i]; i++)
+    {
+      path = _gtk_css_find_theme_dir (dirs[i], "themes", name, variant);
+      if (path)
+        return path;
+    }
+
   /* Finally, try in the default theme directory */
   var = g_getenv ("GTK_DATA_PREFIX");
   if (!var)


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