fractal/components/
custom_entry.rs

1use adw::subclass::prelude::*;
2use gtk::glib;
3
4mod imp {
5    use super::*;
6
7    #[derive(Debug, Default)]
8    pub struct CustomEntry {}
9
10    #[glib::object_subclass]
11    impl ObjectSubclass for CustomEntry {
12        const NAME: &'static str = "CustomEntry";
13        type Type = super::CustomEntry;
14        type ParentType = adw::Bin;
15
16        fn class_init(klass: &mut Self::Class) {
17            klass.set_css_name("entry");
18        }
19    }
20
21    impl ObjectImpl for CustomEntry {}
22    impl WidgetImpl for CustomEntry {}
23    impl BinImpl for CustomEntry {}
24}
25
26glib::wrapper! {
27    /// Wrapper object acting as an entry.
28    ///
29    /// Wrap your custom widgets with CustomEntry to get stock entry styling and
30    /// behavior for free.
31    pub struct CustomEntry(ObjectSubclass<imp::CustomEntry>)
32        @extends gtk::Widget, adw::Bin;
33}
34
35impl CustomEntry {
36    pub fn new() -> Self {
37        glib::Object::new()
38    }
39}