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")]
90 pub struct ListItem(Object<ffi::GtkListItem, ffi::GtkListItemClass>);
91
92 match fn {
93 type_ => || ffi::gtk_list_item_get_type(),
94 }
95}
96
97impl ListItem {
98 pub const NONE: Option<&'static ListItem> = None;
99}
100
101mod sealed {
102 pub trait Sealed {}
103 impl<T: super::IsA<super::ListItem>> Sealed for T {}
104}
105
106pub trait ListItemExt: IsA<ListItem> + sealed::Sealed + 'static {
112 #[cfg(feature = "v4_12")]
118 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
119 #[doc(alias = "gtk_list_item_get_accessible_description")]
120 #[doc(alias = "get_accessible_description")]
121 #[doc(alias = "accessible-description")]
122 fn accessible_description(&self) -> glib::GString {
123 unsafe {
124 from_glib_none(ffi::gtk_list_item_get_accessible_description(
125 self.as_ref().to_glib_none().0,
126 ))
127 }
128 }
129
130 #[cfg(feature = "v4_12")]
136 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
137 #[doc(alias = "gtk_list_item_get_accessible_label")]
138 #[doc(alias = "get_accessible_label")]
139 #[doc(alias = "accessible-label")]
140 fn accessible_label(&self) -> glib::GString {
141 unsafe {
142 from_glib_none(ffi::gtk_list_item_get_accessible_label(
143 self.as_ref().to_glib_none().0,
144 ))
145 }
146 }
147
148 #[doc(alias = "gtk_list_item_get_activatable")]
155 #[doc(alias = "get_activatable")]
156 #[doc(alias = "activatable")]
157 fn is_activatable(&self) -> bool {
158 unsafe {
159 from_glib(ffi::gtk_list_item_get_activatable(
160 self.as_ref().to_glib_none().0,
161 ))
162 }
163 }
164
165 #[doc(alias = "gtk_list_item_get_child")]
172 #[doc(alias = "get_child")]
173 fn child(&self) -> Option<Widget> {
174 unsafe { from_glib_none(ffi::gtk_list_item_get_child(self.as_ref().to_glib_none().0)) }
175 }
176
177 #[cfg(feature = "v4_12")]
184 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
185 #[doc(alias = "gtk_list_item_get_focusable")]
186 #[doc(alias = "get_focusable")]
187 #[doc(alias = "focusable")]
188 fn is_focusable(&self) -> bool {
189 unsafe {
190 from_glib(ffi::gtk_list_item_get_focusable(
191 self.as_ref().to_glib_none().0,
192 ))
193 }
194 }
195
196 #[doc(alias = "gtk_list_item_get_item")]
204 #[doc(alias = "get_item")]
205 fn item(&self) -> Option<glib::Object> {
206 unsafe { from_glib_none(ffi::gtk_list_item_get_item(self.as_ref().to_glib_none().0)) }
207 }
208
209 #[doc(alias = "gtk_list_item_get_position")]
217 #[doc(alias = "get_position")]
218 fn position(&self) -> u32 {
219 unsafe { ffi::gtk_list_item_get_position(self.as_ref().to_glib_none().0) }
220 }
221
222 #[doc(alias = "gtk_list_item_get_selectable")]
231 #[doc(alias = "get_selectable")]
232 #[doc(alias = "selectable")]
233 fn is_selectable(&self) -> bool {
234 unsafe {
235 from_glib(ffi::gtk_list_item_get_selectable(
236 self.as_ref().to_glib_none().0,
237 ))
238 }
239 }
240
241 #[doc(alias = "gtk_list_item_get_selected")]
250 #[doc(alias = "get_selected")]
251 #[doc(alias = "selected")]
252 fn is_selected(&self) -> bool {
253 unsafe {
254 from_glib(ffi::gtk_list_item_get_selected(
255 self.as_ref().to_glib_none().0,
256 ))
257 }
258 }
259
260 #[cfg(feature = "v4_12")]
265 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
266 #[doc(alias = "gtk_list_item_set_accessible_description")]
267 #[doc(alias = "accessible-description")]
268 fn set_accessible_description(&self, description: &str) {
269 unsafe {
270 ffi::gtk_list_item_set_accessible_description(
271 self.as_ref().to_glib_none().0,
272 description.to_glib_none().0,
273 );
274 }
275 }
276
277 #[cfg(feature = "v4_12")]
282 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
283 #[doc(alias = "gtk_list_item_set_accessible_label")]
284 #[doc(alias = "accessible-label")]
285 fn set_accessible_label(&self, label: &str) {
286 unsafe {
287 ffi::gtk_list_item_set_accessible_label(
288 self.as_ref().to_glib_none().0,
289 label.to_glib_none().0,
290 );
291 }
292 }
293
294 #[doc(alias = "gtk_list_item_set_activatable")]
306 #[doc(alias = "activatable")]
307 fn set_activatable(&self, activatable: bool) {
308 unsafe {
309 ffi::gtk_list_item_set_activatable(
310 self.as_ref().to_glib_none().0,
311 activatable.into_glib(),
312 );
313 }
314 }
315
316 #[doc(alias = "gtk_list_item_set_child")]
324 #[doc(alias = "child")]
325 fn set_child(&self, child: Option<&impl IsA<Widget>>) {
326 unsafe {
327 ffi::gtk_list_item_set_child(
328 self.as_ref().to_glib_none().0,
329 child.map(|p| p.as_ref()).to_glib_none().0,
330 );
331 }
332 }
333
334 #[cfg(feature = "v4_12")]
346 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
347 #[doc(alias = "gtk_list_item_set_focusable")]
348 #[doc(alias = "focusable")]
349 fn set_focusable(&self, focusable: bool) {
350 unsafe {
351 ffi::gtk_list_item_set_focusable(self.as_ref().to_glib_none().0, focusable.into_glib());
352 }
353 }
354
355 #[doc(alias = "gtk_list_item_set_selectable")]
370 #[doc(alias = "selectable")]
371 fn set_selectable(&self, selectable: bool) {
372 unsafe {
373 ffi::gtk_list_item_set_selectable(
374 self.as_ref().to_glib_none().0,
375 selectable.into_glib(),
376 );
377 }
378 }
379
380 #[cfg(feature = "v4_12")]
381 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
382 #[doc(alias = "accessible-description")]
383 fn connect_accessible_description_notify<F: Fn(&Self) + 'static>(
384 &self,
385 f: F,
386 ) -> SignalHandlerId {
387 unsafe extern "C" fn notify_accessible_description_trampoline<
388 P: IsA<ListItem>,
389 F: Fn(&P) + 'static,
390 >(
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 b"notify::accessible-description\0".as_ptr() as *const _,
403 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
404 notify_accessible_description_trampoline::<Self, F> as *const (),
405 )),
406 Box_::into_raw(f),
407 )
408 }
409 }
410
411 #[cfg(feature = "v4_12")]
412 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
413 #[doc(alias = "accessible-label")]
414 fn connect_accessible_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
415 unsafe extern "C" fn notify_accessible_label_trampoline<
416 P: IsA<ListItem>,
417 F: Fn(&P) + 'static,
418 >(
419 this: *mut ffi::GtkListItem,
420 _param_spec: glib::ffi::gpointer,
421 f: glib::ffi::gpointer,
422 ) {
423 let f: &F = &*(f as *const F);
424 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
425 }
426 unsafe {
427 let f: Box_<F> = Box_::new(f);
428 connect_raw(
429 self.as_ptr() as *mut _,
430 b"notify::accessible-label\0".as_ptr() as *const _,
431 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
432 notify_accessible_label_trampoline::<Self, F> as *const (),
433 )),
434 Box_::into_raw(f),
435 )
436 }
437 }
438
439 #[doc(alias = "activatable")]
440 fn connect_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
441 unsafe extern "C" fn notify_activatable_trampoline<
442 P: IsA<ListItem>,
443 F: Fn(&P) + 'static,
444 >(
445 this: *mut ffi::GtkListItem,
446 _param_spec: glib::ffi::gpointer,
447 f: glib::ffi::gpointer,
448 ) {
449 let f: &F = &*(f as *const F);
450 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
451 }
452 unsafe {
453 let f: Box_<F> = Box_::new(f);
454 connect_raw(
455 self.as_ptr() as *mut _,
456 b"notify::activatable\0".as_ptr() as *const _,
457 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
458 notify_activatable_trampoline::<Self, F> as *const (),
459 )),
460 Box_::into_raw(f),
461 )
462 }
463 }
464
465 #[doc(alias = "child")]
466 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
467 unsafe extern "C" fn notify_child_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
468 this: *mut ffi::GtkListItem,
469 _param_spec: glib::ffi::gpointer,
470 f: glib::ffi::gpointer,
471 ) {
472 let f: &F = &*(f as *const F);
473 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
474 }
475 unsafe {
476 let f: Box_<F> = Box_::new(f);
477 connect_raw(
478 self.as_ptr() as *mut _,
479 b"notify::child\0".as_ptr() as *const _,
480 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
481 notify_child_trampoline::<Self, F> as *const (),
482 )),
483 Box_::into_raw(f),
484 )
485 }
486 }
487
488 #[cfg(feature = "v4_12")]
489 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
490 #[doc(alias = "focusable")]
491 fn connect_focusable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
492 unsafe extern "C" fn notify_focusable_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
493 this: *mut ffi::GtkListItem,
494 _param_spec: glib::ffi::gpointer,
495 f: glib::ffi::gpointer,
496 ) {
497 let f: &F = &*(f as *const F);
498 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
499 }
500 unsafe {
501 let f: Box_<F> = Box_::new(f);
502 connect_raw(
503 self.as_ptr() as *mut _,
504 b"notify::focusable\0".as_ptr() as *const _,
505 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
506 notify_focusable_trampoline::<Self, F> as *const (),
507 )),
508 Box_::into_raw(f),
509 )
510 }
511 }
512
513 #[doc(alias = "item")]
514 fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
515 unsafe extern "C" fn notify_item_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
516 this: *mut ffi::GtkListItem,
517 _param_spec: glib::ffi::gpointer,
518 f: glib::ffi::gpointer,
519 ) {
520 let f: &F = &*(f as *const F);
521 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
522 }
523 unsafe {
524 let f: Box_<F> = Box_::new(f);
525 connect_raw(
526 self.as_ptr() as *mut _,
527 b"notify::item\0".as_ptr() as *const _,
528 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
529 notify_item_trampoline::<Self, F> as *const (),
530 )),
531 Box_::into_raw(f),
532 )
533 }
534 }
535
536 #[doc(alias = "position")]
537 fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
538 unsafe extern "C" fn notify_position_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
539 this: *mut ffi::GtkListItem,
540 _param_spec: glib::ffi::gpointer,
541 f: glib::ffi::gpointer,
542 ) {
543 let f: &F = &*(f as *const F);
544 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
545 }
546 unsafe {
547 let f: Box_<F> = Box_::new(f);
548 connect_raw(
549 self.as_ptr() as *mut _,
550 b"notify::position\0".as_ptr() as *const _,
551 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
552 notify_position_trampoline::<Self, F> as *const (),
553 )),
554 Box_::into_raw(f),
555 )
556 }
557 }
558
559 #[doc(alias = "selectable")]
560 fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
561 unsafe extern "C" fn notify_selectable_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
562 this: *mut ffi::GtkListItem,
563 _param_spec: glib::ffi::gpointer,
564 f: glib::ffi::gpointer,
565 ) {
566 let f: &F = &*(f as *const F);
567 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
568 }
569 unsafe {
570 let f: Box_<F> = Box_::new(f);
571 connect_raw(
572 self.as_ptr() as *mut _,
573 b"notify::selectable\0".as_ptr() as *const _,
574 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
575 notify_selectable_trampoline::<Self, F> as *const (),
576 )),
577 Box_::into_raw(f),
578 )
579 }
580 }
581
582 #[doc(alias = "selected")]
583 fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
584 unsafe extern "C" fn notify_selected_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
585 this: *mut ffi::GtkListItem,
586 _param_spec: glib::ffi::gpointer,
587 f: glib::ffi::gpointer,
588 ) {
589 let f: &F = &*(f as *const F);
590 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
591 }
592 unsafe {
593 let f: Box_<F> = Box_::new(f);
594 connect_raw(
595 self.as_ptr() as *mut _,
596 b"notify::selected\0".as_ptr() as *const _,
597 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
598 notify_selected_trampoline::<Self, F> as *const (),
599 )),
600 Box_::into_raw(f),
601 )
602 }
603 }
604}
605
606impl<O: IsA<ListItem>> ListItemExt for O {}