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 769660 - GtkLabel:width-chars and max-width-chars don't behave as documented for ellipsized labels
GtkLabel:width-chars and max-width-chars don't behave as documented for ellip...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-08-09 07:45 UTC by Debarshi Ray
Modified: 2018-05-02 17:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A reproducer for ellipsized labels and max-width-chars (923 bytes, text/plain)
2016-08-09 07:48 UTC, Debarshi Ray
  Details
A reproducer for ellipsized labels and width-chars (794 bytes, text/plain)
2016-08-09 07:49 UTC, Debarshi Ray
  Details
GtkLabel: Fix the text layout documentation for ellipsized labels (1.31 KB, patch)
2016-08-09 07:57 UTC, Debarshi Ray
none Details | Review

Description Debarshi Ray 2016-08-09 07:45:18 UTC
The text layout section (ie. #label-text-layout) says:

 * The #GtkLabel:width-chars and #GtkLabel:max-width-chars properties                                                                       
 * can be used to control the size allocation of ellipsized or wrapped                                                                      
 * labels. For ellipsizing labels, if either is specified (and less                                                                         
 * than the actual text size), it is used as the minimum width, and the actual                                                              
 * text size is used as the natural width of the label.

However, the code and comments inside gtk_label_get_preferred_layout_size don't match that. For ellipsized labels:

(i) GtkLabel:width-chars is always the minimum size, regardless of whether it is less than the actual text size or not.

(ii) GtkLabel:max-width-chars is the natural size, not minimum size.
Comment 1 Debarshi Ray 2016-08-09 07:48:26 UTC
Created attachment 332984 [details]
A reproducer for ellipsized labels and max-width-chars
Comment 2 Debarshi Ray 2016-08-09 07:49:01 UTC
Created attachment 332985 [details]
A reproducer for ellipsized labels and width-chars
Comment 3 Debarshi Ray 2016-08-09 07:57:55 UTC
Created attachment 332987 [details] [review]
GtkLabel: Fix the text layout documentation for ellipsized labels
Comment 4 Daniel Boles 2017-09-03 21:55:53 UTC
I've not analysed any of it yet, but what do you think of this commentary in gtk_label_get_preferred_layout_size() ?

  /* "width-chars" Hard-coded minimum width:
   *    - minimum size should be MAX (width-chars, strlen ("..."));
   *    - natural size should be MAX (width-chars, strlen (priv->text));
   *
   * "max-width-chars" User specified maximum size requisition
   *    - minimum size should be MAX (width-chars, 0)
   *    - natural size should be MIN (max-width-chars, strlen (priv->text))
   *
   *    For ellipsizing labels; if max-width-chars is specified: either it is used as
   *    a minimum size or the label text as a minimum size (natural size still overflows).
   *
   *    For wrapping labels; A reasonable minimum size is useful to naturally layout
   *    interfaces automatically. In this case if no "width-chars" is specified, the minimum
   *    width will default to the wrap guess that gtk_label_ensure_layout() does.
   */

In case any of that is wrong, we should update it at the same time. (unless it is right and the code is wrong, but then we presumably can't change the code now)
Comment 5 GNOME Infrastructure Team 2018-05-02 17:23:07 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/654.