Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Widgets/EmojiLabel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Tuba.Widgets.EmojiLabel : Tuba.Widgets.LabelWithWidgets {
}

public EmojiLabel (string? text = null, Gee.HashMap<string, string>? emojis = null) {
Object ();
Object (max_size: 128);
if (text == null) return;

instance_emojis = emojis;
Expand Down
18 changes: 18 additions & 0 deletions src/Widgets/LabelWithWidgets.vala
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ public class Tuba.Widgets.LabelWithWidgets : Gtk.Widget, Gtk.Buildable, Gtk.Acce
}
}

private int _max_size = -1;
public int max_size {
get {
return _max_size;
}
set {
if (_max_size == value) return;

_max_size = value;
invalidate_child_widgets ();
}
}

const string OBJECT_REPLACEMENT_CHARACTER = "\xEF\xBF\xBC";

construct {
Expand Down Expand Up @@ -93,6 +106,11 @@ public class Tuba.Widgets.LabelWithWidgets : Gtk.Widget, Gtk.Buildable, Gtk.Acce
widgets[i].widget.get_preferred_size (out size, out natural_size);
int width = natural_size.width;
int height = natural_size.height;
if (width == 0 || height == 0) return;
if (max_size > 0) {
width = int.min (width, max_size);
height = int.min (height, max_size);
}

int old_width = widgets[i].width;
int old_height = widgets[i].height;
Expand Down