fractal/identity_verification_view/
room_left_page.rs1use adw::{prelude::*, subclass::prelude::*};
2use gtk::glib;
3
4use crate::session::IdentityVerification;
5
6mod imp {
7 use glib::subclass::InitializingObject;
8
9 use super::*;
10
11 #[derive(Debug, Default, gtk::CompositeTemplate, glib::Properties)]
12 #[template(resource = "/org/gnome/Fractal/ui/identity_verification_view/room_left_page.ui")]
13 #[properties(wrapper_type = super::RoomLeftPage)]
14 pub struct RoomLeftPage {
15 #[property(get, set, nullable)]
17 pub verification: glib::WeakRef<IdentityVerification>,
18 #[template_child]
19 pub dismiss_btn: TemplateChild<gtk::Button>,
20 }
21
22 #[glib::object_subclass]
23 impl ObjectSubclass for RoomLeftPage {
24 const NAME: &'static str = "IdentityVerificationRoomLeftPage";
25 type Type = super::RoomLeftPage;
26 type ParentType = adw::Bin;
27
28 fn class_init(klass: &mut Self::Class) {
29 Self::bind_template(klass);
30 Self::Type::bind_template_callbacks(klass);
31 }
32
33 fn instance_init(obj: &InitializingObject<Self>) {
34 obj.init_template();
35 }
36 }
37
38 #[glib::derived_properties]
39 impl ObjectImpl for RoomLeftPage {}
40
41 impl WidgetImpl for RoomLeftPage {
42 fn grab_focus(&self) -> bool {
43 self.dismiss_btn.grab_focus()
44 }
45 }
46
47 impl BinImpl for RoomLeftPage {}
48}
49
50glib::wrapper! {
51 pub struct RoomLeftPage(ObjectSubclass<imp::RoomLeftPage>)
53 @extends gtk::Widget, adw::Bin,
54 @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
55}
56
57#[gtk::template_callbacks]
58impl RoomLeftPage {
59 pub fn new() -> Self {
60 glib::Object::new()
61 }
62
63 #[template_callback]
65 fn dismiss(&self) {
66 let Some(verification) = self.verification() else {
67 return;
68 };
69 verification.dismiss();
70 }
71}