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 647284 - GtkLabel does not honor width-chars anymore.
GtkLabel does not honor width-chars anymore.
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-04-09 15:28 UTC by Paolo Borelli
Modified: 2011-04-19 20:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkLabel does not honor width-chars anymore. (1.16 KB, patch)
2011-04-09 15:28 UTC, Paolo Borelli
none Details | Review
GtkLabel does not honor width-chars anymore. (2.95 KB, patch)
2011-04-09 18:03 UTC, Paolo Borelli
none Details | Review
Cleanup logic to obtain label width. (3.92 KB, patch)
2011-04-09 19:13 UTC, Paolo Borelli
none Details | Review
Factor out a get_char_pixels method for clarity. (2.03 KB, patch)
2011-04-09 20:52 UTC, Paolo Borelli
none Details | Review
GtkLabel does not honor width-chars anymore. (2.62 KB, patch)
2011-04-09 20:53 UTC, Paolo Borelli
none Details | Review
Small cleanup in label sizing code. (1.99 KB, patch)
2011-04-09 20:53 UTC, Paolo Borelli
none Details | Review
Cleanup label sizing code with widget aux info (2.33 KB, patch)
2011-04-09 20:53 UTC, Paolo Borelli
none Details | Review
incomplete unit test (6.33 KB, patch)
2011-04-10 00:00 UTC, Paolo Borelli
needs-work Details | Review

Description Paolo Borelli 2011-04-09 15:28:18 UTC
width-chars property was not taken into account in the natural sizing of
the label unless the label was ellipsized or wrapped. It should instead
influence at least the natural size. This for instance could be observed
in gedit's statusbar where the line/col label was not allocated a fixed
size anymore and thus resized itself when moving the cursor.
Comment 1 Paolo Borelli 2011-04-09 15:28:20 UTC
Created attachment 185587 [details] [review]
GtkLabel does not honor width-chars anymore.
Comment 2 Benjamin Otte (Company) 2011-04-09 16:57:07 UTC
Looking at the code, I'd say that the if in line 3084 should probably be identical to the one in line 3123, otherwise we fail to account for max-width-chars in the default case. Also, that patch should apply to master, too.

Then you can fold the bottom if into the top if in a second patch as code cleanup to make me happy.

And if you do that, you can commit it.
Comment 3 Paolo Borelli 2011-04-09 18:03:37 UTC
Created attachment 185603 [details] [review]
GtkLabel does not honor width-chars anymore.

width-chars property was not taken into account in the natural sizing of
the label unless the label was ellipsized or wrapped. It should instead
influence at least the natural size. This for instance could be observed
in gedit's statusbar where the line/col label was not allocated a fixed
size anymore and thus resized itself when moving the cursor.
Comment 4 Paolo Borelli 2011-04-09 19:13:25 UTC
Created attachment 185604 [details] [review]
Cleanup logic to obtain label width.

Fold the logic taking into account the widget aux width into the
calculation of natural width.
Comment 5 Paolo Borelli 2011-04-09 20:52:32 UTC
Created attachment 185609 [details] [review]
Factor out a get_char_pixels method for clarity.
Comment 6 Paolo Borelli 2011-04-09 20:53:19 UTC
Created attachment 185610 [details] [review]
GtkLabel does not honor width-chars anymore.

width-chars property was not taken into account in the natural sizing of
the label unless the label was ellipsized or wrapped. It should instead
influence at least the natural size. This for instance could be observed
in gedit's statusbar where the line/col label was not allocated a fixed
size anymore and thus resized itself when moving the cursor.
Comment 7 Paolo Borelli 2011-04-09 20:53:28 UTC
Created attachment 185611 [details] [review]
Small cleanup in label sizing code.

Move ellipsized_chars calculation in the scope where it is used.
Comment 8 Paolo Borelli 2011-04-09 20:53:36 UTC
Created attachment 185612 [details] [review]
Cleanup label sizing code with widget aux info

Merge the code that handles the case where a width is specified in the
widget aux info with the rest of the label sizing special cases since
they are now under the same if condition.
Comment 9 Paolo Borelli 2011-04-10 00:00:25 UTC
Created attachment 185622 [details] [review]
incomplete unit test

This patch is a first rough cut at a unit test, it needs more work but it is a start and already shows some cases that look suspicius.