aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_titlebar/call_entry.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2022-02-14 14:55:59 +0100
committerfiaxh <git@lightrise.org>2022-07-27 20:34:20 +0200
commit7e7dcedaf31ee35499875491c9f569c575d28435 (patch)
tree0c5fee2b28baf320775fbc92b3c252e97d9d054f /main/src/ui/conversation_titlebar/call_entry.vala
parentf25bfb00969a7e09996da2d5500e6718f4cc0148 (diff)
downloaddino-7e7dcedaf31ee35499875491c9f569c575d28435.tar.gz
dino-7e7dcedaf31ee35499875491c9f569c575d28435.zip
Port from GTK3 to GTK4
Diffstat (limited to 'main/src/ui/conversation_titlebar/call_entry.vala')
-rw-r--r--main/src/ui/conversation_titlebar/call_entry.vala69
1 files changed, 26 insertions, 43 deletions
diff --git a/main/src/ui/conversation_titlebar/call_entry.vala b/main/src/ui/conversation_titlebar/call_entry.vala
index 1b8b2a05..72376126 100644
--- a/main/src/ui/conversation_titlebar/call_entry.vala
+++ b/main/src/ui/conversation_titlebar/call_entry.vala
@@ -8,65 +8,42 @@ namespace Dino.Ui {
public class CallTitlebarEntry : Plugins.ConversationTitlebarEntry, Object {
public string id { get { return "call"; } }
-
- public CallButton call_button;
-
- private StreamInteractor stream_interactor;
-
- public CallTitlebarEntry(StreamInteractor stream_interactor) {
- this.stream_interactor = stream_interactor;
-
- call_button = new CallButton(stream_interactor) { tooltip_text=_("Start call") };
- call_button.set_image(new Gtk.Image.from_icon_name("dino-phone-symbolic", Gtk.IconSize.MENU) { visible=true });
- }
-
public double order { get { return 4; } }
- public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) {
- if (type == Plugins.WidgetType.GTK) {
- return call_button;
- }
- return null;
- }
- }
- public class CallButton : Plugins.ConversationTitlebarWidget, Gtk.MenuButton {
+ private MenuButton button = new MenuButton() { tooltip_text=_("Start call") };
private StreamInteractor stream_interactor;
private Conversation conversation;
- private ModelButton audio_button = new ModelButton() { text=_("Audio call"), visible=true };
- private ModelButton video_button = new ModelButton() { text=_("Video call"), visible=true };
-
- public CallButton(StreamInteractor stream_interactor) {
+ public CallTitlebarEntry(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
- use_popover = true;
- image = new Gtk.Image.from_icon_name("dino-phone-symbolic", Gtk.IconSize.MENU) { visible=true };
+ button.set_icon_name("dino-phone-symbolic");
- Gtk.PopoverMenu popover_menu = new Gtk.PopoverMenu();
- Box box = new Box(Orientation.VERTICAL, 0) { margin=10, visible=true };
- audio_button.clicked.connect(() => {
+ Menu menu_model = new Menu();
+ menu_model.append(_("Audio call"), "call.audio");
+ menu_model.append(_("Video call"), "call.video");
+ Gtk.PopoverMenu popover_menu = new Gtk.PopoverMenu.from_model(menu_model);
+ button.popover = popover_menu;
+
+ SimpleActionGroup action_group = new SimpleActionGroup();
+ SimpleAction audio_call_action = new SimpleAction("audio", null);
+ audio_call_action.activate.connect((parameter) => {
stream_interactor.get_module(Calls.IDENTITY).initiate_call.begin(conversation, false, (_, res) => {
CallState call_state = stream_interactor.get_module(Calls.IDENTITY).initiate_call.end(res);
open_call_window(call_state);
});
});
- box.add(audio_button);
-
- video_button.clicked.connect(() => {
+ action_group.insert(audio_call_action);
+ SimpleAction video_call_action = new SimpleAction("video", null);
+ video_call_action.activate.connect((parameter) => {
stream_interactor.get_module(Calls.IDENTITY).initiate_call.begin(conversation, true, (_, res) => {
CallState call_state = stream_interactor.get_module(Calls.IDENTITY).initiate_call.end(res);
open_call_window(call_state);
});
});
- box.add(video_button);
- popover_menu.add(box);
-
- popover = popover_menu;
-
- clicked.connect(() => {
- popover_menu.visible = true;
- });
+ action_group.insert(video_call_action);
+ button.insert_action_group("call", action_group);
stream_interactor.get_module(Calls.IDENTITY).call_incoming.connect((call, state,conversation) => {
update_button_state();
@@ -96,6 +73,7 @@ namespace Dino.Ui {
}
public new void set_conversation(Conversation conversation) {
+ print(@"set_conversation $(conversation.counterpart)\n");
this.conversation = conversation;
update_visibility.begin();
@@ -103,12 +81,12 @@ namespace Dino.Ui {
}
private void update_button_state() {
- this.sensitive = !stream_interactor.get_module(Calls.IDENTITY).is_call_in_progress();
+ button.sensitive = !stream_interactor.get_module(Calls.IDENTITY).is_call_in_progress();
}
private async void update_visibility() {
if (conversation == null) {
- visible = false;
+ button.visible = false;
return;
}
@@ -116,10 +94,15 @@ namespace Dino.Ui {
bool can_do_calls = yield stream_interactor.get_module(Calls.IDENTITY).can_conversation_do_calls(conversation);
if (conv_bak != conversation) return;
- visible = video_button.visible = can_do_calls;
+ button.visible = can_do_calls;
}
public new void unset_conversation() { }
+
+ public Object? get_widget(Plugins.WidgetType type) {
+ if (type != Plugins.WidgetType.GTK4) return null;
+ return button;
+ }
}
}