fractal/identity_verification_view/
room_left_page.rs1use adw::subclass::prelude::*;
2use gtk::{glib, prelude::*, CompositeTemplate};
3
4use crate::session::model::IdentityVerification;
5
6mod imp {
7 use glib::subclass::InitializingObject;
8
9 use super::*;
10
11 #[derive(Debug, Default, 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, @implements gtk::Accessible;
54}
55
56#[gtk::template_callbacks]
57impl RoomLeftPage {
58 pub fn new() -> Self {
59 glib::Object::new()
60 }
61
62 #[template_callback]
64 fn dismiss(&self) {
65 let Some(verification) = self.verification() else {
66 return;
67 };
68 verification.dismiss();
69 }
70}