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")]
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 let f: &F = &*(f as *const F);
161 f(&from_glib_borrow(this))
162 }
163 unsafe {
164 let f: Box_<F> = Box_::new(f);
165 connect_raw(
166 self.as_ptr() as *mut _,
167 c"notify::child".as_ptr() as *const _,
168 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
169 notify_child_trampoline::<F> as *const (),
170 )),
171 Box_::into_raw(f),
172 )
173 }
174 }
175
176 #[cfg(feature = "v4_12")]
177 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
178 #[doc(alias = "end")]
179 pub fn connect_end_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
180 unsafe extern "C" fn notify_end_trampoline<F: Fn(&ListHeader) + 'static>(
181 this: *mut ffi::GtkListHeader,
182 _param_spec: glib::ffi::gpointer,
183 f: glib::ffi::gpointer,
184 ) {
185 let f: &F = &*(f as *const F);
186 f(&from_glib_borrow(this))
187 }
188 unsafe {
189 let f: Box_<F> = Box_::new(f);
190 connect_raw(
191 self.as_ptr() as *mut _,
192 c"notify::end".as_ptr() as *const _,
193 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
194 notify_end_trampoline::<F> as *const (),
195 )),
196 Box_::into_raw(f),
197 )
198 }
199 }
200
201 #[cfg(feature = "v4_12")]
202 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
203 #[doc(alias = "item")]
204 pub fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
205 unsafe extern "C" fn notify_item_trampoline<F: Fn(&ListHeader) + 'static>(
206 this: *mut ffi::GtkListHeader,
207 _param_spec: glib::ffi::gpointer,
208 f: glib::ffi::gpointer,
209 ) {
210 let f: &F = &*(f as *const F);
211 f(&from_glib_borrow(this))
212 }
213 unsafe {
214 let f: Box_<F> = Box_::new(f);
215 connect_raw(
216 self.as_ptr() as *mut _,
217 c"notify::item".as_ptr() as *const _,
218 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
219 notify_item_trampoline::<F> as *const (),
220 )),
221 Box_::into_raw(f),
222 )
223 }
224 }
225
226 #[cfg(feature = "v4_12")]
227 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
228 #[doc(alias = "n-items")]
229 pub fn connect_n_items_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
230 unsafe extern "C" fn notify_n_items_trampoline<F: Fn(&ListHeader) + 'static>(
231 this: *mut ffi::GtkListHeader,
232 _param_spec: glib::ffi::gpointer,
233 f: glib::ffi::gpointer,
234 ) {
235 let f: &F = &*(f as *const F);
236 f(&from_glib_borrow(this))
237 }
238 unsafe {
239 let f: Box_<F> = Box_::new(f);
240 connect_raw(
241 self.as_ptr() as *mut _,
242 c"notify::n-items".as_ptr() as *const _,
243 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
244 notify_n_items_trampoline::<F> as *const (),
245 )),
246 Box_::into_raw(f),
247 )
248 }
249 }
250
251 #[cfg(feature = "v4_12")]
252 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
253 #[doc(alias = "start")]
254 pub fn connect_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
255 unsafe extern "C" fn notify_start_trampoline<F: Fn(&ListHeader) + 'static>(
256 this: *mut ffi::GtkListHeader,
257 _param_spec: glib::ffi::gpointer,
258 f: glib::ffi::gpointer,
259 ) {
260 let f: &F = &*(f as *const F);
261 f(&from_glib_borrow(this))
262 }
263 unsafe {
264 let f: Box_<F> = Box_::new(f);
265 connect_raw(
266 self.as_ptr() as *mut _,
267 c"notify::start".as_ptr() as *const _,
268 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
269 notify_start_trampoline::<F> as *const (),
270 )),
271 Box_::into_raw(f),
272 )
273 }
274 }
275}