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_titlebar/occupants_entry.vala | 42 ++++++++-------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'main/src/ui/conversation_titlebar/occupants_entry.vala') diff --git a/main/src/ui/conversation_titlebar/occupants_entry.vala b/main/src/ui/conversation_titlebar/occupants_entry.vala index a316be20..5c0da99b 100644 --- a/main/src/ui/conversation_titlebar/occupants_entry.vala +++ b/main/src/ui/conversation_titlebar/occupants_entry.vala @@ -6,53 +6,39 @@ namespace Dino.Ui { class OccupantsEntry : Plugins.ConversationTitlebarEntry, Object { public string id { get { return "occupants"; } } + public double order { get { return 3; } } StreamInteractor stream_interactor; - OccupantsWidget widget; - - public OccupantsEntry(StreamInteractor stream_interactor) { - this.stream_interactor = stream_interactor; - } - - public double order { get { return 3; } } - public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) { - if (type == Plugins.WidgetType.GTK) { - if (widget == null) { - widget = new OccupantsWidget(stream_interactor); - } - return widget; - } - return null; - } -} + private Conversation? conversation; -class OccupantsWidget : MenuButton, Plugins.ConversationTitlebarWidget { + private MenuButton button = new MenuButton() { icon_name="system-users-symbolic", tooltip_text=_("Members") }; - private Conversation? conversation; - private StreamInteractor stream_interactor; private OccupantMenu.View menu = null; - public OccupantsWidget(StreamInteractor stream_interactor) { - image = new Image.from_icon_name("system-users-symbolic", IconSize.MENU); - tooltip_text = _("Members"); - + public OccupantsEntry(StreamInteractor stream_interactor) { this.stream_interactor = stream_interactor; - set_use_popover(true); } public new void set_conversation(Conversation conversation) { this.conversation = conversation; - visible = conversation.type_ == Conversation.Type.GROUPCHAT; if (conversation.type_ == Conversation.Type.GROUPCHAT) { + button.visible = true; OccupantMenu.View new_menu = new OccupantMenu.View(stream_interactor, conversation); - set_popover(new_menu); + button.set_popover(new_menu); menu = new_menu; + } else { + button.visible = false; } } public new void unset_conversation() { - visible = false; + button.visible = false; + } + + public Object? get_widget(Plugins.WidgetType type) { + if (type != Plugins.WidgetType.GTK4) return null; + return button; } } -- cgit v1.2.3-54-g00ecf