diff --git a/src/Widgets/LabelWithWidgets.vala b/src/Widgets/LabelWithWidgets.vala index 0a8bbb827..ad65a05db 100644 --- a/src/Widgets/LabelWithWidgets.vala +++ b/src/Widgets/LabelWithWidgets.vala @@ -54,6 +54,17 @@ public class Tuba.Widgets.LabelWithWidgets : Gtk.Widget, Gtk.Buildable, Gtk.Acce } } + private bool _fix_overflow_hack = false; + public bool fix_overflow_hack { + get { + return fix_overflow_hack; + } + set { + _fix_overflow_hack = value; + update_label (); + } + } + const string OBJECT_REPLACEMENT_CHARACTER = "\xEF\xBF\xBC"; construct { @@ -227,6 +238,11 @@ public class Tuba.Widgets.LabelWithWidgets : Gtk.Widget, Gtk.Buildable, Gtk.Acce var old_label = label.label; var new_label = _text.replace (placeholder, OBJECT_REPLACEMENT_CHARACTER); + if (_fix_overflow_hack) { + label.lines = int.max (100, widgets.length); + label.ellipsize = Pango.EllipsizeMode.END; + } + if (old_label != new_label) { label.wrap = true; label.wrap_mode = Pango.WrapMode.WORD_CHAR; diff --git a/src/Widgets/MarkupView.vala b/src/Widgets/MarkupView.vala index 22e7868b6..a2dbde8f9 100644 --- a/src/Widgets/MarkupView.vala +++ b/src/Widgets/MarkupView.vala @@ -82,7 +82,8 @@ public class Tuba.Widgets.MarkupView : Gtk.Box { selectable = _selectable, vexpand = true, large_emojis = settings.enlarge_custom_emojis, - use_markup = true + use_markup = true, + fix_overflow_hack = true }; if (instance_emojis != null) label.instance_emojis = instance_emojis; if (mentions != null) label.mentions = mentions; @@ -230,7 +231,8 @@ public class Tuba.Widgets.MarkupView : Gtk.Box { var label = new RichLabel (text) { visible = true, css_classes = { "ttl-code", "monospace" }, - use_markup = true + use_markup = true, + fix_overflow_hack = true // markup = MarkupPolicy.DISALLOW }; @@ -256,7 +258,8 @@ public class Tuba.Widgets.MarkupView : Gtk.Box { var label = new RichLabel (text) { visible = true, css_classes = { "ttl-code", "italic" }, - use_markup = true + use_markup = true, + fix_overflow_hack = true // markup = MarkupPolicy.DISALLOW }; v.append (label); diff --git a/src/Widgets/RichLabel.vala b/src/Widgets/RichLabel.vala index 87fc84a52..9047d109a 100644 --- a/src/Widgets/RichLabel.vala +++ b/src/Widgets/RichLabel.vala @@ -61,6 +61,16 @@ public class Tuba.Widgets.RichLabel : Adw.Bin { set { widget.lines = value; } } + // #756 + public bool fix_overflow_hack { + get { + return widget.fix_overflow_hack; + } + set { + widget.fix_overflow_hack = value; + } + } + public RichLabel (string? text = null) { if (text != null) label = text;