From db3b0d5f233ee3587ae54f8f035222cb098b11dd Mon Sep 17 00:00:00 2001 From: Marvin W Date: Tue, 24 Jan 2023 18:59:46 +0100 Subject: New Avatar UI --- .../ui/conversation_content_view/call_widget.vala | 16 +++++++-------- .../chat_state_populator.vala | 24 ++++++++++++++++------ .../conversation_item_skeleton.vala | 17 +++++++-------- .../ui/conversation_content_view/quote_widget.vala | 4 ++-- 4 files changed, 37 insertions(+), 24 deletions(-) (limited to 'main/src/ui/conversation_content_view') diff --git a/main/src/ui/conversation_content_view/call_widget.vala b/main/src/ui/conversation_content_view/call_widget.vala index 4f7e2953..ab047196 100644 --- a/main/src/ui/conversation_content_view/call_widget.vala +++ b/main/src/ui/conversation_content_view/call_widget.vala @@ -94,15 +94,15 @@ namespace Dino.Ui { } foreach (Jid counterpart in call.counterparts) { - AvatarImage image = new AvatarImage() { force_gray=true, margin_top=2 }; - image.set_conversation_participant(stream_interactor, conversation, counterpart.bare_jid); - multiparty_peer_box.append(image); - multiparty_peer_widgets.add(image); + AvatarPicture picture = new AvatarPicture() { margin_top=2 }; + picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).add_participant(conversation, counterpart.bare_jid); + multiparty_peer_box.append(picture); + multiparty_peer_widgets.add(picture); } - AvatarImage image2 = new AvatarImage() { force_gray=true, margin_top=2 }; - image2.set_conversation_participant(stream_interactor, conversation, call.account.bare_jid); - multiparty_peer_box.append(image2); - multiparty_peer_widgets.add(image2); + AvatarPicture picture2 = new AvatarPicture() { margin_top=2 }; + picture2.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).add_participant(conversation, call.account.bare_jid); + multiparty_peer_box.append(picture2); + multiparty_peer_widgets.add(picture2); outer_additional_box.add_css_class("multiparty-participants"); diff --git a/main/src/ui/conversation_content_view/chat_state_populator.vala b/main/src/ui/conversation_content_view/chat_state_populator.vala index 803739c8..2f02c635 100644 --- a/main/src/ui/conversation_content_view/chat_state_populator.vala +++ b/main/src/ui/conversation_content_view/chat_state_populator.vala @@ -68,7 +68,7 @@ private class MetaChatStateItem : Plugins.MetaConversationItem { private Conversation conversation; private Gee.List jids = new ArrayList(); private Label label; - private AvatarImage image; + private AvatarPicture picture; public MetaChatStateItem(StreamInteractor stream_interactor, Conversation conversation, Gee.List jids) { this.stream_interactor = stream_interactor; @@ -79,10 +79,10 @@ private class MetaChatStateItem : Plugins.MetaConversationItem { public override Object? get_widget(Plugins.ConversationItemWidgetInterface outer, Plugins.WidgetType widget_type) { label = new Label("") { xalign=0, vexpand=true }; label.add_css_class("dim-label"); - image = new AvatarImage() { margin_top=2, valign=Align.START }; + picture = new AvatarPicture() { margin_top=2, valign=Align.START }; Box image_content_box = new Box(Orientation.HORIZONTAL, 8); - image_content_box.append(image); + image_content_box.append(picture); image_content_box.append(label); update(); @@ -97,9 +97,7 @@ private class MetaChatStateItem : Plugins.MetaConversationItem { } private void update() { - if (image == null || label == null) return; - - image.set_conversation_participants(stream_interactor, conversation, jids.to_array()); + if (picture == null || label == null) return; Gee.List display_names = new ArrayList(); foreach (Jid jid in jids) { @@ -108,12 +106,26 @@ private class MetaChatStateItem : Plugins.MetaConversationItem { string new_text = ""; if (jids.size > 3) { new_text = _("%s, %s and %i others are typing…").printf(display_names[0], display_names[1], jids.size - 2); + picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor) + .add_participant(conversation, jids[0]) + .add_participant(conversation, jids[1]) + .add_participant(conversation, jids[2]) + .add("+"); } else if (jids.size == 3) { new_text = _("%s, %s and %s are typing…").printf(display_names[0], display_names[1], display_names[2]); + picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor) + .add_participant(conversation, jids[0]) + .add_participant(conversation, jids[1]) + .add_participant(conversation, jids[2]); } else if (jids.size == 2) { new_text =_("%s and %s are typing…").printf(display_names[0], display_names[1]); + picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor) + .add_participant(conversation, jids[0]) + .add_participant(conversation, jids[1]); } else { new_text = _("%s is typing…").printf(display_names[0]); + picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor) + .add_participant(conversation, jids[0]); } label.label = new_text; 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 bbde76b1..5d86f6c7 100644 --- a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala +++ b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala @@ -12,7 +12,7 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, public Grid main_grid { get; set; } public Label name_label { get; set; } public Label time_label { get; set; } - public AvatarImage avatar_image { get; set; } + public AvatarPicture avatar_picture { get; set; } public Image encryption_image { get; set; } public Image received_image { get; set; } @@ -51,7 +51,7 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, main_grid.add_css_class("message-box"); name_label = (Label) builder.get_object("name_label"); time_label = (Label) builder.get_object("time_label"); - avatar_image = (AvatarImage) builder.get_object("avatar_image"); + avatar_picture = (AvatarPicture) builder.get_object("avatar_picture"); encryption_image = (Image) builder.get_object("encrypted_image"); received_image = (Image) builder.get_object("marked_image"); @@ -62,7 +62,8 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, } if (item.requires_header) { - avatar_image.set_conversation_participant(stream_interactor, conversation, item.jid); + // TODO: For MUC messags, use real jid from message if known + avatar_picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).add_participant(conversation, item.jid); } this.notify["show-skeleton"].connect(update_margin); @@ -116,7 +117,7 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, } private void update_margin() { - avatar_image.visible = show_skeleton; + avatar_picture.visible = show_skeleton; name_label.visible = show_skeleton; time_label.visible = show_skeleton; encryption_image.visible = show_skeleton; @@ -286,10 +287,10 @@ public class ConversationItemSkeleton : Plugins.ConversationItemWidgetInterface, time_label.dispose(); time_label = null; } - if (avatar_image != null) { - avatar_image.unparent(); - avatar_image.dispose(); - avatar_image = null; + if (avatar_picture != null) { + avatar_picture.unparent(); + avatar_picture.dispose(); + avatar_picture = null; } if (encryption_image != null) { encryption_image.unparent(); diff --git a/main/src/ui/conversation_content_view/quote_widget.vala b/main/src/ui/conversation_content_view/quote_widget.vala index 6dbf459c..23b62e6a 100644 --- a/main/src/ui/conversation_content_view/quote_widget.vala +++ b/main/src/ui/conversation_content_view/quote_widget.vala @@ -61,13 +61,13 @@ namespace Dino.Ui.Quote { public Widget get_widget(Model model) { Builder builder = new Builder.from_resource("/im/dino/Dino/quote.ui"); - AvatarImage avatar = (AvatarImage) builder.get_object("avatar"); + AvatarPicture avatar = (AvatarPicture) builder.get_object("avatar"); Label author = (Label) builder.get_object("author"); Label time = (Label) builder.get_object("time"); Label message = (Label) builder.get_object("message"); Button abort_button = (Button) builder.get_object("abort-button"); - avatar.set_conversation_participant(model.stream_interactor, model.conversation, model.author_jid); + avatar.model = new ViewModel.CompatAvatarPictureModel(model.stream_interactor).add_participant(model.conversation, model.author_jid); model.bind_property("display-name", author, "label", BindingFlags.SYNC_CREATE); model.bind_property("display-time", time, "label", BindingFlags.SYNC_CREATE); model.bind_property("message", message, "label", BindingFlags.SYNC_CREATE); -- cgit v1.2.3-54-g00ecf