1use 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 = "ALSACtlCardInfo")]
70 pub struct CardInfo(Object<ffi::ALSACtlCardInfo, ffi::ALSACtlCardInfoClass>);
71
72 match fn {
73 type_ => || ffi::alsactl_card_info_get_type(),
74 }
75}
76
77impl CardInfo {
78 pub const NONE: Option<&'static CardInfo> = None;
79}
80
81pub trait CardInfoExt: IsA<CardInfo> + 'static {
87 #[doc(alias = "card-id")]
89 fn card_id(&self) -> i32 {
90 ObjectExt::property(self.as_ref(), "card-id")
91 }
92
93 fn components(&self) -> Option<glib::GString> {
95 ObjectExt::property(self.as_ref(), "components")
96 }
97
98 fn driver(&self) -> Option<glib::GString> {
100 ObjectExt::property(self.as_ref(), "driver")
101 }
102
103 fn id(&self) -> Option<glib::GString> {
105 ObjectExt::property(self.as_ref(), "id")
106 }
107
108 #[doc(alias = "long-name")]
110 fn long_name(&self) -> Option<glib::GString> {
111 ObjectExt::property(self.as_ref(), "long-name")
112 }
113
114 #[doc(alias = "mixer-name")]
116 fn mixer_name(&self) -> Option<glib::GString> {
117 ObjectExt::property(self.as_ref(), "mixer-name")
118 }
119
120 fn name(&self) -> Option<glib::GString> {
122 ObjectExt::property(self.as_ref(), "name")
123 }
124
125 #[doc(alias = "card-id")]
126 fn connect_card_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
127 unsafe extern "C" fn notify_card_id_trampoline<P: IsA<CardInfo>, F: Fn(&P) + 'static>(
128 this: *mut ffi::ALSACtlCardInfo,
129 _param_spec: glib::ffi::gpointer,
130 f: glib::ffi::gpointer,
131 ) {
132 let f: &F = &*(f as *const F);
133 f(CardInfo::from_glib_borrow(this).unsafe_cast_ref())
134 }
135 unsafe {
136 let f: Box_<F> = Box_::new(f);
137 connect_raw(
138 self.as_ptr() as *mut _,
139 c"notify::card-id".as_ptr() as *const _,
140 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
141 notify_card_id_trampoline::<Self, F> as *const (),
142 )),
143 Box_::into_raw(f),
144 )
145 }
146 }
147
148 #[doc(alias = "components")]
149 fn connect_components_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
150 unsafe extern "C" fn notify_components_trampoline<P: IsA<CardInfo>, F: Fn(&P) + 'static>(
151 this: *mut ffi::ALSACtlCardInfo,
152 _param_spec: glib::ffi::gpointer,
153 f: glib::ffi::gpointer,
154 ) {
155 let f: &F = &*(f as *const F);
156 f(CardInfo::from_glib_borrow(this).unsafe_cast_ref())
157 }
158 unsafe {
159 let f: Box_<F> = Box_::new(f);
160 connect_raw(
161 self.as_ptr() as *mut _,
162 c"notify::components".as_ptr() as *const _,
163 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
164 notify_components_trampoline::<Self, F> as *const (),
165 )),
166 Box_::into_raw(f),
167 )
168 }
169 }
170
171 #[doc(alias = "driver")]
172 fn connect_driver_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
173 unsafe extern "C" fn notify_driver_trampoline<P: IsA<CardInfo>, F: Fn(&P) + 'static>(
174 this: *mut ffi::ALSACtlCardInfo,
175 _param_spec: glib::ffi::gpointer,
176 f: glib::ffi::gpointer,
177 ) {
178 let f: &F = &*(f as *const F);
179 f(CardInfo::from_glib_borrow(this).unsafe_cast_ref())
180 }
181 unsafe {
182 let f: Box_<F> = Box_::new(f);
183 connect_raw(
184 self.as_ptr() as *mut _,
185 c"notify::driver".as_ptr() as *const _,
186 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
187 notify_driver_trampoline::<Self, F> as *const (),
188 )),
189 Box_::into_raw(f),
190 )
191 }
192 }
193
194 #[doc(alias = "id")]
195 fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
196 unsafe extern "C" fn notify_id_trampoline<P: IsA<CardInfo>, F: Fn(&P) + 'static>(
197 this: *mut ffi::ALSACtlCardInfo,
198 _param_spec: glib::ffi::gpointer,
199 f: glib::ffi::gpointer,
200 ) {
201 let f: &F = &*(f as *const F);
202 f(CardInfo::from_glib_borrow(this).unsafe_cast_ref())
203 }
204 unsafe {
205 let f: Box_<F> = Box_::new(f);
206 connect_raw(
207 self.as_ptr() as *mut _,
208 c"notify::id".as_ptr() as *const _,
209 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210 notify_id_trampoline::<Self, F> as *const (),
211 )),
212 Box_::into_raw(f),
213 )
214 }
215 }
216
217 #[doc(alias = "long-name")]
218 fn connect_long_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
219 unsafe extern "C" fn notify_long_name_trampoline<P: IsA<CardInfo>, F: Fn(&P) + 'static>(
220 this: *mut ffi::ALSACtlCardInfo,
221 _param_spec: glib::ffi::gpointer,
222 f: glib::ffi::gpointer,
223 ) {
224 let f: &F = &*(f as *const F);
225 f(CardInfo::from_glib_borrow(this).unsafe_cast_ref())
226 }
227 unsafe {
228 let f: Box_<F> = Box_::new(f);
229 connect_raw(
230 self.as_ptr() as *mut _,
231 c"notify::long-name".as_ptr() as *const _,
232 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
233 notify_long_name_trampoline::<Self, F> as *const (),
234 )),
235 Box_::into_raw(f),
236 )
237 }
238 }
239
240 #[doc(alias = "mixer-name")]
241 fn connect_mixer_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
242 unsafe extern "C" fn notify_mixer_name_trampoline<P: IsA<CardInfo>, F: Fn(&P) + 'static>(
243 this: *mut ffi::ALSACtlCardInfo,
244 _param_spec: glib::ffi::gpointer,
245 f: glib::ffi::gpointer,
246 ) {
247 let f: &F = &*(f as *const F);
248 f(CardInfo::from_glib_borrow(this).unsafe_cast_ref())
249 }
250 unsafe {
251 let f: Box_<F> = Box_::new(f);
252 connect_raw(
253 self.as_ptr() as *mut _,
254 c"notify::mixer-name".as_ptr() as *const _,
255 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
256 notify_mixer_name_trampoline::<Self, F> as *const (),
257 )),
258 Box_::into_raw(f),
259 )
260 }
261 }
262
263 #[doc(alias = "name")]
264 fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
265 unsafe extern "C" fn notify_name_trampoline<P: IsA<CardInfo>, F: Fn(&P) + 'static>(
266 this: *mut ffi::ALSACtlCardInfo,
267 _param_spec: glib::ffi::gpointer,
268 f: glib::ffi::gpointer,
269 ) {
270 let f: &F = &*(f as *const F);
271 f(CardInfo::from_glib_borrow(this).unsafe_cast_ref())
272 }
273 unsafe {
274 let f: Box_<F> = Box_::new(f);
275 connect_raw(
276 self.as_ptr() as *mut _,
277 c"notify::name".as_ptr() as *const _,
278 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
279 notify_name_trampoline::<Self, F> as *const (),
280 )),
281 Box_::into_raw(f),
282 )
283 }
284 }
285}
286
287impl<O: IsA<CardInfo>> CardInfoExt for O {}