Skip to main content

fractal/utils/
placeholder_object.rs

1use gtk::{glib, prelude::*, subclass::prelude::*};
2
3mod imp {
4    use std::cell::RefCell;
5
6    use super::*;
7
8    #[derive(Debug, Default, glib::Properties)]
9    #[properties(wrapper_type = super::PlaceholderObject)]
10    pub struct PlaceholderObject {
11        /// The identifier of this item.
12        #[property(get, set)]
13        id: RefCell<String>,
14    }
15
16    #[glib::object_subclass]
17    impl ObjectSubclass for PlaceholderObject {
18        const NAME: &'static str = "PlaceholderObject";
19        type Type = super::PlaceholderObject;
20    }
21
22    #[glib::derived_properties]
23    impl ObjectImpl for PlaceholderObject {}
24}
25
26glib::wrapper! {
27    /// A GObject to use as a placeholder.
28    ///
29    /// It can be used for example to add extra widgets in a list model and can
30    /// be identified with its ID.
31    pub struct PlaceholderObject(ObjectSubclass<imp::PlaceholderObject>);
32}
33
34impl PlaceholderObject {
35    pub fn new(id: &str) -> Self {
36        glib::Object::builder().property("id", id).build()
37    }
38}