Fix label attributes updated with delay
This commit is contained in:
parent
f74c1f18b1
commit
1d123c7e66
|
@ -182,7 +182,7 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
nick_label.label += ": ";
|
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);
|
message_label.label = Util.summarize_whitespaces_to_space(body);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -198,7 +198,7 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_is_image = transfer.mime_type != null && transfer.mime_type.has_prefix("image");
|
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) {
|
if (transfer.direction == Message.DIRECTION_SENT) {
|
||||||
message_label.label = (file_is_image ? _("Image sent") : _("File sent") );
|
message_label.label = (file_is_image ? _("Image sent") : _("File sent") );
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,7 +210,7 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
Call call = call_item.call;
|
Call call = call_item.call;
|
||||||
|
|
||||||
nick_label.label = call.direction == Call.DIRECTION_OUTGOING ? _("Me") + ": " : "";
|
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");
|
message_label.label = call.direction == Call.DIRECTION_OUTGOING ? _("Outgoing call") : _("Incoming call");
|
||||||
break;
|
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) {
|
protected void update_read(bool force_update = false) {
|
||||||
int current_num_unread = stream_interactor.get_module(ChatInteraction.IDENTITY).get_num_unread(conversation);
|
int current_num_unread = stream_interactor.get_module(ChatInteraction.IDENTITY).get_num_unread(conversation);
|
||||||
if (num_unread == current_num_unread && !force_update) return;
|
if (num_unread == current_num_unread && !force_update) return;
|
||||||
|
@ -227,10 +233,10 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
if (num_unread == 0) {
|
if (num_unread == 0) {
|
||||||
unread_count_label.visible = false;
|
unread_count_label.visible = false;
|
||||||
|
|
||||||
name_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
|
change_label_attribute(name_label, attr_weight_new(Weight.NORMAL));
|
||||||
time_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
|
change_label_attribute(time_label, attr_weight_new(Weight.NORMAL));
|
||||||
nick_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
|
change_label_attribute(nick_label, attr_weight_new(Weight.NORMAL));
|
||||||
message_label.attributes.filter((attr) => attr.equal(attr_weight_new(Weight.BOLD)));
|
change_label_attribute(message_label, attr_weight_new(Weight.NORMAL));
|
||||||
} else {
|
} else {
|
||||||
unread_count_label.label = num_unread.to_string();
|
unread_count_label.label = num_unread.to_string();
|
||||||
unread_count_label.visible = true;
|
unread_count_label.visible = true;
|
||||||
|
@ -243,16 +249,11 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
unread_count_label.remove_css_class("unread-count-notify");
|
unread_count_label.remove_css_class("unread-count-notify");
|
||||||
}
|
}
|
||||||
|
|
||||||
name_label.attributes.insert(attr_weight_new(Weight.BOLD));
|
change_label_attribute(name_label, attr_weight_new(Weight.BOLD));
|
||||||
time_label.attributes.insert(attr_weight_new(Weight.BOLD));
|
change_label_attribute(time_label, attr_weight_new(Weight.BOLD));
|
||||||
nick_label.attributes.insert(attr_weight_new(Weight.BOLD));
|
change_label_attribute(nick_label, attr_weight_new(Weight.BOLD));
|
||||||
message_label.attributes.insert(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) {
|
public override void state_flags_changed(StateFlags flags) {
|
||||||
|
|
Loading…
Reference in a new issue