1use crate::{Widget, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GtkListHeader")]
56 pub struct ListHeader(Object<ffi::GtkListHeader, ffi::GtkListHeaderClass>);
57
58 match fn {
59 type_ => || ffi::gtk_list_header_get_type(),
60 }
61}
62
63impl ListHeader {
64 #[doc(alias = "gtk_list_header_get_child")]
71 #[doc(alias = "get_child")]
72 pub fn child(&self) -> Option<Widget> {
73 unsafe { from_glib_none(ffi::gtk_list_header_get_child(self.to_glib_none().0)) }
74 }
75
76 #[doc(alias = "gtk_list_header_get_end")]
85 #[doc(alias = "get_end")]
86 pub fn end(&self) -> u32 {
87 unsafe { ffi::gtk_list_header_get_end(self.to_glib_none().0) }
88 }
89
90 #[doc(alias = "gtk_list_header_get_item")]
100 #[doc(alias = "get_item")]
101 pub fn item(&self) -> Option<glib::Object> {
102 unsafe { from_glib_none(ffi::gtk_list_header_get_item(self.to_glib_none().0)) }
103 }
104
105 #[doc(alias = "gtk_list_header_get_n_items")]
113 #[doc(alias = "get_n_items")]
114 #[doc(alias = "n-items")]
115 pub fn n_items(&self) -> u32 {
116 unsafe { ffi::gtk_list_header_get_n_items(self.to_glib_none().0) }
117 }
118
119 #[doc(alias = "gtk_list_header_get_start")]
128 #[doc(alias = "get_start")]
129 pub fn start(&self) -> u32 {
130 unsafe { ffi::gtk_list_header_get_start(self.to_glib_none().0) }
131 }
132
133 #[doc(alias = "gtk_list_header_set_child")]
141 #[doc(alias = "child")]
142 pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
143 unsafe {
144 ffi::gtk_list_header_set_child(
145 self.to_glib_none().0,
146 child.map(|p| p.as_ref()).to_glib_none().0,
147 );
148 }
149 }
150
151 #[cfg(feature = "v4_12")]
152 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
153 #[doc(alias = "child")]
154 pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
155 unsafe extern "C" fn notify_child_trampoline<F: Fn(&ListHeader) + 'static>(
156 this: *mut ffi::GtkListHeader,
157 _param_spec: glib::ffi::gpointer,
158 f: glib::ffi::gpointer,
159 ) {
160 unsafe {
161 let f: &F = &*(f as *const F);
162 f(&from_glib_borrow(this))
163 }
164 }
165 unsafe {
166 let f: Box_<F> = Box_::new(f);
167 connect_raw(
168 self.as_ptr() as *mut _,
169 c"notify::child".as_ptr() as *const _,
170 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
171 notify_child_trampoline::<F> as *const (),
172 )),
173 Box_::into_raw(f),
174 )
175 }
176 }
177
178 #[cfg(feature = "v4_12")]
179 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
180 #[doc(alias = "end")]
181 pub fn connect_end_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
182 unsafe extern "C" fn notify_end_trampoline<F: Fn(&ListHeader) + 'static>(
183 this: *mut ffi::GtkListHeader,
184 _param_spec: glib::ffi::gpointer,
185 f: glib::ffi::gpointer,
186 ) {
187 unsafe {
188 let f: &F = &*(f as *const F);
189 f(&from_glib_borrow(this))
190 }
191 }
192 unsafe {
193 let f: Box_<F> = Box_::new(f);
194 connect_raw(
195 self.as_ptr() as *mut _,
196 c"notify::end".as_ptr() as *const _,
197 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
198 notify_end_trampoline::<F> as *const (),
199 )),
200 Box_::into_raw(f),
201 )
202 }
203 }
204
205 #[cfg(feature = "v4_12")]
206 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
207 #[doc(alias = "item")]
208 pub fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
209 unsafe extern "C" fn notify_item_trampoline<F: Fn(&ListHeader) + 'static>(
210 this: *mut ffi::GtkListHeader,
211 _param_spec: glib::ffi::gpointer,
212 f: glib::ffi::gpointer,
213 ) {
214 unsafe {
215 let f: &F = &*(f as *const F);
216 f(&from_glib_borrow(this))
217 }
218 }
219 unsafe {
220 let f: Box_<F> = Box_::new(f);
221 connect_raw(
222 self.as_ptr() as *mut _,
223 c"notify::item".as_ptr() as *const _,
224 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
225 notify_item_trampoline::<F> as *const (),
226 )),
227 Box_::into_raw(f),
228 )
229 }
230 }
231
232 #[cfg(feature = "v4_12")]
233 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
234 #[doc(alias = "n-items")]
235 pub fn connect_n_items_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
236 unsafe extern "C" fn notify_n_items_trampoline<F: Fn(&ListHeader) + 'static>(
237 this: *mut ffi::GtkListHeader,
238 _param_spec: glib::ffi::gpointer,
239 f: glib::ffi::gpointer,
240 ) {
241 unsafe {
242 let f: &F = &*(f as *const F);
243 f(&from_glib_borrow(this))
244 }
245 }
246 unsafe {
247 let f: Box_<F> = Box_::new(f);
248 connect_raw(
249 self.as_ptr() as *mut _,
250 c"notify::n-items".as_ptr() as *const _,
251 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
252 notify_n_items_trampoline::<F> as *const (),
253 )),
254 Box_::into_raw(f),
255 )
256 }
257 }
258
259 #[cfg(feature = "v4_12")]
260 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
261 #[doc(alias = "start")]
262 pub fn connect_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
263 unsafe extern "C" fn notify_start_trampoline<F: Fn(&ListHeader) + 'static>(
264 this: *mut ffi::GtkListHeader,
265 _param_spec: glib::ffi::gpointer,
266 f: glib::ffi::gpointer,
267 ) {
268 unsafe {
269 let f: &F = &*(f as *const F);
270 f(&from_glib_borrow(this))
271 }
272 }
273 unsafe {
274 let f: Box_<F> = Box_::new(f);
275 connect_raw(
276 self.as_ptr() as *mut _,
277 c"notify::start".as_ptr() as *const _,
278 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
279 notify_start_trampoline::<F> as *const (),
280 )),
281 Box_::into_raw(f),
282 )
283 }
284 }
285}