GNOME Bugzilla – Bug 707695
GtkLevelBar Colour CSS
Last modified: 2014-10-27 11:06:51 UTC
Under the heading "Example 21. Adding a custom offset on the bar" on https://developer.gnome.org/gtk3/unstable/GtkLevelBar.html: the CSS given changes the colour of the background of the bar, not the colour of the bar itself (as you would expect). It produces this: http://i.imgur.com/M7Mmg3g.png It should produce something this: http://i.imgur.com/OIv3Gm2.png This is the CSS I used: @define-color color green; .level-bar.fill-block.level-my-offset { border-color: shade(@color, 0.85); background-image: linear-gradient(to bottom, shade(@color, 1.2), @color 75%, shade(@color, 0.95)); } .level-bar.fill-block.empty-fill-block { border-color: alpha(#000000, 0.1); background-color: transparent; background-image: none; }
Clearly, the advice in the docs is not working. You can fix things up by using something like .level-bar.fill-block.level-my-offset { border-color: shade(@color, 0.85); background-image: linear-gradient(to bottom, shade(@color, 1.2), @color 75%, shade(@color, 0.95)); } .level-bar.fill-block.empty-fill-block.level-my-offset { border-color: alpha(#000000, 0.1); background-color: transparent; background-image: none; } Clearly, that is suboptimal. I've added a testcase (tests/testlevelbar.c) for this in the gtk sources. Leaving this open for Cosimo to comment.
(In reply to comment #1) > Leaving this open for Cosimo to comment. Cosimo: ping
I guess this depends on the order which the CSS rules are defined? .level-bar.fill-block.level-my-offset and .level-bar.fill-block.empty-fill-block have the same specificity, so if a fill block gets both "level-my-offset" and "empty-fill-block" style classes, the one declared first wins. That's probably not how it should work though - I'll take a look at the code.
Created attachment 289298 [details] [review] testlevelbar: don't segfault when quitting testlevelbar Quit the mainloop when the window is closed.
Created attachment 289299 [details] [review] levelbar: don't use the current value style class for empty blocks We want to be able to style the empty blocks independently of all the offset styles, so remove the current style class when painting an empty block.
Created attachment 289300 [details] [review] testlevelbar: fix CSS to be aligned with documentation
It seems there was an actual bug in the code that was making GtkLevelBar use the style class for the current value offset. Attached patches fix the issue here.
Review of attachment 289298 [details] [review]: sure