diff options
| author | Marvin W <git@larma.de> | 2023-02-06 20:23:54 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-10-05 14:32:06 +0200 |
| commit | 7d3498a8338612a0469534506890407955ceaf60 (patch) | |
| tree | 74b60279a5a4cfa9f976f444acf257803b079205 /main/src | |
| parent | cc5b6312bc616a59258051900f84e81757f8b87a (diff) | |
| download | dino-7d3498a8338612a0469534506890407955ceaf60.tar.gz | |
Fix label attributes updated with delay
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/ui/conversation_selector/conversation_selector_row.vala | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala index 067f257c..e71f58d1 100644 --- a/main/src/ui/conversation_selector/conversation_selector_row.vala +++ b/main/src/ui/conversation_selector/conversation_selector_row.vala @@ -175,7 +175,7 @@ public class ConversationSelectorRow : ListBoxRow { nick_label.label += ": "; } - message_label.attributes.filter((attr) => attr.equal(attr_style_new(Pango.Style.ITALIC))); + change_label_attribute(message_label, attr_style_new(Pango.Style.NORMAL)); message_label.label = Util.summarize_whitespaces_to_space(body); break; @@ -191,7 +191,7 @@ public class ConversationSelectorRow : ListBoxRow { } bool file_is_image = transfer.mime_type != null && transfer.mime_type.has_prefix("image"); - message_label.attributes.insert(attr_style_new(Pango.Style.ITALIC)); + change_label_attribute(message_label, attr_style_new(Pango.Style.ITALIC)); if (transfer.direction == Message.DIRECTION_SENT) { message_label.label = (file_is_image ? _("Image sent") : _("File sent") ); } else { @@ -203,7 +203,7 @@ public class ConversationSelectorRow : ListBoxRow { Call call = call_item.call; nick_label.label = call.direction == Call.DIRECTION_OUTGOING ? _("Me") + ": " : ""; - message_label.attributes.insert(attr_style_new(Pango.Style.ITALIC)); + change_label_attribute(message_label, attr_style_new(Pango.Style.ITALIC)); message_label.label = call.direction == Call.DIRECTION_OUTGOING ? _("Outgoing call") : _("Incoming call"); break; } @@ -212,6 +212,12 @@ public class ConversationSelectorRow : ListBoxRow { } } + private static void change_label_attribute(Label label, owned Attribute attribute) { + AttrList copy = label.attributes.copy(); + copy.change((owned) attribute); + label.attributes = copy; + } + protected void update_read(bool force_update = false) { int current_num_unread = stream_interactor.get_module(ChatInteraction.IDENTITY).get_num_unread(conversation); if (num_unread == current_num_unread && !force_update) return; @@ -220,10 +226,10 @@ public class ConversationSelectorRow : ListBoxRow { if (num_unread == 0) { unread_count_label.visible = false; - name_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD))); - time_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD))); - nick_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD))); - message_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD))); + change_label_attribute(name_label, attr_weight_new(Weight.NORMAL)); + change_label_attribute(time_label, attr_weight_new(Weight.NORMAL)); + change_label_attribute(nick_label, attr_weight_new(Weight.NORMAL)); + change_label_attribute(message_label, attr_weight_new(Weight.NORMAL)); } else { unread_count_label.label = num_unread.to_string(); unread_count_label.visible = true; @@ -236,16 +242,11 @@ public class ConversationSelectorRow : ListBoxRow { unread_count_label.get_style_context().remove_class("unread-count-notify"); } - name_label.attributes.insert(attr_weight_new(Weight.BOLD)); - time_label.attributes.insert(attr_weight_new(Weight.BOLD)); - nick_label.attributes.insert(attr_weight_new(Weight.BOLD)); - message_label.attributes.insert(attr_weight_new(Weight.BOLD)); + change_label_attribute(name_label, attr_weight_new(Weight.BOLD)); + change_label_attribute(time_label, attr_weight_new(Weight.BOLD)); + change_label_attribute(nick_label, attr_weight_new(Weight.BOLD)); + change_label_attribute(message_label, attr_weight_new(Weight.BOLD)); } - - name_label.label = name_label.label; // TODO initializes redrawing, which would otherwise not happen. nicer? - time_label.label = time_label.label; - nick_label.label = nick_label.label; - message_label.label = message_label.label; } public override void state_flags_changed(StateFlags flags) { |
