From 7e7dcedaf31ee35499875491c9f569c575d28435 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 14 Feb 2022 14:55:59 +0100 Subject: Port from GTK3 to GTK4 --- .../ui/conversation_content_view/call_widget.vala | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'main/src/ui/conversation_content_view/call_widget.vala') diff --git a/main/src/ui/conversation_content_view/call_widget.vala b/main/src/ui/conversation_content_view/call_widget.vala index e45792e2..645c31c1 100644 --- a/main/src/ui/conversation_content_view/call_widget.vala +++ b/main/src/ui/conversation_content_view/call_widget.vala @@ -17,7 +17,7 @@ namespace Dino.Ui { this.stream_interactor = stream_interactor; } - public override Object? get_widget(Plugins.WidgetType type) { + public override Object? get_widget(Plugins.ConversationItemWidgetInterface outer, Plugins.WidgetType type) { CallItem call_item = content_item as CallItem; CallState? call_state = stream_interactor.get_module(Calls.IDENTITY).call_states[call_item.call]; return new CallWidget(stream_interactor, call_item.call, call_state, call_item.conversation) { visible=true }; @@ -45,6 +45,7 @@ namespace Dino.Ui { private Conversation conversation; public Call.State call_state { get; set; } // needs to be public for binding private uint time_update_handler_id = 0; + private ArrayList multiparty_peer_widgets = new ArrayList(); construct { margin_top = 4; @@ -58,11 +59,11 @@ namespace Dino.Ui { this.call = call; this.conversation = conversation; - size_allocate.connect((allocation) => { - if (allocation.height > parent.get_allocated_height()) { - Idle.add(() => { parent.queue_resize(); return false; }); - } - }); +// size_allocate.connect((allocation) => { +// if (allocation.height > parent.get_allocated_height()) { +// Idle.add(() => { parent.queue_resize(); return false; }); +// } +// }); call.bind_property("state", this, "call-state"); this.notify["call-state"].connect(update_call_state); @@ -88,16 +89,20 @@ namespace Dino.Ui { if (call.state != Call.State.IN_PROGRESS && call.state != Call.State.ENDED) return; if (call.counterparts.size <= 1 && conversation.type_ == Conversation.Type.CHAT) return; - multiparty_peer_box.foreach((widget) => { multiparty_peer_box.remove(widget); }); + foreach (Widget peer_widget in multiparty_peer_widgets) { + multiparty_peer_box.remove(peer_widget); + } foreach (Jid counterpart in call.counterparts) { AvatarImage image = new AvatarImage() { force_gray=true, margin_top=2, visible=true }; image.set_conversation_participant(stream_interactor, conversation, counterpart.bare_jid); - multiparty_peer_box.add(image); + multiparty_peer_box.append(image); + multiparty_peer_widgets.add(image); } AvatarImage image2 = new AvatarImage() { force_gray=true, margin_top=2, visible=true }; image2.set_conversation_participant(stream_interactor, conversation, call.account.bare_jid); - multiparty_peer_box.add(image2); + multiparty_peer_box.append(image2); + multiparty_peer_widgets.add(image2); outer_additional_box.get_style_context().add_class("multiparty-participants"); @@ -121,7 +126,7 @@ namespace Dino.Ui { switch (relevant_state) { case Call.State.RINGING: - image.set_from_icon_name("dino-phone-ring-symbolic", IconSize.LARGE_TOOLBAR); + image.set_from_icon_name("dino-phone-ring-symbolic"); if (call.direction == Call.DIRECTION_INCOMING) { bool video = call_manager.should_we_send_video(); @@ -146,7 +151,7 @@ namespace Dino.Ui { break; case Call.State.ESTABLISHING: case Call.State.IN_PROGRESS: - image.set_from_icon_name("dino-phone-in-talk-symbolic", IconSize.LARGE_TOOLBAR); + image.set_from_icon_name("dino-phone-in-talk-symbolic"); title_label.label = _("Call started"); string duration = get_duration_string((new DateTime.now_utc()).difference(call.local_time)); subtitle_label.label = _("Started %s ago").printf(duration); @@ -162,13 +167,13 @@ namespace Dino.Ui { break; case Call.State.OTHER_DEVICE: - image.set_from_icon_name("dino-phone-hangup-symbolic", IconSize.LARGE_TOOLBAR); + image.set_from_icon_name("dino-phone-hangup-symbolic"); title_label.label = call.direction == Call.DIRECTION_INCOMING ? _("Incoming call") : _("Outgoing call"); subtitle_label.label = _("You handled this call on another device"); break; case Call.State.ENDED: - image.set_from_icon_name("dino-phone-hangup-symbolic", IconSize.LARGE_TOOLBAR); + image.set_from_icon_name("dino-phone-hangup-symbolic"); title_label.label = _("Call ended"); string formated_end = Util.format_time(call.end_time, _("%H∶%M"), _("%l∶%M %p")); string duration = get_duration_string(call.end_time.difference(call.local_time)); @@ -177,7 +182,7 @@ namespace Dino.Ui { _("Lasted %s").printf(duration); break; case Call.State.MISSED: - image.set_from_icon_name("dino-phone-missed-symbolic", IconSize.LARGE_TOOLBAR); + image.set_from_icon_name("dino-phone-missed-symbolic"); title_label.label = _("Call missed"); if (call.direction == Call.DIRECTION_INCOMING) { subtitle_label.label = _("You missed this call"); @@ -187,7 +192,7 @@ namespace Dino.Ui { } break; case Call.State.DECLINED: - image.set_from_icon_name("dino-phone-hangup-symbolic", IconSize.LARGE_TOOLBAR); + image.set_from_icon_name("dino-phone-hangup-symbolic"); title_label.label = _("Call declined"); if (call.direction == Call.DIRECTION_INCOMING) { subtitle_label.label = _("You declined this call"); @@ -197,7 +202,7 @@ namespace Dino.Ui { } break; case Call.State.FAILED: - image.set_from_icon_name("dino-phone-hangup-symbolic", IconSize.LARGE_TOOLBAR); + image.set_from_icon_name("dino-phone-hangup-symbolic"); title_label.label = _("Call failed"); subtitle_label.label = "Call failed to establish"; break; -- cgit v1.2.3-70-g09d2