libadwaita/auto/
enum_list_item.rs1use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "AdwEnumListItem")]
16 pub struct EnumListItem(Object<ffi::AdwEnumListItem, ffi::AdwEnumListItemClass>);
17
18 match fn {
19 type_ => || ffi::adw_enum_list_item_get_type(),
20 }
21}
22
23impl EnumListItem {
24 #[doc(alias = "adw_enum_list_item_get_name")]
25 #[doc(alias = "get_name")]
26 pub fn name(&self) -> glib::GString {
27 unsafe { from_glib_none(ffi::adw_enum_list_item_get_name(self.to_glib_none().0)) }
28 }
29
30 #[doc(alias = "adw_enum_list_item_get_nick")]
31 #[doc(alias = "get_nick")]
32 pub fn nick(&self) -> glib::GString {
33 unsafe { from_glib_none(ffi::adw_enum_list_item_get_nick(self.to_glib_none().0)) }
34 }
35
36 #[doc(alias = "adw_enum_list_item_get_value")]
37 #[doc(alias = "get_value")]
38 pub fn value(&self) -> i32 {
39 unsafe { ffi::adw_enum_list_item_get_value(self.to_glib_none().0) }
40 }
41
42 #[doc(alias = "name")]
43 pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
44 unsafe extern "C" fn notify_name_trampoline<F: Fn(&EnumListItem) + 'static>(
45 this: *mut ffi::AdwEnumListItem,
46 _param_spec: glib::ffi::gpointer,
47 f: glib::ffi::gpointer,
48 ) {
49 let f: &F = &*(f as *const F);
50 f(&from_glib_borrow(this))
51 }
52 unsafe {
53 let f: Box_<F> = Box_::new(f);
54 connect_raw(
55 self.as_ptr() as *mut _,
56 c"notify::name".as_ptr() as *const _,
57 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
58 notify_name_trampoline::<F> as *const (),
59 )),
60 Box_::into_raw(f),
61 )
62 }
63 }
64
65 #[doc(alias = "nick")]
66 pub fn connect_nick_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
67 unsafe extern "C" fn notify_nick_trampoline<F: Fn(&EnumListItem) + 'static>(
68 this: *mut ffi::AdwEnumListItem,
69 _param_spec: glib::ffi::gpointer,
70 f: glib::ffi::gpointer,
71 ) {
72 let f: &F = &*(f as *const F);
73 f(&from_glib_borrow(this))
74 }
75 unsafe {
76 let f: Box_<F> = Box_::new(f);
77 connect_raw(
78 self.as_ptr() as *mut _,
79 c"notify::nick".as_ptr() as *const _,
80 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
81 notify_nick_trampoline::<F> as *const (),
82 )),
83 Box_::into_raw(f),
84 )
85 }
86 }
87
88 #[doc(alias = "value")]
89 pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
90 unsafe extern "C" fn notify_value_trampoline<F: Fn(&EnumListItem) + 'static>(
91 this: *mut ffi::AdwEnumListItem,
92 _param_spec: glib::ffi::gpointer,
93 f: glib::ffi::gpointer,
94 ) {
95 let f: &F = &*(f as *const F);
96 f(&from_glib_borrow(this))
97 }
98 unsafe {
99 let f: Box_<F> = Box_::new(f);
100 connect_raw(
101 self.as_ptr() as *mut _,
102 c"notify::value".as_ptr() as *const _,
103 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
104 notify_value_trampoline::<F> as *const (),
105 )),
106 Box_::into_raw(f),
107 )
108 }
109 }
110}
111
112impl std::fmt::Display for EnumListItem {
113 #[inline]
114 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
115 f.write_str(&self.name())
116 }
117}