aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_content_view
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-04-08 12:07:04 +0200
committerfiaxh <git@lightrise.org>2021-04-09 22:23:13 +0200
commit8d1c6c29be7018c74ec3f8ea05f5849eac5b4069 (patch)
treedde27c13cd0ae8af31b9194b3450c58d4fe9cf02 /main/src/ui/conversation_content_view
parent3454201e5a3da058ccbef0bbaf467599912a8c38 (diff)
downloaddino-8d1c6c29be7018c74ec3f8ea05f5849eac5b4069.tar.gz
dino-8d1c6c29be7018c74ec3f8ea05f5849eac5b4069.zip
Display+store call encryption info
Diffstat (limited to 'main/src/ui/conversation_content_view')
-rw-r--r--main/src/ui/conversation_content_view/content_populator.vala1
-rw-r--r--main/src/ui/conversation_content_view/conversation_item_skeleton.vala74
2 files changed, 46 insertions, 29 deletions
diff --git a/main/src/ui/conversation_content_view/content_populator.vala b/main/src/ui/conversation_content_view/content_populator.vala
index d7ce9ce5..ef859bde 100644
--- a/main/src/ui/conversation_content_view/content_populator.vala
+++ b/main/src/ui/conversation_content_view/content_populator.vala
@@ -88,6 +88,7 @@ public abstract class ContentMetaItem : Plugins.MetaConversationItem {
this.mark = content_item.mark;
content_item.bind_property("mark", this, "mark");
+ content_item.bind_property("encryption", this, "encryption");
this.can_merge = true;
this.requires_avatar = true;
diff --git a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
index c0099bf4..bcb6864e 100644
--- a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
+++ b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
@@ -104,7 +104,7 @@ public class ItemMetaDataHeader : Box {
[GtkChild] public Label dot_label;
[GtkChild] public Label time_label;
public Image received_image = new Image() { opacity=0.4 };
- public Image? unencrypted_image = null;
+ public Widget? encryption_image = null;
public static IconSize ICON_SIZE_HEADER = Gtk.icon_size_register("im.dino.Dino.HEADER_ICON", 17, 12);
@@ -124,50 +124,66 @@ public class ItemMetaDataHeader : Box {
update_name_label();
name_label.style_updated.connect(update_name_label);
+ conversation.notify["encryption"].connect(update_unencrypted_icon);
+ item.notify["encryption"].connect(update_encryption_icon);
+ update_encryption_icon();
+
+ this.add(received_image);
+
+ if (item.time != null) {
+ update_time();
+ }
+
+ item.bind_property("mark", this, "item-mark");
+ this.notify["item-mark"].connect_after(update_received_mark);
+ update_received_mark();
+ }
+
+ private void update_encryption_icon() {
Application app = GLib.Application.get_default() as Application;
ContentMetaItem ci = item as ContentMetaItem;
- if (ci != null) {
+ if (item.encryption != Encryption.NONE && ci != null) {
+ Widget? widget = null;
foreach(var e in app.plugin_registry.encryption_list_entries) {
if (e.encryption == item.encryption) {
- Object? w = e.get_encryption_icon(conversation, ci.content_item);
- if (w != null) {
- this.add(w as Widget);
- } else {
- Image image = new Image.from_icon_name("dino-changes-prevent-symbolic", ICON_SIZE_HEADER) { opacity=0.4, visible = true };
- this.add(image);
- }
+ widget = e.get_encryption_icon(conversation, ci.content_item) as Widget;
break;
}
}
+ if (widget == null) {
+ widget = new Image.from_icon_name("dino-changes-prevent-symbolic", ICON_SIZE_HEADER) { opacity=0.4, visible = true };
+ }
+ update_encryption_image(widget);
}
if (item.encryption == Encryption.NONE) {
- conversation.notify["encryption"].connect(update_unencrypted_icon);
update_unencrypted_icon();
}
+ }
- this.add(received_image);
-
- if (item.time != null) {
- update_time();
+ private void update_unencrypted_icon() {
+ if (item.encryption != Encryption.NONE) return;
+
+ if (conversation.encryption != Encryption.NONE && encryption_image == null) {
+ Image image = new Image() { opacity=0.4, visible = true };
+ image.set_from_icon_name("dino-changes-allowed-symbolic", ICON_SIZE_HEADER);
+ image.tooltip_text = _("Unencrypted");
+ update_encryption_image(image);
+ Util.force_error_color(image);
+ } else if (conversation.encryption == Encryption.NONE && encryption_image != null) {
+ update_encryption_image(null);
}
-
- item.bind_property("mark", this, "item-mark");
- this.notify["item-mark"].connect_after(update_received_mark);
- update_received_mark();
}
- private void update_unencrypted_icon() {
- if (conversation.encryption != Encryption.NONE && unencrypted_image == null) {
- unencrypted_image = new Image() { opacity=0.4, visible = true };
- unencrypted_image.set_from_icon_name("dino-changes-allowed-symbolic", ICON_SIZE_HEADER);
- unencrypted_image.tooltip_text = _("Unencrypted");
- this.add(unencrypted_image);
- this.reorder_child(unencrypted_image, 3);
- Util.force_error_color(unencrypted_image);
- } else if (conversation.encryption == Encryption.NONE && unencrypted_image != null) {
- this.remove(unencrypted_image);
- unencrypted_image = null;
+ private void update_encryption_image(Widget? widget) {
+ if (encryption_image != null) {
+ this.remove(encryption_image);
+ encryption_image = null;
+ }
+ if (widget != null) {
+ this.add(widget);
+ this.reorder_child(widget, 3);
+ encryption_image = widget;
}
}