GNOME Bugzilla – Bug 647284
GtkLabel does not honor width-chars anymore.
Last modified: 2011-04-19 20:25:49 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.
Created attachment 185587 [details] [review] GtkLabel does not honor width-chars anymore.
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.
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.
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.
Created attachment 185609 [details] [review] Factor out a get_char_pixels method for clarity.
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.
Created attachment 185611 [details] [review] Small cleanup in label sizing code. Move ellipsized_chars calculation in the scope where it is used.
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.
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.