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 --- main/src/ui/conversation_titlebar/menu_entry.vala | 44 ++++++++--------------- 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'main/src/ui/conversation_titlebar/menu_entry.vala') diff --git a/main/src/ui/conversation_titlebar/menu_entry.vala b/main/src/ui/conversation_titlebar/menu_entry.vala index 9b3b6ee2..28a06c24 100644 --- a/main/src/ui/conversation_titlebar/menu_entry.vala +++ b/main/src/ui/conversation_titlebar/menu_entry.vala @@ -6,58 +6,42 @@ namespace Dino.Ui { class MenuEntry : Plugins.ConversationTitlebarEntry, Object { public string id { get { return "menu"; } } - - StreamInteractor stream_interactor; - MenuWidget widget; - - public MenuEntry(StreamInteractor stream_interactor) { - this.stream_interactor = stream_interactor; - } - public double order { get { return 0; } } - public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) { - if (type == Plugins.WidgetType.GTK) { - if (widget == null) { - widget = new MenuWidget(stream_interactor) { visible=true, sensitive=false }; - } - return widget; - } - return null; - } -} -class MenuWidget : Button, Plugins.ConversationTitlebarWidget { - - private StreamInteractor stream_interactor; + StreamInteractor stream_interactor; private Conversation? conversation; - public MenuWidget(StreamInteractor stream_interactor) { + Button button = new Button() { icon_name="open-menu-symbolic" }; + + public MenuEntry(StreamInteractor stream_interactor) { this.stream_interactor = stream_interactor; - image = new Image.from_icon_name("open-menu-symbolic", IconSize.MENU); - clicked.connect(on_clicked); + button.clicked.connect(on_clicked); } public new void set_conversation(Conversation conversation) { - this.sensitive = true; + button.sensitive = true; this.conversation = conversation; if (conversation.type_ == Conversation.Type.GROUPCHAT) { - tooltip_text = "Channel details"; + button.tooltip_text = "Channel details"; } else { - tooltip_text = "Conversation details"; + button.tooltip_text = "Conversation details"; } } public new void unset_conversation() { - this.sensitive = false; + button.sensitive = false; } private void on_clicked() { ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation); - contact_details_dialog.set_transient_for((Window) get_toplevel()); + contact_details_dialog.set_transient_for((Window) button.get_root()); contact_details_dialog.present(); } + public Object? get_widget(Plugins.WidgetType type) { + if (type != Plugins.WidgetType.GTK4) return null; + return button; + } } - } -- cgit v1.2.3-54-g00ecf