Skip to content

Commit

Permalink
fix(LWW): temp hack to fix status overflow (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Feb 1, 2024
1 parent ea533d5 commit 6376aa8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/Widgets/LabelWithWidgets.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions src/Widgets/MarkupView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
};

Expand All @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/Widgets/RichLabel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6376aa8

Please sign in to comment.