aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/call_window/call_encryption_button.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_encryption_button.vala
parentf25bfb00969a7e09996da2d5500e6718f4cc0148 (diff)
downloaddino-7e7dcedaf31ee35499875491c9f569c575d28435.tar.gz
dino-7e7dcedaf31ee35499875491c9f569c575d28435.zip
Port from GTK3 to GTK4
Diffstat (limited to 'main/src/ui/call_window/call_encryption_button.vala')
-rw-r--r--main/src/ui/call_window/call_encryption_button.vala50
1 files changed, 26 insertions, 24 deletions
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("<b>%s</b>".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("<b>%s</b>".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("<b>Audio</b>") { use_markup=true, xalign=0, visible=true });
- box.add(create_media_encryption_grid(audio_encryption));
- box.add(new Label("<b>Video</b>") { use_markup=true, xalign=0, visible=true });
- box.add(create_media_encryption_grid(video_encryption));
+ box.append(new Label("<b>Audio</b>") { use_markup=true, xalign=0, visible=true });
+ box.append(create_media_encryption_grid(audio_encryption));
+ box.append(new Label("<b>Video</b>") { 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) {