GNOME Bugzilla – Bug 657621
Calculate the wrong height of labels wrapping on words
Last modified: 2018-04-14 23:54:39 UTC
- Open libempathy-gtk/empathy-account-widget-irc.ui
- Display the vbox_irc widget
- As you can see there is a big space between label_password_note and the GtkExpander
That's because of the wrapping of word. If you disable it, the height of the label is fine. If you try adding or removing some words to the label you'll notice that his height growths/reduces for each word.
Created attachment 195275 [details]
Test program to demonstrate the issue. Run it and press couple times the "Add new label" button. The dialog is resized much more than is necessary. When I compile it with gtk2 then it doesn't suffer of such issue, but it doesn't rewrap when I change window with, whereas gtk3 does that, it only doesn't shrink the required size appropriately (I mean the dialog's size).
All that seems to me like GtkLabel is calculating its wrapped text size with incorrect label-size values, forcing into unneeded gaps in packing.
This is with gtk3-3.0.12-1 and gtk2-2.24.4-2.
*** Bug 658351 has been marked as a duplicate of this bug. ***
Also affect Empathy's contact tooltips:
I've described the underlying issue here in a blog post a while ago (unfortunately lost in the demise of fedora blog hosting...).
The remedy for now is to set a reasonable wrap-width on all wrapping labels.
Note that packing label into a GtkGrid instead of a GtkTable fixed this issue.
Yeah, GtkTable is stupid, it assigns the minimum size returned from gtk_widget_get_preferred_size() (why does that function even exist?) to all its children, which is getting more and more broken as widgets switch over more and more to proper width-for-height handling. And GtkTable will be deprecated for GTK 3.4 - it's properly replaced by GtkGrid.
(In reply to comment #4)
> I've described the underlying issue here in a blog post a while ago
> (unfortunately lost in the demise of fedora blog hosting...).
> The remedy for now is to set a reasonable wrap-width on all wrapping labels.
I cannot find the property, is it supposed to be GtkLabel::width-chars and/or GtkLabel::max-width-chars; the later doesn't influence the bad behaviour (while the documentation suggests it should, from my point of view), the former does influence it, but calculating the right value for the parent allocated space is not that trivial (I even do not know how to do that).
(In reply to comment #5)
> Note that packing label into a GtkGrid instead of a GtkTable fixed this issue.
My real widget chain in evolution itself is this:
EAlertBar (GtkInfoBar descendant)
EMailShellContent (GtkBin descendant)
EShellWindow (GtkWindow descendant)
Thus there is no GtkTable, neither in my simplified test.c.
*** Bug 660587 has been marked as a duplicate of this bug. ***
*** Bug 664898 has been marked as a duplicate of this bug. ***
*** Bug 671440 has been marked as a duplicate of this bug. ***
OK, in Evolution it was its own fault. I just fixed it in . It's not a case for test.c, though.
Created attachment 231045 [details]
I've run into this issue in 3.4.3, also not connected with GtkTable. It seems that the label's height request is always the maximum height request that it would have if its width were squeezed to the minimum. You can work around this by calling gtk_widget_set_size_request(label, SOME_FIXED_VALUE, -1). Here's a Python script illustrating the problem and workaround.
This bug seems to be the cause of https://bugzilla.gnome.org/show_bug.cgi?id=670496. Unfortunately the workaround documented in https://bugzilla.gnome.org/show_bug.cgi?id=657621#c12 (which was applied in zenity) doesn't seem to work anymore in 3.22.
This bug should really be closed; the issue is that GtkDialog does not enforce a size related on the monitor size (because it's a broken heuristic) and thus people can set the contents of the dialog to exceed the size of the screen if they aren't careful with label size and word wrapping.
(In reply to Alan from comment #13)
> This bug seems to be the cause of
> https://bugzilla.gnome.org/show_bug.cgi?id=670496. Unfortunately the
> workaround documented in
> https://bugzilla.gnome.org/show_bug.cgi?id=657621#c12 (which was applied in
> zenity) doesn't seem to work anymore in 3.22.
Is Zenity setting the label text from the input without setting max-width-chars on the label it uses, and without setting wrapping to TRUE?
> Is Zenity setting the label text from the input without setting
> max-width-chars on the label it uses, and without setting wrapping to TRUE?
It was setting wrapping to true, but not max-width-chars. Please not that for the dialog to get the right heigh, I not only had to set max-width-chars but also width-chars.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla.
If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: