Skip to content
  • Luca Bacci's avatar
    Set a default max_width_chars for wrapping Gtk::Labels (!40) · 769d19e0
    Luca Bacci authored and Mike Fleetwood's avatar Mike Fleetwood committed
    Opening the Partition Information dialog for a file system mounted on a
    very long mount point, or on openSUSE which mounts the OS from 10 btrfs
    subvolumes from the same partition, will cause the dialog to be very
    wide as the "Mounted on ..." text is not wrapped.
    
    Back in Gtk2, when width_chars / max_width_chars were not set, wrapping
    labels had a default width beyond which text wrapped onto a new line
    [1].
    
    For Gtk3 this default width was first reworked a bit [2], and then was
    removed for the very early Gtk3 3.0.10 release [3].
    
    It is recommended that applications explicitly set default values,
    otherwise wrapping labels never wrap when requesting their natural
    allocation.
    
    References:
    
    [1] Gtk 2.24.32 source code - gtk/gtklabel.c:2975
        https://gitlab.gnome.org/GNOME/gtk/blob/2.24.32/gtk/gtklabel.c#L2975
            "This long string gives a good enough length for any line to
            have."
    
    [2] Gtk commit from 2010-04-21:
        gtk@680d7762
        Make sure not to base the minimum size on "max-width-chars", only
        the natural size.
            "This string is just about long enough."
    
    [3] Gtk commit from 2011-04-17:
        gtk@c8ce1106
        label: Don't try to guess a label's size
    
        People should use window default sizes or label
        width-chars/max-width-chars to find the ideal layout for a label
        instead of relying on magic.
    
    Closes !40 - Limit wrapping labels
    769d19e0