composer-widget: Ellipsize long attachment names

If an attachment name is way too long, the attachment name label forces
the composer widget to become too wide which breaks on smaller screens.

To fix this, ellipsize the label if needed. Since the user has probably
just chosen the attachment, they probably have an idea which attachment
it is anyway, so we can do this instead of wrapping. Since the file
extension can make a big difference, we ellipsize in the middle.

When a label is ellipsized, we also add the label as a tooltip in case a
user wants to double check the attachment name though.

Fixes: https://gitlab.gnome.org/GNOME/geary/-/issues/1577
This commit is contained in:
Niels De Graef 2023-11-19 22:58:04 +01:00 committed by Cédric Bellegarde
parent 920343e575
commit 6ae4cd620f

View file

@ -1872,6 +1872,9 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
Gtk.Label label = new Gtk.Label(label_text);
box.pack_start(label);
label.halign = Gtk.Align.START;
label.ellipsize = Pango.EllipsizeMode.MIDDLE;
label.has_tooltip = true;
label.query_tooltip.connect(Util.Gtk.query_tooltip_label);
Gtk.Button remove_button = new Gtk.Button.from_icon_name("user-trash-symbolic", BUTTON);
box.pack_start(remove_button, false, false);