fractal/components/
custom_entry.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use adw::subclass::prelude::*;
use gtk::glib;

mod imp {
    use super::*;

    #[derive(Debug, Default)]
    pub struct CustomEntry {}

    #[glib::object_subclass]
    impl ObjectSubclass for CustomEntry {
        const NAME: &'static str = "CustomEntry";
        type Type = super::CustomEntry;
        type ParentType = adw::Bin;

        fn class_init(klass: &mut Self::Class) {
            klass.set_css_name("entry");
        }
    }

    impl ObjectImpl for CustomEntry {}
    impl WidgetImpl for CustomEntry {}
    impl BinImpl for CustomEntry {}
}

glib::wrapper! {
    /// Wrapper object acting as an entry.
    ///
    /// Wrap your custom widgets with CustomEntry to get stock entry styling and
    /// behavior for free.
    pub struct CustomEntry(ObjectSubclass<imp::CustomEntry>)
        @extends gtk::Widget, adw::Bin;
}

impl CustomEntry {
    pub fn new() -> Self {
        glib::Object::new()
    }
}