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")]
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 let f: &F = &*(f as *const F);
392 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
393 }
394 unsafe {
395 let f: Box_<F> = Box_::new(f);
396 connect_raw(
397 self.as_ptr() as *mut _,
398 c"notify::accessible-description".as_ptr() as *const _,
399 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
400 notify_accessible_description_trampoline::<Self, F> as *const (),
401 )),
402 Box_::into_raw(f),
403 )
404 }
405 }
406
407 #[cfg(feature = "v4_12")]
408 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
409 #[doc(alias = "accessible-label")]
410 fn connect_accessible_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
411 unsafe extern "C" fn notify_accessible_label_trampoline<
412 P: IsA<ListItem>,
413 F: Fn(&P) + 'static,
414 >(
415 this: *mut ffi::GtkListItem,
416 _param_spec: glib::ffi::gpointer,
417 f: glib::ffi::gpointer,
418 ) {
419 let f: &F = &*(f as *const F);
420 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
421 }
422 unsafe {
423 let f: Box_<F> = Box_::new(f);
424 connect_raw(
425 self.as_ptr() as *mut _,
426 c"notify::accessible-label".as_ptr() as *const _,
427 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
428 notify_accessible_label_trampoline::<Self, F> as *const (),
429 )),
430 Box_::into_raw(f),
431 )
432 }
433 }
434
435 #[doc(alias = "activatable")]
436 fn connect_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
437 unsafe extern "C" fn notify_activatable_trampoline<
438 P: IsA<ListItem>,
439 F: Fn(&P) + 'static,
440 >(
441 this: *mut ffi::GtkListItem,
442 _param_spec: glib::ffi::gpointer,
443 f: glib::ffi::gpointer,
444 ) {
445 let f: &F = &*(f as *const F);
446 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
447 }
448 unsafe {
449 let f: Box_<F> = Box_::new(f);
450 connect_raw(
451 self.as_ptr() as *mut _,
452 c"notify::activatable".as_ptr() as *const _,
453 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
454 notify_activatable_trampoline::<Self, F> as *const (),
455 )),
456 Box_::into_raw(f),
457 )
458 }
459 }
460
461 #[doc(alias = "child")]
462 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
463 unsafe extern "C" fn notify_child_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
464 this: *mut ffi::GtkListItem,
465 _param_spec: glib::ffi::gpointer,
466 f: glib::ffi::gpointer,
467 ) {
468 let f: &F = &*(f as *const F);
469 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
470 }
471 unsafe {
472 let f: Box_<F> = Box_::new(f);
473 connect_raw(
474 self.as_ptr() as *mut _,
475 c"notify::child".as_ptr() as *const _,
476 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
477 notify_child_trampoline::<Self, F> as *const (),
478 )),
479 Box_::into_raw(f),
480 )
481 }
482 }
483
484 #[cfg(feature = "v4_12")]
485 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
486 #[doc(alias = "focusable")]
487 fn connect_focusable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
488 unsafe extern "C" fn notify_focusable_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
489 this: *mut ffi::GtkListItem,
490 _param_spec: glib::ffi::gpointer,
491 f: glib::ffi::gpointer,
492 ) {
493 let f: &F = &*(f as *const F);
494 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
495 }
496 unsafe {
497 let f: Box_<F> = Box_::new(f);
498 connect_raw(
499 self.as_ptr() as *mut _,
500 c"notify::focusable".as_ptr() as *const _,
501 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
502 notify_focusable_trampoline::<Self, F> as *const (),
503 )),
504 Box_::into_raw(f),
505 )
506 }
507 }
508
509 #[doc(alias = "item")]
510 fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
511 unsafe extern "C" fn notify_item_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
512 this: *mut ffi::GtkListItem,
513 _param_spec: glib::ffi::gpointer,
514 f: glib::ffi::gpointer,
515 ) {
516 let f: &F = &*(f as *const F);
517 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
518 }
519 unsafe {
520 let f: Box_<F> = Box_::new(f);
521 connect_raw(
522 self.as_ptr() as *mut _,
523 c"notify::item".as_ptr() as *const _,
524 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
525 notify_item_trampoline::<Self, F> as *const (),
526 )),
527 Box_::into_raw(f),
528 )
529 }
530 }
531
532 #[doc(alias = "position")]
533 fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
534 unsafe extern "C" fn notify_position_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
535 this: *mut ffi::GtkListItem,
536 _param_spec: glib::ffi::gpointer,
537 f: glib::ffi::gpointer,
538 ) {
539 let f: &F = &*(f as *const F);
540 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
541 }
542 unsafe {
543 let f: Box_<F> = Box_::new(f);
544 connect_raw(
545 self.as_ptr() as *mut _,
546 c"notify::position".as_ptr() as *const _,
547 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
548 notify_position_trampoline::<Self, F> as *const (),
549 )),
550 Box_::into_raw(f),
551 )
552 }
553 }
554
555 #[doc(alias = "selectable")]
556 fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
557 unsafe extern "C" fn notify_selectable_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
558 this: *mut ffi::GtkListItem,
559 _param_spec: glib::ffi::gpointer,
560 f: glib::ffi::gpointer,
561 ) {
562 let f: &F = &*(f as *const F);
563 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
564 }
565 unsafe {
566 let f: Box_<F> = Box_::new(f);
567 connect_raw(
568 self.as_ptr() as *mut _,
569 c"notify::selectable".as_ptr() as *const _,
570 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
571 notify_selectable_trampoline::<Self, F> as *const (),
572 )),
573 Box_::into_raw(f),
574 )
575 }
576 }
577
578 #[doc(alias = "selected")]
579 fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
580 unsafe extern "C" fn notify_selected_trampoline<P: IsA<ListItem>, F: Fn(&P) + 'static>(
581 this: *mut ffi::GtkListItem,
582 _param_spec: glib::ffi::gpointer,
583 f: glib::ffi::gpointer,
584 ) {
585 let f: &F = &*(f as *const F);
586 f(ListItem::from_glib_borrow(this).unsafe_cast_ref())
587 }
588 unsafe {
589 let f: Box_<F> = Box_::new(f);
590 connect_raw(
591 self.as_ptr() as *mut _,
592 c"notify::selected".as_ptr() as *const _,
593 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
594 notify_selected_trampoline::<Self, F> as *const (),
595 )),
596 Box_::into_raw(f),
597 )
598 }
599 }
600}
601
602impl<O: IsA<ListItem>> ListItemExt for O {}