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 728027 - CSSProvider documentation doesn't mention background-image vs background-color precedence order
CSSProvider documentation doesn't mention background-image vs background-colo...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
3.12.x
Other Linux
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-04-11 10:18 UTC by Robert Roth
Modified: 2016-05-23 23:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example reproducing the problem. (1.52 KB, text/x-csrc)
2014-04-11 10:18 UTC, Robert Roth
Details

Description Robert Roth 2014-04-11 10:18:47 UTC
Created attachment 274072 [details]
Example reproducing the problem.

Tried to set the background-color of a GtkButton with the following CSS loaded with a css provider added to the style context of the default screen with the APPLICATION priority:

GtkButton {
    background-color: red;
}

The background-color is not set, when the window showing the button is focused, however when switching to another window, the red background-color shows on the button, switching back removes it again.

Find the example code I have tested with attached.
Comment 1 Robert Roth 2014-04-11 10:27:32 UTC
Tried the following CSS snippets for setting the background-color for the focused version too:

Version 1 (doesn't work for the focused):

GtkButton:focused,
GtkButton {
    background-color: red;
}

Version 2 (doesn't work for the focused):

.button:focused,
.button {
    background-color: red;
}

Version 3 (the only one working):

GtkButton {
   background-color: red;
   background-image: none;
}
Comment 2 Robert Roth 2014-04-11 11:24:26 UTC
garnacho mentioned the following on IRC:

"background-image has precedence over background, if you want solid colors you should be unsetting the former if you want to deal with themes using gradients altogether, not just Adwaita"

This is not mentioned anywhere in the GtkCssProvider documentation describing all the CSS attributes, maybe it would be worth adding a few words about this precedence order (image/solid colors/...).
Comment 3 Matthias Clasen 2016-05-23 23:28:42 UTC
Added a bit of informatino here: https://git.gnome.org/browse/gtk+/commit/?id=30c3d6af563ec1693bcc6f1a959a735fb5be53d2