authenticator/widgets/
camera_row.rs1use gtk::{glib, prelude::*, subclass::prelude::*};
2
3mod imp {
4 use super::*;
5
6 #[derive(Default)]
7 pub struct CameraRow {
8 pub label: gtk::Label,
9 pub checkmark: gtk::Image,
10 }
11
12 #[glib::object_subclass]
13 impl ObjectSubclass for CameraRow {
14 const NAME: &'static str = "CameraRow";
15 type Type = super::CameraRow;
16 type ParentType = gtk::Box;
17 }
18
19 impl ObjectImpl for CameraRow {
20 fn constructed(&self) {
21 self.parent_constructed();
22 let obj = self.obj();
23
24 obj.set_spacing(6);
25 self.checkmark.set_icon_name(Some("object-select-symbolic"));
26 self.checkmark.set_visible(false);
27
28 obj.append(&self.label);
29 obj.append(&self.checkmark);
30 }
31 }
32 impl WidgetImpl for CameraRow {}
33 impl BoxImpl for CameraRow {}
34}
35
36glib::wrapper! {
37 pub struct CameraRow(ObjectSubclass<imp::CameraRow>)
38 @extends gtk::Widget, gtk::Box,
39 @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
40}
41
42impl Default for CameraRow {
43 fn default() -> Self {
44 glib::Object::new()
45 }
46}
47
48impl CameraRow {
49 pub fn set_label(&self, label: &str) {
50 self.imp().label.set_label(label);
51 }
52
53 pub fn set_selected(&self, selected: bool) {
54 self.imp().checkmark.set_visible(selected);
55 }
56}