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 = "GtkListItem")]
89 pub struct ListItem(Object<ffi::GtkListItem, ffi::GtkListItemClass>);
90
91 match fn {
92 type_ => || ffi::gtk_list_item_get_type(),
93 }
94}
95
96impl ListItem {
97 pub const NONE: Option<&'static ListItem> = None;
98}
99
100pub trait ListItemExt: IsA<ListItem> + 'static {
106 #[cfg(feature = "v4_12")]
112 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
113 #[doc(alias = "gtk_list_item_get_accessible_description")]
114 #[doc(alias = "get_accessible_description")]
115 #[doc(alias = "accessible-description")]
116 fn accessible_description(&self) -> glib::GString {
117 unsafe {
118 from_glib_none(ffi::gtk_list_item_get_accessible_description(
119 self.as_ref().to_glib_none().0,
120 ))
121 }
122 }
123
124 #[cfg(feature = "v4_12")]
130 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
131 #[doc(alias = "gtk_list_item_get_accessible_label")]
132 #[doc(alias = "get_accessible_label")]
133 #[doc(alias = "accessible-label")]
134 fn accessible_label(&self) -> glib::GString {
135 unsafe {
136 from_glib_none(ffi::gtk_list_item_get_accessible_label(
137 self.as_ref().to_glib_none().0,
138 ))
139 }
140 }
141
142 #[doc(alias = "gtk_list_item_get_activatable")]
149 #[doc(alias = "get_activatable")]
150 #[doc(alias = "activatable")]
151 fn is_activatable(&self) -> bool {
152 unsafe {
153 from_glib(ffi::gtk_list_item_get_activatable(
154 self.as_ref().to_glib_none().0,
155 ))
156 }
157 }
158
159 #[doc(alias = "gtk_list_item_get_child")]
166 #[doc(alias = "get_child")]
167 fn child(&self) -> Option<Widget> {
168 unsafe { from_glib_none(ffi::gtk_list_item_get_child(self.as_ref().to_glib_none().0)) }
169 }
170
171 #[cfg(feature = "v4_12")]
178 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
179 #[doc(alias = "gtk_list_item_get_focusable")]
180 #[doc(alias = "get_focusable")]
181 #[doc(alias = "focusable")]
182 fn is_focusable(&self) -> bool {
183 unsafe {
184 from_glib(ffi::gtk_list_item_get_focusable(
185 self.as_ref().to_glib_none().0,
186 ))
187 }
188 }
189
190 #[doc(alias = "gtk_list_item_get_item")]
198 #[doc(alias = "get_item")]
199 fn item(&self) -> Option<glib::Object> {
200 unsafe { from_glib_none(ffi::gtk_list_item_get_item(self.as_ref().to_glib_none().0)) }
201 }
202
203 #[doc(alias = "gtk_list_item_get_position")]
211 #[doc(alias = "get_position")]
212 fn position(&self) -> u32 {
213 unsafe { ffi::gtk_list_item_get_position(self.as_ref().to_glib_none().0) }
214 }
215
216 #[doc(alias = "gtk_list_item_get_selectable")]
225 #[doc(alias = "get_selectable")]
226 #[doc(alias = "selectable")]
227 fn is_selectable(&self) -> bool {
228 unsafe {
229 from_glib(ffi::gtk_list_item_get_selectable(
230 self.as_ref().to_glib_none().0,
231 ))
232 }
233 }
234
235 #[doc(alias = "gtk_list_item_get_selected")]
244 #[doc(alias = "get_selected")]
245 #[doc(alias = "selected")]
246 fn is_selected(&self) -> bool {
247 unsafe {
248 from_glib(ffi::gtk_list_item_get_selected(
249 self.as_ref().to_glib_none().0,
250 ))
251 }
252 }
253
254 #[cfg(feature = "v4_12")]
260 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
261 #[doc(alias = "gtk_list_item_set_accessible_description")]
262 #[doc(alias = "accessible-description")]
263 fn set_accessible_description(&self, description: &str) {
264 unsafe {
265 ffi::gtk_list_item_set_accessible_description(
266 self.as_ref().to_glib_none().0,
267 description.to_glib_none().0,
268 );
269 }
270 }
271
272 #[cfg(feature = "v4_12")]
278 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
279 #[doc(alias = "gtk_list_item_set_accessible_label")]
280 #[doc(alias = "accessible-label")]
281 fn set_accessible_label(&self, label: &str) {
282 unsafe {
283 ffi::gtk_list_item_set_accessible_label(
284 self.as_ref().to_glib_none().0,
285 label.to_glib_none().0,
286 );
287 }
288 }
289
290 #[doc(alias = "gtk_list_item_set_activatable")]
302 #[doc(alias = "activatable")]
303 fn set_activatable(&self, activatable: bool) {
304 unsafe {
305 ffi::gtk_list_item_set_activatable(
306 self.as_ref().to_glib_none().0,
307 activatable.into_glib(),
308 );
309 }
310 }
311
312 #[doc(alias = "gtk_list_item_set_child")]
320 #[doc(alias = "child")]
321 fn set_child(&self, child: Option<&impl IsA<Widget>>) {
322 unsafe {
323 ffi::gtk_list_item_set_child(
324 self.as_ref().to_glib_none().0,
325 child.map(|p| p.as_ref()).to_glib_none().0,
326 );
327 }
328 }
329
330 #[cfg(feature = "v4_12")]
342 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
343 #[doc(alias = "gtk_list_item_set_focusable")]
344 #[doc(alias = "focusable")]
345 fn set_focusable(&self, focusable: bool) {
346 unsafe {
347 ffi::gtk_list_item_set_focusable(self.as_ref().to_glib_none().0, focusable.into_glib());
348 }
349 }
350
351 #[doc(alias = "gtk_list_item_set_selectable")]
366 #[doc(alias = "selectable")]
367 fn set_selectable(&self, selectable: bool) {
368 unsafe {
369 ffi::gtk_list_item_set_selectable(
370 self.as_ref().to_glib_none().0,
371 selectable.into_glib(),
372 );
373 }
374 }
375
376 #[cfg(feature = "v4_12")]
377 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
378 #[doc(alias = "accessible-description")]
379 fn connect_accessible_description_notify<F: Fn(&Self) + 'static>(
380 &self,
381 f: F,
382 ) -> SignalHandlerId {
383 unsafe extern "C" fn notify_accessible_description_trampoline<
384 P: IsA<ListItem>,
385 F: Fn(&P) + 'static,
386 >(
387 this: *mut ffi::GtkListItem,
388 _param_spec: glib::ffi::gpointer,
389 f: glib::ffi::gpointer,
390 ) {
391 unsafe {
392 let f: &F = &*(f as *const F);
393 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
394 }
395 }
396 unsafe {
397 let f: Box_<F> = Box_::new(f);
398 connect_raw(
399 self.as_ptr() as *mut _,
400 c"notify::accessible-description".as_ptr() as *const _,
401 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
402 notify_accessible_description_trampoline::<Self, F> as *const (),
403 )),
404 Box_::into_raw(f),
405 )
406 }
407 }
408
409 #[cfg(feature = "v4_12")]
410 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
411 #[doc(alias = "accessible-label")]
412 fn connect_accessible_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
413 unsafe extern "C" fn notify_accessible_label_trampoline<
414 P: IsA<ListItem>,
415 F: Fn(&P) + 'static,
416 >(
417 this: *mut ffi::GtkListItem,
418 _param_spec: glib::ffi::gpointer,
419 f: glib::ffi::gpointer,
420 ) {
421 unsafe {
422 let f: &F = &*(f as *const F);
423 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
424 }
425 }
426 unsafe {
427 let f: Box_<F> = Box_::new(f);
428 connect_raw(
429 self.as_ptr() as *mut _,
430 c"notify::accessible-label".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 unsafe {
450 let f: &F = &*(f as *const F);
451 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
452 }
453 }
454 unsafe {
455 let f: Box_<F> = Box_::new(f);
456 connect_raw(
457 self.as_ptr() as *mut _,
458 c"notify::activatable".as_ptr() as *const _,
459 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
460 notify_activatable_trampoline::<Self, F> as *const (),
461 )),
462 Box_::into_raw(f),
463 )
464 }
465 }
466
467 #[doc(alias = "child")]
468 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
469 unsafe extern "C" fn notify_child_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
470 this: *mut ffi::GtkListItem,
471 _param_spec: glib::ffi::gpointer,
472 f: glib::ffi::gpointer,
473 ) {
474 unsafe {
475 let f: &F = &*(f as *const F);
476 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
477 }
478 }
479 unsafe {
480 let f: Box_<F> = Box_::new(f);
481 connect_raw(
482 self.as_ptr() as *mut _,
483 c"notify::child".as_ptr() as *const _,
484 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
485 notify_child_trampoline::<Self, F> as *const (),
486 )),
487 Box_::into_raw(f),
488 )
489 }
490 }
491
492 #[cfg(feature = "v4_12")]
493 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
494 #[doc(alias = "focusable")]
495 fn connect_focusable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
496 unsafe extern "C" fn notify_focusable_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
497 this: *mut ffi::GtkListItem,
498 _param_spec: glib::ffi::gpointer,
499 f: glib::ffi::gpointer,
500 ) {
501 unsafe {
502 let f: &F = &*(f as *const F);
503 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
504 }
505 }
506 unsafe {
507 let f: Box_<F> = Box_::new(f);
508 connect_raw(
509 self.as_ptr() as *mut _,
510 c"notify::focusable".as_ptr() as *const _,
511 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
512 notify_focusable_trampoline::<Self, F> as *const (),
513 )),
514 Box_::into_raw(f),
515 )
516 }
517 }
518
519 #[doc(alias = "item")]
520 fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
521 unsafe extern "C" fn notify_item_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
522 this: *mut ffi::GtkListItem,
523 _param_spec: glib::ffi::gpointer,
524 f: glib::ffi::gpointer,
525 ) {
526 unsafe {
527 let f: &F = &*(f as *const F);
528 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
529 }
530 }
531 unsafe {
532 let f: Box_<F> = Box_::new(f);
533 connect_raw(
534 self.as_ptr() as *mut _,
535 c"notify::item".as_ptr() as *const _,
536 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
537 notify_item_trampoline::<Self, F> as *const (),
538 )),
539 Box_::into_raw(f),
540 )
541 }
542 }
543
544 #[doc(alias = "position")]
545 fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
546 unsafe extern "C" fn notify_position_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
547 this: *mut ffi::GtkListItem,
548 _param_spec: glib::ffi::gpointer,
549 f: glib::ffi::gpointer,
550 ) {
551 unsafe {
552 let f: &F = &*(f as *const F);
553 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
554 }
555 }
556 unsafe {
557 let f: Box_<F> = Box_::new(f);
558 connect_raw(
559 self.as_ptr() as *mut _,
560 c"notify::position".as_ptr() as *const _,
561 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
562 notify_position_trampoline::<Self, F> as *const (),
563 )),
564 Box_::into_raw(f),
565 )
566 }
567 }
568
569 #[doc(alias = "selectable")]
570 fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
571 unsafe extern "C" fn notify_selectable_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
572 this: *mut ffi::GtkListItem,
573 _param_spec: glib::ffi::gpointer,
574 f: glib::ffi::gpointer,
575 ) {
576 unsafe {
577 let f: &F = &*(f as *const F);
578 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
579 }
580 }
581 unsafe {
582 let f: Box_<F> = Box_::new(f);
583 connect_raw(
584 self.as_ptr() as *mut _,
585 c"notify::selectable".as_ptr() as *const _,
586 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
587 notify_selectable_trampoline::<Self, F> as *const (),
588 )),
589 Box_::into_raw(f),
590 )
591 }
592 }
593
594 #[doc(alias = "selected")]
595 fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
596 unsafe extern "C" fn notify_selected_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
597 this: *mut ffi::GtkListItem,
598 _param_spec: glib::ffi::gpointer,
599 f: glib::ffi::gpointer,
600 ) {
601 unsafe {
602 let f: &F = &*(f as *const F);
603 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
604 }
605 }
606 unsafe {
607 let f: Box_<F> = Box_::new(f);
608 connect_raw(
609 self.as_ptr() as *mut _,
610 c"notify::selected".as_ptr() as *const _,
611 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
612 notify_selected_trampoline::<Self, F> as *const (),
613 )),
614 Box_::into_raw(f),
615 )
616 }
617 }
618}
619
620impl<O: IsA<ListItem>> ListItemExt for O {}