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