GNOME Bugzilla – Bug 761363
Unlabeled GtkCheckButton does not respect valign
Last modified: 2016-02-07 14:14:05 UTC
Created attachment 320132 [details] Testcase. Run with or without an argument to get labeled or unlabeled checkbox When label is NULL, checkbox has incorrect vertical alignment.
I admit that I don't see any difference between labeled and unlabeled. Also, there is nothing next to your checkbutton to align it to, so setting valign will not make much of a difference.
Created attachment 320212 [details] Screenshot: no label on checkbox
Created attachment 320213 [details] Screenshot: checkbox with a label
Created attachment 320214 [details] Testcase In my use-case i have a hbox with two widgets - a checkbox with no label and a label. Checkbox is packed to the left, label is packed to the right. Until roughly a month a go (maybe even less) label-less checkbox would valign just fine. But at some point that changed. Actually, now that i'm looking, at this, i can't make the widget valigned at all. I *can* do that with Inspector, if i change the parameters of the label subwidget of the checkbutton widget, but i can't make the checkbox widget valigned as a whole. So yeah, disregard my "no label" comments, they are not relevant.
so, you describe your use case... but your testcase still doesn't reproduce it.
Created attachment 320234 [details] Testcase v3 Fine, here's the testcase with a checkbox and a label packed in a box. Both are packed with fill && !expand, both are given 100 height request. Label is centered vertically, checkbox is not, even though both widgets *do* occupy the 100-tall area, according to inspector.
from my brief testing, this has something to do with the height request - as long as I don't set it, the checkbox is centered just fine with GTK_ALIGN_CENTER.
Yes, without a height request the checkbutton remains small, if allowed to do so, and GTK_ALIGN_CENTER positions it at the center of the available vertical space. With GTK_ALIGN_FILL it will be as big as allowed (you don't need to set height request on it, just put it in a box with some tall widget). If that happens, it will occupy all the space, but within that space it will be aligned to the top, regardless of what its vertical alignment value (which defaults to 0.5) is. Using GTK_ALIGN_CENTER is a workaround, but not a fix. At the very least because GTK_ALIGN_FILL is, AFAIK, the default for any widget.