GNOME Bugzilla – Bug 728027
CSSProvider documentation doesn't mention background-image vs background-color precedence order
Last modified: 2016-05-23 23:28:42 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.
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; }
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/...).
Added a bit of informatino here: https://git.gnome.org/browse/gtk+/commit/?id=30c3d6af563ec1693bcc6f1a959a735fb5be53d2