alsatimer/auto/
device_info.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi, DeviceInfoFlag};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// A GObject-derived object to express information of timer device.
16    ///
17    /// A [`DeviceInfo`][crate::DeviceInfo] is a GObject-derived object to express information of timer device.
18    /// The call of alsatimer_get_device_info() returns an instance of the object according to the
19    /// identifier of timer device.
20    ///
21    /// The object wraps `struct snd_timer_ginfo` in UAPI of Linux sound subsystem.
22    ///
23    /// ## Properties
24    ///
25    ///
26    /// #### `card-id`
27    ///  The numeric ID of sound card.
28    ///
29    /// Readable
30    ///
31    ///
32    /// #### `flags`
33    ///  The flags of timer, one of [`DeviceInfoFlag`][crate::DeviceInfoFlag].
34    ///
35    /// Readable
36    ///
37    ///
38    /// #### `id`
39    ///  The string ID of timer.
40    ///
41    /// Readable
42    ///
43    ///
44    /// #### `instance-count`
45    ///  The number of instances for the timer.
46    ///
47    /// Readable
48    ///
49    ///
50    /// #### `name`
51    ///  The name of timer.
52    ///
53    /// Readable
54    ///
55    ///
56    /// #### `resolution`
57    ///  The resolution in nano seconds.
58    ///
59    /// Readable
60    ///
61    ///
62    /// #### `resolution-max`
63    ///  The maximum resolution in nano seconds.
64    ///
65    /// Readable
66    ///
67    ///
68    /// #### `resolution-min`
69    ///  The minimum resolution in nano seconds.
70    ///
71    /// Readable
72    ///
73    /// # Implements
74    ///
75    /// [`DeviceInfoExt`][trait@crate::prelude::DeviceInfoExt]
76    #[doc(alias = "ALSATimerDeviceInfo")]
77    pub struct DeviceInfo(Object<ffi::ALSATimerDeviceInfo, ffi::ALSATimerDeviceInfoClass>);
78
79    match fn {
80        type_ => || ffi::alsatimer_device_info_get_type(),
81    }
82}
83
84impl DeviceInfo {
85    pub const NONE: Option<&'static DeviceInfo> = None;
86}
87
88mod sealed {
89    pub trait Sealed {}
90    impl<T: super::IsA<super::DeviceInfo>> Sealed for T {}
91}
92
93/// Trait containing all [`struct@DeviceInfo`] methods.
94///
95/// # Implementors
96///
97/// [`DeviceInfo`][struct@crate::DeviceInfo]
98pub trait DeviceInfoExt: IsA<DeviceInfo> + sealed::Sealed + 'static {
99    /// The numeric ID of sound card.
100    #[doc(alias = "card-id")]
101    fn card_id(&self) -> i32 {
102        ObjectExt::property(self.as_ref(), "card-id")
103    }
104
105    /// The flags of timer, one of [`DeviceInfoFlag`][crate::DeviceInfoFlag].
106    fn flags(&self) -> DeviceInfoFlag {
107        ObjectExt::property(self.as_ref(), "flags")
108    }
109
110    /// The string ID of timer.
111    fn id(&self) -> Option<glib::GString> {
112        ObjectExt::property(self.as_ref(), "id")
113    }
114
115    /// The number of instances for the timer.
116    #[doc(alias = "instance-count")]
117    fn instance_count(&self) -> u32 {
118        ObjectExt::property(self.as_ref(), "instance-count")
119    }
120
121    /// The name of timer.
122    fn name(&self) -> Option<glib::GString> {
123        ObjectExt::property(self.as_ref(), "name")
124    }
125
126    /// The resolution in nano seconds.
127    fn resolution(&self) -> u64 {
128        ObjectExt::property(self.as_ref(), "resolution")
129    }
130
131    /// The maximum resolution in nano seconds.
132    #[doc(alias = "resolution-max")]
133    fn resolution_max(&self) -> u64 {
134        ObjectExt::property(self.as_ref(), "resolution-max")
135    }
136
137    /// The minimum resolution in nano seconds.
138    #[doc(alias = "resolution-min")]
139    fn resolution_min(&self) -> u64 {
140        ObjectExt::property(self.as_ref(), "resolution-min")
141    }
142
143    #[doc(alias = "card-id")]
144    fn connect_card_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
145        unsafe extern "C" fn notify_card_id_trampoline<P: IsA<DeviceInfo>, F: Fn(&P) + 'static>(
146            this: *mut ffi::ALSATimerDeviceInfo,
147            _param_spec: glib::ffi::gpointer,
148            f: glib::ffi::gpointer,
149        ) {
150            let f: &F = &*(f as *const F);
151            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
152        }
153        unsafe {
154            let f: Box_<F> = Box_::new(f);
155            connect_raw(
156                self.as_ptr() as *mut _,
157                b"notify::card-id\0".as_ptr() as *const _,
158                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
159                    notify_card_id_trampoline::<Self, F> as *const (),
160                )),
161                Box_::into_raw(f),
162            )
163        }
164    }
165
166    #[doc(alias = "flags")]
167    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
168        unsafe extern "C" fn notify_flags_trampoline<P: IsA<DeviceInfo>, F: Fn(&P) + 'static>(
169            this: *mut ffi::ALSATimerDeviceInfo,
170            _param_spec: glib::ffi::gpointer,
171            f: glib::ffi::gpointer,
172        ) {
173            let f: &F = &*(f as *const F);
174            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
175        }
176        unsafe {
177            let f: Box_<F> = Box_::new(f);
178            connect_raw(
179                self.as_ptr() as *mut _,
180                b"notify::flags\0".as_ptr() as *const _,
181                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
182                    notify_flags_trampoline::<Self, F> as *const (),
183                )),
184                Box_::into_raw(f),
185            )
186        }
187    }
188
189    #[doc(alias = "id")]
190    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
191        unsafe extern "C" fn notify_id_trampoline<P: IsA<DeviceInfo>, F: Fn(&P) + 'static>(
192            this: *mut ffi::ALSATimerDeviceInfo,
193            _param_spec: glib::ffi::gpointer,
194            f: glib::ffi::gpointer,
195        ) {
196            let f: &F = &*(f as *const F);
197            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
198        }
199        unsafe {
200            let f: Box_<F> = Box_::new(f);
201            connect_raw(
202                self.as_ptr() as *mut _,
203                b"notify::id\0".as_ptr() as *const _,
204                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
205                    notify_id_trampoline::<Self, F> as *const (),
206                )),
207                Box_::into_raw(f),
208            )
209        }
210    }
211
212    #[doc(alias = "instance-count")]
213    fn connect_instance_count_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
214        unsafe extern "C" fn notify_instance_count_trampoline<
215            P: IsA<DeviceInfo>,
216            F: Fn(&P) + 'static,
217        >(
218            this: *mut ffi::ALSATimerDeviceInfo,
219            _param_spec: glib::ffi::gpointer,
220            f: glib::ffi::gpointer,
221        ) {
222            let f: &F = &*(f as *const F);
223            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
224        }
225        unsafe {
226            let f: Box_<F> = Box_::new(f);
227            connect_raw(
228                self.as_ptr() as *mut _,
229                b"notify::instance-count\0".as_ptr() as *const _,
230                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
231                    notify_instance_count_trampoline::<Self, F> as *const (),
232                )),
233                Box_::into_raw(f),
234            )
235        }
236    }
237
238    #[doc(alias = "name")]
239    fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
240        unsafe extern "C" fn notify_name_trampoline<P: IsA<DeviceInfo>, F: Fn(&P) + 'static>(
241            this: *mut ffi::ALSATimerDeviceInfo,
242            _param_spec: glib::ffi::gpointer,
243            f: glib::ffi::gpointer,
244        ) {
245            let f: &F = &*(f as *const F);
246            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
247        }
248        unsafe {
249            let f: Box_<F> = Box_::new(f);
250            connect_raw(
251                self.as_ptr() as *mut _,
252                b"notify::name\0".as_ptr() as *const _,
253                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
254                    notify_name_trampoline::<Self, F> as *const (),
255                )),
256                Box_::into_raw(f),
257            )
258        }
259    }
260
261    #[doc(alias = "resolution")]
262    fn connect_resolution_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
263        unsafe extern "C" fn notify_resolution_trampoline<
264            P: IsA<DeviceInfo>,
265            F: Fn(&P) + 'static,
266        >(
267            this: *mut ffi::ALSATimerDeviceInfo,
268            _param_spec: glib::ffi::gpointer,
269            f: glib::ffi::gpointer,
270        ) {
271            let f: &F = &*(f as *const F);
272            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
273        }
274        unsafe {
275            let f: Box_<F> = Box_::new(f);
276            connect_raw(
277                self.as_ptr() as *mut _,
278                b"notify::resolution\0".as_ptr() as *const _,
279                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
280                    notify_resolution_trampoline::<Self, F> as *const (),
281                )),
282                Box_::into_raw(f),
283            )
284        }
285    }
286
287    #[doc(alias = "resolution-max")]
288    fn connect_resolution_max_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
289        unsafe extern "C" fn notify_resolution_max_trampoline<
290            P: IsA<DeviceInfo>,
291            F: Fn(&P) + 'static,
292        >(
293            this: *mut ffi::ALSATimerDeviceInfo,
294            _param_spec: glib::ffi::gpointer,
295            f: glib::ffi::gpointer,
296        ) {
297            let f: &F = &*(f as *const F);
298            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
299        }
300        unsafe {
301            let f: Box_<F> = Box_::new(f);
302            connect_raw(
303                self.as_ptr() as *mut _,
304                b"notify::resolution-max\0".as_ptr() as *const _,
305                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
306                    notify_resolution_max_trampoline::<Self, F> as *const (),
307                )),
308                Box_::into_raw(f),
309            )
310        }
311    }
312
313    #[doc(alias = "resolution-min")]
314    fn connect_resolution_min_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
315        unsafe extern "C" fn notify_resolution_min_trampoline<
316            P: IsA<DeviceInfo>,
317            F: Fn(&P) + 'static,
318        >(
319            this: *mut ffi::ALSATimerDeviceInfo,
320            _param_spec: glib::ffi::gpointer,
321            f: glib::ffi::gpointer,
322        ) {
323            let f: &F = &*(f as *const F);
324            f(DeviceInfo::from_glib_borrow(this).unsafe_cast_ref())
325        }
326        unsafe {
327            let f: Box_<F> = Box_::new(f);
328            connect_raw(
329                self.as_ptr() as *mut _,
330                b"notify::resolution-min\0".as_ptr() as *const _,
331                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
332                    notify_resolution_min_trampoline::<Self, F> as *const (),
333                )),
334                Box_::into_raw(f),
335            )
336        }
337    }
338}
339
340impl<O: IsA<DeviceInfo>> DeviceInfoExt for O {}