After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 641354 - Look for themes in XDG folders
Look for themes in XDG folders
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Carlos Garnacho
gtk-bugs
Depends on:
Blocks: 523057
 
 
Reported: 2011-02-03 15:16 UTC by Christian Dywan
Modified: 2016-03-22 09:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Also look in system data dirs for themes (2.61 KB, patch)
2016-03-17 04:37 UTC, Matthias Clasen
committed Details | Review
Load theme settings from the right location (5.76 KB, patch)
2016-03-17 05:05 UTC, Matthias Clasen
committed Details | Review

Description Christian Dywan 2011-02-03 15:16:11 UTC
Right now _gtk_css_provider_get_theme_dir only looks at GTK_DATA_PREFIX and doesn't honor XDG folders, ie. g_get_system_data_dirs().

See http://git.gnome.org/browse/gtk+/tree/gtk/gtkcssprovider.c#n4134
Comment 1 Matthias Clasen 2011-02-04 21:12:14 UTC
What I am missing here is an explanation of why it would be a good idea to look for themes in more places
Comment 2 William Jon McCann 2011-04-03 18:10:12 UTC
Moving data out of the home directory is a good thing.  It makes it easier to migrate data and allows one to relocate configuration data to even remote storage.
Comment 3 William Jon McCann 2011-04-03 18:12:07 UTC

*** This bug has been marked as a duplicate of bug 447840 ***
Comment 4 William Jon McCann 2011-04-03 18:38:38 UTC
Hmm I think I misunderstood.
Comment 5 Matthias Clasen 2012-04-24 10:25:57 UTC
Actually, we already look in XDG_CONFIG_HOME/gtk-3.0/gtk.css. The code for this is in http://git.gnome.org/browse/gtk+/tree/gtk/gtksettings.c#n1538

It would be good to test that this works as intended.
Comment 6 Adam Dingle 2013-12-14 13:52:43 UTC
I think GTK should look for themes in all directories in XDG_DATA_DIRS as Christian originally suggested.  That way I could install a theme locally (e.g. in /usr/local/share/themes or ~/local/share/themes) and GTK could still find it.
Comment 7 Adam Dingle 2013-12-16 17:20:58 UTC
Matthias, would you take a patch to look for themes in all XDG_DATA_DIRS?
Comment 8 Jookia 2016-03-14 06:25:20 UTC
Hey there! I've come to this bug report after dealing with the need to have XDG_DATA_DIRS support in GTK+.

In a system with a functional package manager like GuixSD or NixOS, everything outside of ~/home is generally immutable. Furthermore, these systems aren't FHS-compliant as each package lives in its own directory in what we call 'the store'. Installing a theme system-wide, it'd most likely end up in /run/current-system/profile/share/themes. But we also have ways for users to install packages in their own profiles, which usually can be found in ~/.guix-profile/share/themes. As a result we have no single location for themes.

I wrote a long discussion about our options for fixing this in GuixSD: https://lists.gnu.org/archive/html/guix-devel/2016-03/msg00492.html
It includes some patches that may be appropriate here, but I'd have to extract them from the Guix tree for you.

Luckily, XDG_DATA_DIRS covers those paths above and is also customizable by the user in case they want to try themes in a sandbox before installing it to their profile. In fact Xfce already reads this directory when looking for themes!

It'd be much appreciated if GTK+ started looking at XDG_DATA_DIRS for themes, it'd fix the issue in GuixSD and NixOS. It'd also mean people using Guix or Nix on other distributions would be able to use installed themes in those package managers.
Comment 9 Matthias Clasen 2016-03-17 04:37:02 UTC
Created attachment 324151 [details] [review]
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
Comment 10 Matthias Clasen 2016-03-17 05:05:35 UTC
Created attachment 324152 [details] [review]
Load theme settings from the right location

When loading a per-theme settings.ini file, look for it in
the same directory where we found the gtk.css file for the
theme. Previously, we were always looking in
$prefix/share/themes/THEME/gtk-3.0/, even if the css was
loaded from somewhere else.
Comment 11 Matthias Clasen 2016-03-21 01:10:00 UTC
Review of attachment 324151 [details] [review]:

.
Comment 12 Matthias Clasen 2016-03-21 01:10:15 UTC
Review of attachment 324151 [details] [review]:

.
Comment 13 Matthias Clasen 2016-03-22 02:48:40 UTC
Attachment 324151 [details] pushed as 475d916 - Also look in system data dirs for themes
Attachment 324152 [details] pushed as 7cb36ab - Load theme settings from the right location
Comment 14 Jookia 2016-03-22 09:42:24 UTC
Wow, thanks for the fast response and fix! One thing I'd like to note is that the inspector also looks for themes, perhaps this could cause some confusion since it's not patched?

Jookia.