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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{BuilderScope, ListItemFactory};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// [`BuilderListItemFactory`][crate::BuilderListItemFactory] is a [`ListItemFactory`][crate::ListItemFactory] that creates
    /// widgets by instantiating [`Builder`][crate::Builder] UI templates.
    ///
    /// The templates must be extending [`ListItem`][crate::ListItem], and typically use
    /// [`Expression`][crate::Expression]s to obtain data from the items in the model.
    ///
    /// Example:
    /// ```xml
    ///   <interface>
    ///     <template class="GtkListItem">
    ///       <property name="child">
    ///         <object class="GtkLabel">
    ///           <property name="xalign">0</property>
    ///           <binding name="label">
    ///             <lookup name="name" type="SettingsKey">
    ///               <lookup name="item">GtkListItem</lookup>
    ///             </lookup>
    ///           </binding>
    ///         </object>
    ///       </property>
    ///     </template>
    ///   </interface>
    /// ```
    ///
    /// ## Properties
    ///
    ///
    /// #### `bytes`
    ///  `GBytes` containing the UI definition.
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `resource`
    ///  Path of the resource containing the UI definition.
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `scope`
    ///  [`BuilderScope`][crate::BuilderScope] to use when instantiating listitems
    ///
    /// Readable | Writeable | Construct Only
    ///
    /// # Implements
    ///
    /// [`ListItemFactoryExt`][trait@crate::prelude::ListItemFactoryExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "GtkBuilderListItemFactory")]
    pub struct BuilderListItemFactory(Object<ffi::GtkBuilderListItemFactory, ffi::GtkBuilderListItemFactoryClass>) @extends ListItemFactory;

    match fn {
        type_ => || ffi::gtk_builder_list_item_factory_get_type(),
    }
}

impl BuilderListItemFactory {
    /// Creates a new [`BuilderListItemFactory`][crate::BuilderListItemFactory] that instantiates widgets
    /// using @bytes as the data to pass to [`Builder`][crate::Builder].
    /// ## `scope`
    /// A scope to use when instantiating
    /// ## `bytes`
    /// the `GBytes` containing the ui file to instantiate
    ///
    /// # Returns
    ///
    /// a new [`BuilderListItemFactory`][crate::BuilderListItemFactory]
    #[doc(alias = "gtk_builder_list_item_factory_new_from_bytes")]
    #[doc(alias = "new_from_bytes")]
    pub fn from_bytes(
        scope: Option<&impl IsA<BuilderScope>>,
        bytes: &glib::Bytes,
    ) -> BuilderListItemFactory {
        assert_initialized_main_thread!();
        unsafe {
            ListItemFactory::from_glib_full(ffi::gtk_builder_list_item_factory_new_from_bytes(
                scope.map(|p| p.as_ref()).to_glib_none().0,
                bytes.to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }

    /// Creates a new [`BuilderListItemFactory`][crate::BuilderListItemFactory] that instantiates widgets
    /// using data read from the given @resource_path to pass to [`Builder`][crate::Builder].
    /// ## `scope`
    /// A scope to use when instantiating
    /// ## `resource_path`
    /// valid path to a resource that contains the data
    ///
    /// # Returns
    ///
    /// a new [`BuilderListItemFactory`][crate::BuilderListItemFactory]
    #[doc(alias = "gtk_builder_list_item_factory_new_from_resource")]
    #[doc(alias = "new_from_resource")]
    pub fn from_resource(
        scope: Option<&impl IsA<BuilderScope>>,
        resource_path: &str,
    ) -> BuilderListItemFactory {
        assert_initialized_main_thread!();
        unsafe {
            ListItemFactory::from_glib_full(ffi::gtk_builder_list_item_factory_new_from_resource(
                scope.map(|p| p.as_ref()).to_glib_none().0,
                resource_path.to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }

    /// Gets the data used as the [`Builder`][crate::Builder] UI template for constructing
    /// listitems.
    ///
    /// # Returns
    ///
    /// The [`Builder`][crate::Builder] data
    #[doc(alias = "gtk_builder_list_item_factory_get_bytes")]
    #[doc(alias = "get_bytes")]
    pub fn bytes(&self) -> glib::Bytes {
        unsafe {
            from_glib_none(ffi::gtk_builder_list_item_factory_get_bytes(
                self.to_glib_none().0,
            ))
        }
    }

    /// If the data references a resource, gets the path of that resource.
    ///
    /// # Returns
    ///
    /// The path to the resource
    #[doc(alias = "gtk_builder_list_item_factory_get_resource")]
    #[doc(alias = "get_resource")]
    pub fn resource(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gtk_builder_list_item_factory_get_resource(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the scope used when constructing listitems.
    ///
    /// # Returns
    ///
    /// The scope used when constructing listitems
    #[doc(alias = "gtk_builder_list_item_factory_get_scope")]
    #[doc(alias = "get_scope")]
    pub fn scope(&self) -> Option<BuilderScope> {
        unsafe {
            from_glib_none(ffi::gtk_builder_list_item_factory_get_scope(
                self.to_glib_none().0,
            ))
        }
    }
}