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 = "GtkListItem")]
15 pub struct ListItem(Object<ffi::GtkListItem, ffi::GtkListItemClass>);
16
17 match fn {
18 type_ => || ffi::gtk_list_item_get_type(),
19 }
20}
21
22impl ListItem {
23 pub const NONE: Option<&'static ListItem> = None;
24}
25
26pub trait ListItemExt: IsA<ListItem> + 'static {
27 #[cfg(feature = "v4_12")]
28 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
29 #[doc(alias = "gtk_list_item_get_accessible_description")]
30 #[doc(alias = "get_accessible_description")]
31 #[doc(alias = "accessible-description")]
32 fn accessible_description(&self) -> glib::GString {
33 unsafe {
34 from_glib_none(ffi::gtk_list_item_get_accessible_description(
35 self.as_ref().to_glib_none().0,
36 ))
37 }
38 }
39
40 #[cfg(feature = "v4_12")]
41 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
42 #[doc(alias = "gtk_list_item_get_accessible_label")]
43 #[doc(alias = "get_accessible_label")]
44 #[doc(alias = "accessible-label")]
45 fn accessible_label(&self) -> glib::GString {
46 unsafe {
47 from_glib_none(ffi::gtk_list_item_get_accessible_label(
48 self.as_ref().to_glib_none().0,
49 ))
50 }
51 }
52
53 #[doc(alias = "gtk_list_item_get_activatable")]
54 #[doc(alias = "get_activatable")]
55 #[doc(alias = "activatable")]
56 fn is_activatable(&self) -> bool {
57 unsafe {
58 from_glib(ffi::gtk_list_item_get_activatable(
59 self.as_ref().to_glib_none().0,
60 ))
61 }
62 }
63
64 #[doc(alias = "gtk_list_item_get_child")]
65 #[doc(alias = "get_child")]
66 fn child(&self) -> Option<Widget> {
67 unsafe { from_glib_none(ffi::gtk_list_item_get_child(self.as_ref().to_glib_none().0)) }
68 }
69
70 #[cfg(feature = "v4_12")]
71 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
72 #[doc(alias = "gtk_list_item_get_focusable")]
73 #[doc(alias = "get_focusable")]
74 #[doc(alias = "focusable")]
75 fn is_focusable(&self) -> bool {
76 unsafe {
77 from_glib(ffi::gtk_list_item_get_focusable(
78 self.as_ref().to_glib_none().0,
79 ))
80 }
81 }
82
83 #[doc(alias = "gtk_list_item_get_item")]
84 #[doc(alias = "get_item")]
85 fn item(&self) -> Option<glib::Object> {
86 unsafe { from_glib_none(ffi::gtk_list_item_get_item(self.as_ref().to_glib_none().0)) }
87 }
88
89 #[doc(alias = "gtk_list_item_get_position")]
90 #[doc(alias = "get_position")]
91 fn position(&self) -> u32 {
92 unsafe { ffi::gtk_list_item_get_position(self.as_ref().to_glib_none().0) }
93 }
94
95 #[doc(alias = "gtk_list_item_get_selectable")]
96 #[doc(alias = "get_selectable")]
97 #[doc(alias = "selectable")]
98 fn is_selectable(&self) -> bool {
99 unsafe {
100 from_glib(ffi::gtk_list_item_get_selectable(
101 self.as_ref().to_glib_none().0,
102 ))
103 }
104 }
105
106 #[doc(alias = "gtk_list_item_get_selected")]
107 #[doc(alias = "get_selected")]
108 #[doc(alias = "selected")]
109 fn is_selected(&self) -> bool {
110 unsafe {
111 from_glib(ffi::gtk_list_item_get_selected(
112 self.as_ref().to_glib_none().0,
113 ))
114 }
115 }
116
117 #[cfg(feature = "v4_12")]
118 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
119 #[doc(alias = "gtk_list_item_set_accessible_description")]
120 #[doc(alias = "accessible-description")]
121 fn set_accessible_description(&self, description: &str) {
122 unsafe {
123 ffi::gtk_list_item_set_accessible_description(
124 self.as_ref().to_glib_none().0,
125 description.to_glib_none().0,
126 );
127 }
128 }
129
130 #[cfg(feature = "v4_12")]
131 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
132 #[doc(alias = "gtk_list_item_set_accessible_label")]
133 #[doc(alias = "accessible-label")]
134 fn set_accessible_label(&self, label: &str) {
135 unsafe {
136 ffi::gtk_list_item_set_accessible_label(
137 self.as_ref().to_glib_none().0,
138 label.to_glib_none().0,
139 );
140 }
141 }
142
143 #[doc(alias = "gtk_list_item_set_activatable")]
144 #[doc(alias = "activatable")]
145 fn set_activatable(&self, activatable: bool) {
146 unsafe {
147 ffi::gtk_list_item_set_activatable(
148 self.as_ref().to_glib_none().0,
149 activatable.into_glib(),
150 );
151 }
152 }
153
154 #[doc(alias = "gtk_list_item_set_child")]
155 #[doc(alias = "child")]
156 fn set_child(&self, child: Option<&impl IsA<Widget>>) {
157 unsafe {
158 ffi::gtk_list_item_set_child(
159 self.as_ref().to_glib_none().0,
160 child.map(|p| p.as_ref()).to_glib_none().0,
161 );
162 }
163 }
164
165 #[cfg(feature = "v4_12")]
166 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
167 #[doc(alias = "gtk_list_item_set_focusable")]
168 #[doc(alias = "focusable")]
169 fn set_focusable(&self, focusable: bool) {
170 unsafe {
171 ffi::gtk_list_item_set_focusable(self.as_ref().to_glib_none().0, focusable.into_glib());
172 }
173 }
174
175 #[doc(alias = "gtk_list_item_set_selectable")]
176 #[doc(alias = "selectable")]
177 fn set_selectable(&self, selectable: bool) {
178 unsafe {
179 ffi::gtk_list_item_set_selectable(
180 self.as_ref().to_glib_none().0,
181 selectable.into_glib(),
182 );
183 }
184 }
185
186 #[cfg(feature = "v4_12")]
187 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
188 #[doc(alias = "accessible-description")]
189 fn connect_accessible_description_notify<F: Fn(&Self) + 'static>(
190 &self,
191 f: F,
192 ) -> SignalHandlerId {
193 unsafe extern "C" fn notify_accessible_description_trampoline<
194 P: IsA<ListItem>,
195 F: Fn(&P) + 'static,
196 >(
197 this: *mut ffi::GtkListItem,
198 _param_spec: glib::ffi::gpointer,
199 f: glib::ffi::gpointer,
200 ) {
201 let f: &F = &*(f as *const F);
202 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
203 }
204 unsafe {
205 let f: Box_<F> = Box_::new(f);
206 connect_raw(
207 self.as_ptr() as *mut _,
208 c"notify::accessible-description".as_ptr() as *const _,
209 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210 notify_accessible_description_trampoline::<Self, F> as *const (),
211 )),
212 Box_::into_raw(f),
213 )
214 }
215 }
216
217 #[cfg(feature = "v4_12")]
218 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
219 #[doc(alias = "accessible-label")]
220 fn connect_accessible_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
221 unsafe extern "C" fn notify_accessible_label_trampoline<
222 P: IsA<ListItem>,
223 F: Fn(&P) + 'static,
224 >(
225 this: *mut ffi::GtkListItem,
226 _param_spec: glib::ffi::gpointer,
227 f: glib::ffi::gpointer,
228 ) {
229 let f: &F = &*(f as *const F);
230 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
231 }
232 unsafe {
233 let f: Box_<F> = Box_::new(f);
234 connect_raw(
235 self.as_ptr() as *mut _,
236 c"notify::accessible-label".as_ptr() as *const _,
237 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
238 notify_accessible_label_trampoline::<Self, F> as *const (),
239 )),
240 Box_::into_raw(f),
241 )
242 }
243 }
244
245 #[doc(alias = "activatable")]
246 fn connect_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
247 unsafe extern "C" fn notify_activatable_trampoline<
248 P: IsA<ListItem>,
249 F: Fn(&P) + 'static,
250 >(
251 this: *mut ffi::GtkListItem,
252 _param_spec: glib::ffi::gpointer,
253 f: glib::ffi::gpointer,
254 ) {
255 let f: &F = &*(f as *const F);
256 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
257 }
258 unsafe {
259 let f: Box_<F> = Box_::new(f);
260 connect_raw(
261 self.as_ptr() as *mut _,
262 c"notify::activatable".as_ptr() as *const _,
263 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
264 notify_activatable_trampoline::<Self, F> as *const (),
265 )),
266 Box_::into_raw(f),
267 )
268 }
269 }
270
271 #[doc(alias = "child")]
272 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
273 unsafe extern "C" fn notify_child_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
274 this: *mut ffi::GtkListItem,
275 _param_spec: glib::ffi::gpointer,
276 f: glib::ffi::gpointer,
277 ) {
278 let f: &F = &*(f as *const F);
279 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
280 }
281 unsafe {
282 let f: Box_<F> = Box_::new(f);
283 connect_raw(
284 self.as_ptr() as *mut _,
285 c"notify::child".as_ptr() as *const _,
286 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
287 notify_child_trampoline::<Self, F> as *const (),
288 )),
289 Box_::into_raw(f),
290 )
291 }
292 }
293
294 #[cfg(feature = "v4_12")]
295 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
296 #[doc(alias = "focusable")]
297 fn connect_focusable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
298 unsafe extern "C" fn notify_focusable_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
299 this: *mut ffi::GtkListItem,
300 _param_spec: glib::ffi::gpointer,
301 f: glib::ffi::gpointer,
302 ) {
303 let f: &F = &*(f as *const F);
304 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
305 }
306 unsafe {
307 let f: Box_<F> = Box_::new(f);
308 connect_raw(
309 self.as_ptr() as *mut _,
310 c"notify::focusable".as_ptr() as *const _,
311 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
312 notify_focusable_trampoline::<Self, F> as *const (),
313 )),
314 Box_::into_raw(f),
315 )
316 }
317 }
318
319 #[doc(alias = "item")]
320 fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
321 unsafe extern "C" fn notify_item_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
322 this: *mut ffi::GtkListItem,
323 _param_spec: glib::ffi::gpointer,
324 f: glib::ffi::gpointer,
325 ) {
326 let f: &F = &*(f as *const F);
327 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
328 }
329 unsafe {
330 let f: Box_<F> = Box_::new(f);
331 connect_raw(
332 self.as_ptr() as *mut _,
333 c"notify::item".as_ptr() as *const _,
334 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
335 notify_item_trampoline::<Self, F> as *const (),
336 )),
337 Box_::into_raw(f),
338 )
339 }
340 }
341
342 #[doc(alias = "position")]
343 fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
344 unsafe extern "C" fn notify_position_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
345 this: *mut ffi::GtkListItem,
346 _param_spec: glib::ffi::gpointer,
347 f: glib::ffi::gpointer,
348 ) {
349 let f: &F = &*(f as *const F);
350 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
351 }
352 unsafe {
353 let f: Box_<F> = Box_::new(f);
354 connect_raw(
355 self.as_ptr() as *mut _,
356 c"notify::position".as_ptr() as *const _,
357 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
358 notify_position_trampoline::<Self, F> as *const (),
359 )),
360 Box_::into_raw(f),
361 )
362 }
363 }
364
365 #[doc(alias = "selectable")]
366 fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
367 unsafe extern "C" fn notify_selectable_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
368 this: *mut ffi::GtkListItem,
369 _param_spec: glib::ffi::gpointer,
370 f: glib::ffi::gpointer,
371 ) {
372 let f: &F = &*(f as *const F);
373 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
374 }
375 unsafe {
376 let f: Box_<F> = Box_::new(f);
377 connect_raw(
378 self.as_ptr() as *mut _,
379 c"notify::selectable".as_ptr() as *const _,
380 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
381 notify_selectable_trampoline::<Self, F> as *const (),
382 )),
383 Box_::into_raw(f),
384 )
385 }
386 }
387
388 #[doc(alias = "selected")]
389 fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
390 unsafe extern "C" fn notify_selected_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
391 this: *mut ffi::GtkListItem,
392 _param_spec: glib::ffi::gpointer,
393 f: glib::ffi::gpointer,
394 ) {
395 let f: &F = &*(f as *const F);
396 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
397 }
398 unsafe {
399 let f: Box_<F> = Box_::new(f);
400 connect_raw(
401 self.as_ptr() as *mut _,
402 c"notify::selected".as_ptr() as *const _,
403 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
404 notify_selected_trampoline::<Self, F> as *const (),
405 )),
406 Box_::into_raw(f),
407 )
408 }
409 }
410}
411
412impl<O: IsA<ListItem>> ListItemExt for O {}