GNOME Bugzilla – Bug 769660
GtkLabel:width-chars and max-width-chars don't behave as documented for ellipsized labels
Last modified: 2018-05-02 17:23:07 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.
Created attachment 332984 [details] A reproducer for ellipsized labels and max-width-chars
Created attachment 332985 [details] A reproducer for ellipsized labels and width-chars
Created attachment 332987 [details] [review] GtkLabel: Fix the text layout documentation for ellipsized labels
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)
-- 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.