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 --- .../src/ui/call_window/call_encryption_button.vala | 50 +++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'main/src/ui/call_window/call_encryption_button.vala') diff --git a/main/src/ui/call_window/call_encryption_button.vala b/main/src/ui/call_window/call_encryption_button.vala index a7081954..095db2b4 100644 --- a/main/src/ui/call_window/call_encryption_button.vala +++ b/main/src/ui/call_window/call_encryption_button.vala @@ -2,61 +2,63 @@ using Dino.Entities; using Gtk; using Pango; -public class Dino.Ui.CallEncryptionButton : MenuButton { +public class Dino.Ui.CallEncryptionButtonController { - private Image encryption_image = new Image.from_icon_name("", IconSize.BUTTON) { visible=true }; private bool has_been_set = false; public bool controls_active { get; set; default=false; } - public CallEncryptionButton() { - this.opacity = 0; - add(encryption_image); - this.set_popover(popover); + public MenuButton button; - this.notify["controls-active"].connect(update_opacity); + public CallEncryptionButtonController(MenuButton button) { + this.button = button; + + button.opacity = 0; +// button.set_popover(popover); + + button.notify["controls-active"].connect(update_opacity); } public void set_icon(bool encrypted, string? icon_name) { if (encrypted) { - encryption_image.set_from_icon_name(icon_name ?? "changes-prevent-symbolic", IconSize.BUTTON); - get_style_context().remove_class("unencrypted"); + button.icon_name = icon_name ?? "changes-prevent-symbolic"; + button.get_style_context().remove_class("unencrypted"); } else { - encryption_image.set_from_icon_name(icon_name ?? "changes-allow-symbolic", IconSize.BUTTON); - get_style_context().add_class("unencrypted"); + button.icon_name = icon_name ?? "changes-allow-symbolic"; + button.get_style_context().add_class("unencrypted"); } has_been_set = true; update_opacity(); } public void set_info(string? title, bool show_keys, Xmpp.Xep.Jingle.ContentEncryption? audio_encryption, Xmpp.Xep.Jingle.ContentEncryption? video_encryption) { - Popover popover = new Popover(this); - this.set_popover(popover); + Popover popover = new Popover(); + button.set_popover(popover); if (audio_encryption == null) { - popover.add(new Label("This call is unencrypted.") { margin=10, visible=true } ); + popover.set_child(new Label("This call is unencrypted.") { visible=true } ); return; } if (title != null && !show_keys) { - popover.add(new Label(title) { use_markup=true, margin=10, visible=true } ); + popover.set_child(new Label(title) { use_markup=true, visible=true } ); return; } - Box box = new Box(Orientation.VERTICAL, 10) { margin=10, visible=true }; - box.add(new Label("%s".printf(title ?? "This call is end-to-end encrypted.")) { use_markup=true, xalign=0, visible=true }); + Box box = new Box(Orientation.VERTICAL, 10) { visible=true }; + box.append(new Label("%s".printf(title ?? "This call is end-to-end encrypted.")) { use_markup=true, xalign=0, visible=true }); if (video_encryption == null) { - box.add(create_media_encryption_grid(audio_encryption)); + box.append(create_media_encryption_grid(audio_encryption)); } else { - box.add(new Label("Audio") { use_markup=true, xalign=0, visible=true }); - box.add(create_media_encryption_grid(audio_encryption)); - box.add(new Label("Video") { use_markup=true, xalign=0, visible=true }); - box.add(create_media_encryption_grid(video_encryption)); + box.append(new Label("Audio") { use_markup=true, xalign=0, visible=true }); + box.append(create_media_encryption_grid(audio_encryption)); + box.append(new Label("Video") { use_markup=true, xalign=0, visible=true }); + box.append(create_media_encryption_grid(video_encryption)); } - popover.add(box); + popover.set_child(box); } public void update_opacity() { - this.opacity = controls_active && has_been_set ? 1 : 0; + button.opacity = controls_active && has_been_set ? 1 : 0; } private Grid create_media_encryption_grid(Xmpp.Xep.Jingle.ContentEncryption? encryption) { -- cgit v1.2.3-54-g00ecf