gtk4/auto/
enum_list_item.rs1use crate::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 = "GtkEnumListItem")]
40 pub struct EnumListItem(Object<ffi::GtkEnumListItem, ffi::GtkEnumListItemClass>);
41
42 match fn {
43 type_ => || ffi::gtk_enum_list_item_get_type(),
44 }
45}
46
47impl EnumListItem {
48 #[doc(alias = "gtk_enum_list_item_get_name")]
54 #[doc(alias = "get_name")]
55 pub fn name(&self) -> glib::GString {
56 unsafe { from_glib_none(ffi::gtk_enum_list_item_get_name(self.to_glib_none().0)) }
57 }
58
59 #[doc(alias = "gtk_enum_list_item_get_nick")]
65 #[doc(alias = "get_nick")]
66 pub fn nick(&self) -> glib::GString {
67 unsafe { from_glib_none(ffi::gtk_enum_list_item_get_nick(self.to_glib_none().0)) }
68 }
69
70 #[doc(alias = "gtk_enum_list_item_get_value")]
76 #[doc(alias = "get_value")]
77 pub fn value(&self) -> i32 {
78 unsafe { ffi::gtk_enum_list_item_get_value(self.to_glib_none().0) }
79 }
80
81 #[cfg(feature = "v4_24")]
82 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
83 #[doc(alias = "name")]
84 pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
85 unsafe extern "C" fn notify_name_trampoline<F: Fn(&EnumListItem) + 'static>(
86 this: *mut ffi::GtkEnumListItem,
87 _param_spec: glib::ffi::gpointer,
88 f: glib::ffi::gpointer,
89 ) {
90 unsafe {
91 let f: &F = &*(f as *const F);
92 f(&from_glib_borrow(this))
93 }
94 }
95 unsafe {
96 let f: Box_<F> = Box_::new(f);
97 connect_raw(
98 self.as_ptr() as *mut _,
99 c"notify::name".as_ptr(),
100 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
101 notify_name_trampoline::<F> as *const (),
102 )),
103 Box_::into_raw(f),
104 )
105 }
106 }
107
108 #[cfg(feature = "v4_24")]
109 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
110 #[doc(alias = "nick")]
111 pub fn connect_nick_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
112 unsafe extern "C" fn notify_nick_trampoline<F: Fn(&EnumListItem) + 'static>(
113 this: *mut ffi::GtkEnumListItem,
114 _param_spec: glib::ffi::gpointer,
115 f: glib::ffi::gpointer,
116 ) {
117 unsafe {
118 let f: &F = &*(f as *const F);
119 f(&from_glib_borrow(this))
120 }
121 }
122 unsafe {
123 let f: Box_<F> = Box_::new(f);
124 connect_raw(
125 self.as_ptr() as *mut _,
126 c"notify::nick".as_ptr(),
127 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
128 notify_nick_trampoline::<F> as *const (),
129 )),
130 Box_::into_raw(f),
131 )
132 }
133 }
134
135 #[cfg(feature = "v4_24")]
136 #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
137 #[doc(alias = "value")]
138 pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
139 unsafe extern "C" fn notify_value_trampoline<F: Fn(&EnumListItem) + 'static>(
140 this: *mut ffi::GtkEnumListItem,
141 _param_spec: glib::ffi::gpointer,
142 f: glib::ffi::gpointer,
143 ) {
144 unsafe {
145 let f: &F = &*(f as *const F);
146 f(&from_glib_borrow(this))
147 }
148 }
149 unsafe {
150 let f: Box_<F> = Box_::new(f);
151 connect_raw(
152 self.as_ptr() as *mut _,
153 c"notify::value".as_ptr(),
154 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
155 notify_value_trampoline::<F> as *const (),
156 )),
157 Box_::into_raw(f),
158 )
159 }
160 }
161}
162
163impl std::fmt::Display for EnumListItem {
164 #[inline]
165 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
166 f.write_str(&self.name())
167 }
168}