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 707695 - GtkLevelBar Colour CSS
GtkLevelBar Colour CSS
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
3.9.x
Other Linux
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-09-07 16:38 UTC by Jane Smith
Modified: 2014-10-27 11:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
testlevelbar: don't segfault when quitting testlevelbar (1.13 KB, patch)
2014-10-24 22:28 UTC, Cosimo Cecchi
accepted-commit_now Details | Review
levelbar: don't use the current value style class for empty blocks (2.80 KB, patch)
2014-10-24 22:28 UTC, Cosimo Cecchi
none Details | Review
testlevelbar: fix CSS to be aligned with documentation (829 bytes, patch)
2014-10-24 22:28 UTC, Cosimo Cecchi
none Details | Review

Description Jane Smith 2013-09-07 16:38:33 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;
}
Comment 1 Matthias Clasen 2013-09-08 20:44:18 UTC
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.
Comment 2 André Klapper 2014-05-23 02:05:21 UTC
(In reply to comment #1)
> Leaving this open for Cosimo to comment.

Cosimo: ping
Comment 3 André Klapper 2014-10-24 20:33:26 UTC
(In reply to comment #1)
> Leaving this open for Cosimo to comment.

Cosimo: ping
Comment 4 Cosimo Cecchi 2014-10-24 21:18:13 UTC
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.
Comment 5 Cosimo Cecchi 2014-10-24 22:28:15 UTC
Created attachment 289298 [details] [review]
testlevelbar: don't segfault when quitting testlevelbar

Quit the mainloop when the window is closed.
Comment 6 Cosimo Cecchi 2014-10-24 22:28:20 UTC
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.
Comment 7 Cosimo Cecchi 2014-10-24 22:28:24 UTC
Created attachment 289300 [details] [review]
testlevelbar: fix CSS to be aligned with documentation
Comment 8 Cosimo Cecchi 2014-10-24 22:30:20 UTC
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.
Comment 9 Matthias Clasen 2014-10-27 10:54:28 UTC
Review of attachment 289298 [details] [review]:

sure