aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/call_window/call_window.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/call_window/call_window.vala
parentf25bfb00969a7e09996da2d5500e6718f4cc0148 (diff)
downloaddino-7e7dcedaf31ee35499875491c9f569c575d28435.tar.gz
dino-7e7dcedaf31ee35499875491c9f569c575d28435.zip
Port from GTK3 to GTK4
Diffstat (limited to 'main/src/ui/call_window/call_window.vala')
-rw-r--r--main/src/ui/call_window/call_window.vala58
1 files changed, 31 insertions, 27 deletions
diff --git a/main/src/ui/call_window/call_window.vala b/main/src/ui/call_window/call_window.vala
index ab969597..5facd574 100644
--- a/main/src/ui/call_window/call_window.vala
+++ b/main/src/ui/call_window/call_window.vala
@@ -15,13 +15,15 @@ namespace Dino.Ui {
public Grid grid = new Grid() { visible=true };
public CallBottomBar bottom_bar = new CallBottomBar() { visible=true };
public Revealer bottom_bar_revealer = new Revealer() { valign=Align.END, transition_type=RevealerTransitionType.CROSSFADE, transition_duration=200, visible=true };
- public HeaderBar header_bar = new HeaderBar() { valign=Align.START, halign=Align.END, show_close_button=true, visible=true, opacity=0.0 };
+ public HeaderBar header_bar = new HeaderBar() { valign=Align.START, halign=Align.END, show_title_buttons=true, visible=true, opacity=0.0 };
public Revealer header_bar_revealer = new Revealer() { halign=Align.END, valign=Align.START, transition_type=RevealerTransitionType.SLIDE_LEFT, transition_duration=200, visible=true, reveal_child=false };
public Box own_video_box = new Box(Orientation.HORIZONTAL, 0) { halign=Align.END, valign=Align.END, visible=true };
private Widget? own_video = null;
private HashMap<string, ParticipantWidget> participant_widgets = new HashMap<string, ParticipantWidget>();
private ArrayList<string> participants = new ArrayList<string>();
+ private EventControllerMotion this_motion_events = new EventControllerMotion();
+
private int own_video_width = 150;
private int own_video_height = 100;
@@ -31,32 +33,36 @@ namespace Dino.Ui {
construct {
header_bar.get_style_context().add_class("call-header-bar");
- header_bar.custom_title = new Box(Orientation.VERTICAL, 0);
- header_bar.spacing = 0;
- header_bar_revealer.add(header_bar);
- bottom_bar_revealer.add(bottom_bar);
+ header_bar.title_widget = new Box(Orientation.VERTICAL, 0);
+// header_bar.spacing = 0;
+ header_bar_revealer.set_child(header_bar);
+ bottom_bar_revealer.set_child(bottom_bar);
own_video_box.get_style_context().add_class("own-video");
this.get_style_context().add_class("dino-call-window");
- overlay.add(grid);
+ overlay.set_child(grid);
overlay.add_overlay(own_video_box);
overlay.add_overlay(bottom_bar_revealer);
overlay.add_overlay(header_bar_revealer);
overlay.get_child_position.connect(on_get_child_position);
- add(overlay);
+ set_child(overlay);
}
public CallWindow() {
this.bind_property("controls-active", bottom_bar_revealer, "reveal-child", BindingFlags.SYNC_CREATE);
- this.motion_notify_event.connect(reveal_control_elements);
- this.enter_notify_event.connect(reveal_control_elements);
- this.leave_notify_event.connect(reveal_control_elements);
- this.configure_event.connect(reveal_control_elements); // upon resizing
+ ((Widget) this).add_controller(this_motion_events);
+ this_motion_events.motion.connect(reveal_control_elements);
+ this_motion_events.enter.connect(reveal_control_elements);
+ this_motion_events.leave.connect(reveal_control_elements);
+
+ this.notify["default-width"].connect(reveal_control_elements);
+ this.notify["default-height"].connect(reveal_control_elements);
- this.configure_event.connect(reposition_participant_widgets);
+ this.notify["default-width"].connect(reposition_participant_widgets);
+ this.notify["default-height"].connect(reposition_participant_widgets);
this.set_titlebar(new OutsideHeaderBar(this.header_bar) { visible=true });
@@ -103,11 +109,10 @@ namespace Dino.Ui {
}
}
- private bool reposition_participant_widgets() {
- int width, height;
- this.get_size(out width,out height);
+ private void reposition_participant_widgets() {
+ int width = get_size(Orientation.HORIZONTAL);
+ int height = get_size(Orientation.VERTICAL);
reposition_participant_widgets_rec(participants, width, height, 0, 0, 0, 0);
- return false;
}
private void reposition_participant_widgets_rec(ArrayList<string> participants, int width, int height, int margin_top, int margin_right, int margin_bottom, int margin_left) {
@@ -144,14 +149,14 @@ namespace Dino.Ui {
}
public void set_own_video(Widget? widget_) {
- own_video_box.foreach((widget) => { own_video_box.remove(widget); });
+// own_video_box.foreach((widget) => { own_video_box.remove(widget); });
own_video = widget_;
if (own_video == null) {
- own_video = new Box(Orientation.HORIZONTAL, 0) { expand=true };
+ own_video = new Box(Orientation.HORIZONTAL, 0) { hexpand=true, vexpand=true };
}
own_video.visible = true;
- own_video_box.add(own_video);
+ own_video_box.append(own_video);
}
public void set_own_video_ratio(int width, int height) {
@@ -165,7 +170,7 @@ namespace Dino.Ui {
}
public void unset_own_video() {
- own_video_box.foreach((widget) => { own_video_box.remove(widget); });
+// own_video_box.foreach((widget) => { own_video_box.remove(widget); });
}
public void set_status(string participant_id, string state) {
@@ -192,13 +197,12 @@ namespace Dino.Ui {
bottom_bar.show_counterpart_ended(text);
}
- private bool reveal_control_elements() {
+ private void reveal_control_elements() {
if (!bottom_bar_revealer.child_revealed) {
controls_active = true;
}
timeout_hide_control_elements();
- return false;
}
private void timeout_hide_control_elements() {
@@ -229,8 +233,8 @@ namespace Dino.Ui {
private bool on_get_child_position(Widget widget, out Gdk.Rectangle allocation) {
if (widget == own_video_box) {
- int width, height;
- this.get_size(out width,out height);
+ int width = get_size(Orientation.HORIZONTAL);
+ int height = get_size(Orientation.VERTICAL);
allocation = Gdk.Rectangle();
allocation.width = own_video_width;
@@ -252,8 +256,8 @@ namespace Dino.Ui {
public OutsideHeaderBar(HeaderBar header_bar) {
this.header_bar = header_bar;
- size_allocate.connect_after(on_header_bar_size_allocate);
- header_bar.size_allocate.connect(on_header_bar_size_allocate);
+// size_allocate.connect_after(on_header_bar_size_allocate);
+// header_bar.size_allocate.connect(on_header_bar_size_allocate);
}
public void on_header_bar_size_allocate() {
@@ -263,7 +267,7 @@ namespace Dino.Ui {
Allocation alloc;
get_allocation(out alloc);
alloc.height = header_bar_alloc.height;
- set_allocation(alloc);
+// set_allocation(alloc);
}
}
} \ No newline at end of file