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 650971 - User-Theme extension causes other extensions to ignore CSS rules
User-Theme extension causes other extensions to ignore CSS rules
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
3.0.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
: 649742 651386 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-05-24 13:47 UTC by Alin Andrei
Modified: 2011-06-15 19:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
StTheme: retrive the list of custom stylesheets and use it in loadTheme() (3.25 KB, patch)
2011-06-02 15:07 UTC, Giovanni Campagna
committed Details | Review

Description Alin Andrei 2011-05-24 13:47:57 UTC
When using the User-Theme extension, other extensions don't respect the CSS rules in their .css file anymore.

Here's a screenshot with an extension before installing the user-theme extension:http://lh3.googleusercontent.com/_1QSDkzYY2vc/TdpoBypFL_I/AAAAAAAAEh0/BjQ6kq5RUWc/gnome-shell-weather-extension.png

And here's a screenshot after installing user-theme extension: http://i.imgur.com/WhwoW.png

This doesn't happen just with the extension in the screenshot but with all extensions that display something on the panel and require CSS. However, if you want to take a look at the css for the extension in the screenshot, see here: https://github.com/simon04/gnome-shell-extension-weather

I've tried this on two Fedora 15 systems with the same result.
Comment 1 Florian Mounier 2011-05-25 08:57:30 UTC
I can confirm this on archlinux with gnome shell 3.0.1
User-theme hides local extensions css class.
Comment 2 John Stowers 2011-05-25 21:39:42 UTC
(In reply to comment #1)
> I can confirm this on archlinux with gnome shell 3.0.1
> User-theme hides local extensions css class.

Any idea why? The user-theme extension is 50 lines of code that doesnt do anything other than set the path to the shell-theme stylesheet [1]. Its interaction with gnome shell is limited to Main.setThemeStylesheet(_stylesheet).

The problem must be in the shell or shell-toolkit

[1] http://git.gnome.org/browse/gnome-shell-extensions/tree/extensions/user-theme/extension.js
Comment 3 Alin Andrei 2011-05-25 21:52:34 UTC
@John: it could be, I'm not a developer so I don't really know. What's certain is that the user-theme extension triggers this somehow.

(I've tried it on a fresh install too with just one extension that uses CSS, with and without the user-theme extension to make sure).
Comment 4 Florian Müllner 2011-05-25 21:56:16 UTC
Without looking into it too deeply, this is what I think is happening:

Extensions' stylesheets are added to the active theme. When the user-theme extension calls setThemeStylesheet(), the theme which holds the previously loaded extensions' stylesheets is replaced with another theme, which doesn't.

I suspect extensions are loaded alphabetically, so z-extension's CSS will probably still work ...
Comment 5 John Stowers 2011-05-25 22:14:50 UTC
(In reply to comment #4)
> Without looking into it too deeply, this is what I think is happening:
> 
> Extensions' stylesheets are added to the active theme. When the user-theme
> extension calls setThemeStylesheet(), the theme which holds the previously
> loaded extensions' stylesheets is replaced with another theme, which doesn't.
> 
> I suspect extensions are loaded alphabetically, so z-extension's CSS will
> probably still work ...

Yeah that looks like it. The following two calls fight

http://git.gnome.org/browse/gnome-shell/tree/js/ui/main.js#n399

http://git.gnome.org/browse/gnome-shell/tree/js/ui/extensionSystem.js#n136

themeContext.load_theme vs. themeContext.load_stylesheet
Comment 6 Owen Taylor 2011-05-25 22:23:01 UTC
Same as bug 642876 ?
Comment 7 John Stowers 2011-05-25 22:30:07 UTC
(In reply to comment #6)
> Same as bug 642876 ?

IMO, yes. Thats similar to the fix I was just hacking on right now.

As a side note: I think moving the theme-name schema into g-s (bug 650701) would also be an appropriate part of this fix. Then the only supported method for theme changes would be the setting of that key (and should take the race out of theme changes while loading/overwriting extension stylesheets)
Comment 8 Finnbarr P. Murphy 2011-05-27 04:17:07 UTC
I agree with John.  Part of the fix should be to move the theme-name schema into g-s.
Comment 9 Florian Müllner 2011-05-27 08:52:08 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > Same as bug 642876 ?
> 
> IMO, yes. Thats similar to the fix I was just hacking on right now.
> 
> As a side note: I think moving the theme-name schema into g-s (bug 650701)
> would also be an appropriate part of this fix. Then the only supported method
> for theme changes would be the setting of that key (and should take the race
> out of theme changes while loading/overwriting extension stylesheets)

How so? If the key changes, the previous theme is freed, and with it extensions' CSS. I honestly don't see much of a difference ...
Comment 10 John Stowers 2011-05-27 11:56:58 UTC
(In reply to comment #9)
> (In reply to comment #7)
> > (In reply to comment #6)
> > > Same as bug 642876 ?
> > 
> > IMO, yes. Thats similar to the fix I was just hacking on right now.
> > 
> > As a side note: I think moving the theme-name schema into g-s (bug 650701)
> > would also be an appropriate part of this fix. Then the only supported method
> > for theme changes would be the setting of that key (and should take the race
> > out of theme changes while loading/overwriting extension stylesheets)
> 
> How so? If the key changes, the previous theme is freed, and with it
> extensions' CSS. I honestly don't see much of a difference ...

Obviously the old css would still have to be stored and then re-added after a theme change. I was referring to the fact that doing so mid way through loading extensions containing said css seems icky.

It would also be appreciated if the g-s team would give us this inch (and move the schema into g-s proper).
Comment 11 Florian Müllner 2011-05-27 12:14:35 UTC
(In reply to comment #10)
> Obviously the old css would still have to be stored and then re-added after a
> theme change. I was referring to the fact that doing so mid way through loading
> extensions containing said css seems icky.

True, but as the proposed key could be changed from an extension, it wouldn't fix this problem (think of a theme packaged as extension, setting itself as default theme ...)
Comment 12 Erick Perez Castellanos 2011-05-27 13:30:10 UTC
*** Bug 649742 has been marked as a duplicate of this bug. ***
Comment 13 Finnbarr P. Murphy 2011-05-27 14:24:56 UTC
> Part of the fix should be to move the theme-name schema into g-s.

The primary reason for this is that the user-theme extension assumes that it is the only extension that uses the extension theme schema. 

However there are already a number of theme selector utilities such as gnome-tweak-tool and extensions such as ThemeSelector that use this schema and the number of users of this schema is only going to grow over time.

The problem occurs when a user removes the user-theme extension using a package manager such as yum because the schema is also removed.
Comment 14 John Stowers 2011-05-27 22:24:53 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > Obviously the old css would still have to be stored and then re-added after a
> > theme change. I was referring to the fact that doing so mid way through loading
> > extensions containing said css seems icky.
> 
> True, but as the proposed key could be changed from an extension, it wouldn't
> fix this problem (think of a theme packaged as extension, setting itself as
> default theme ...)

Sure, and this is javascript so there are also approximately seventy bazillion ways developers can monkey patch the shell and break it nicely to their liking. I will be happy if fix way encouraged people to do correct things.

Will you take a patch that fixes this and moves the schema into g-s or not?
Comment 15 John Stowers 2011-05-27 22:32:36 UTC
> I will be happy if fix way encouraged people to do correct things.
                                 ^^^ the fixed way
Comment 16 Giovanni Campagna 2011-05-31 19:48:10 UTC
*** Bug 651386 has been marked as a duplicate of this bug. ***
Comment 17 Giovanni Campagna 2011-06-02 15:07:26 UTC
Created attachment 189086 [details] [review]
StTheme: retrive the list of custom stylesheets and use it in loadTheme()

Using the list of stylesheets loaded with st_theme_load_stylesheet(),
one can build an StTheme that is completely identical to the previous
one, except for one property (application-stylesheet).
This allows rt and the user-theme extension to work while respecting
the theming of other extensions.
Comment 18 John Stowers 2011-06-02 20:53:21 UTC
(In reply to comment #17)
> Created an attachment (id=189086) [details] [review]
> StTheme: retrive the list of custom stylesheets and use it in loadTheme()
> 
> Using the list of stylesheets loaded with st_theme_load_stylesheet(),
> one can build an StTheme that is completely identical to the previous
> one, except for one property (application-stylesheet).
> This allows rt and the user-theme extension to work while respecting
> the theming of other extensions.

(In reply to comment #17)
> Created an attachment (id=189086) [details] [review]
> StTheme: retrive the list of custom stylesheets and use it in loadTheme()
> 
> Using the list of stylesheets loaded with st_theme_load_stylesheet(),
> one can build an StTheme that is completely identical to the previous
> one, except for one property (application-stylesheet).
> This allows rt and the user-theme extension to work while respecting
> the theming of other extensions.

Just tested this and it works for me here.

Thankyou Giovanni.
Comment 19 Finnbarr P. Murphy 2011-06-03 16:44:59 UTC
Works for me also.   Cascading order precedence maintained.
Comment 20 John Stowers 2011-06-06 13:27:13 UTC
Ping? Is this OK to commit?

I have now received a few personal emails from users telling me in varying degrees of politeness that user-theme extension has broken their GNOME3.
Comment 21 Finnbarr P. Murphy 2011-06-06 14:04:31 UTC
I agree that this fix should go in as soon as possible.
Comment 22 bwatkins 2011-06-09 00:55:27 UTC
Works here as well, this really needs to go in! This is an official extension, and one of the most popular ones. Can't have this keep ruining so many other extensions.
Comment 23 Tim Lauridsen 2011-06-11 08:28:43 UTC
Work for me too :)
Comment 24 John Stowers 2011-06-13 01:20:23 UTC
Ping? Seriously.
Comment 25 Colin Walters 2011-06-15 18:19:37 UTC
Review of attachment 189086 [details] [review]:

::: js/ui/main.js
@@ +402,3 @@
     let theme = new St.Theme ({ application_stylesheet: cssStylesheet });
+
+    if (previousTheme) {

Don't we want a check if previousTheme != theme too?
Comment 26 Giovanni Campagna 2011-06-15 19:35:05 UTC
(In reply to comment #25)
> Review of attachment 189086 [details] [review]:
> 
> ::: js/ui/main.js
> @@ +402,3 @@
>      let theme = new St.Theme ({ application_stylesheet: cssStylesheet });
> +
> +    if (previousTheme) {
> 
> Don't we want a check if previousTheme != theme too?

That's not possible, theme is always a new object, and objects are compared by pointer in JS.
(That's true even if constructor is overridden for the GObject, although gjs probably won't like that)
Comment 27 Colin Walters 2011-06-15 19:42:46 UTC
Comment on attachment 189086 [details] [review]
StTheme: retrive the list of custom stylesheets and use it in loadTheme()

OK.
Comment 28 Giovanni Campagna 2011-06-15 19:58:14 UTC
Attachment 189086 [details] pushed as 2674d96 - StTheme: retrive the list of custom stylesheets and use it in loadTheme()