aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2023-02-06 20:23:54 +0100
committerMarvin W <git@larma.de>2023-02-07 10:50:45 +0100
commit1d123c7e66d963fd8cc8cc4250b5813a62676f56 (patch)
tree4a142f49e88f23f78ea49271eaaf50f5c1817096 /main/src
parentf74c1f18b12df0d650f74b6fa43b7f2f0a9bce79 (diff)
downloaddino-1d123c7e66d963fd8cc8cc4250b5813a62676f56.tar.gz
dino-1d123c7e66d963fd8cc8cc4250b5813a62676f56.zip
Fix label attributes updated with delay
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/conversation_selector/conversation_selector_row.vala33
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 8355b104..e71176aa 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -182,7 +182,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;
@@ -198,7 +198,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 {
@@ -210,7 +210,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;
}
@@ -219,6 +219,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;
@@ -227,10 +233,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;
@@ -243,16 +249,11 @@ public class ConversationSelectorRow : ListBoxRow {
unread_count_label.remove_css_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) {