alsatimer/auto/
instance_params.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, InstanceParamFlag};
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 parameters of user instance.
16    ///
17    /// A [`InstanceParams`][crate::InstanceParams] is a GObject-derived object to express parameters of user instance
18    /// attached to any timer device or the other instance as slave. The call of
19    /// [`UserInstanceExtManual::set_params()`][crate::prelude::UserInstanceExtManual::set_params()] requires the instance of object.
20    ///
21    /// The object wraps `struct snd_timer_params` in UAPI of Linux sound subsystem.
22    ///
23    /// ## Properties
24    ///
25    ///
26    /// #### `flags`
27    ///  The flags for user instance, as a set of [`InstanceParamFlag`][crate::InstanceParamFlag].
28    ///
29    /// Readable | Writeable
30    ///
31    ///
32    /// #### `interval`
33    ///  The interval to generate event in tick count.
34    ///
35    /// Readable | Writeable
36    ///
37    ///
38    /// #### `queue-size`
39    ///  The size of queue.
40    ///
41    /// Readable | Writeable
42    ///
43    /// # Implements
44    ///
45    /// [`InstanceParamsExt`][trait@crate::prelude::InstanceParamsExt], [`InstanceParamsExtManual`][trait@crate::prelude::InstanceParamsExtManual]
46    #[doc(alias = "ALSATimerInstanceParams")]
47    pub struct InstanceParams(Object<ffi::ALSATimerInstanceParams, ffi::ALSATimerInstanceParamsClass>);
48
49    match fn {
50        type_ => || ffi::alsatimer_instance_params_get_type(),
51    }
52}
53
54impl InstanceParams {
55    pub const NONE: Option<&'static InstanceParams> = None;
56
57    /// Allocate and return an instance of [`InstanceParams`][crate::InstanceParams].
58    ///
59    /// # Returns
60    ///
61    /// An instance of [`InstanceParams`][crate::InstanceParams].
62    #[doc(alias = "alsatimer_instance_params_new")]
63    pub fn new() -> InstanceParams {
64        unsafe { from_glib_full(ffi::alsatimer_instance_params_new()) }
65    }
66}
67
68impl Default for InstanceParams {
69    fn default() -> Self {
70        Self::new()
71    }
72}
73
74/// Trait containing the part of [`struct@InstanceParams`] methods.
75///
76/// # Implementors
77///
78/// [`InstanceParams`][struct@crate::InstanceParams]
79pub trait InstanceParamsExt: IsA<InstanceParams> + 'static {
80    /// The flags for user instance, as a set of [`InstanceParamFlag`][crate::InstanceParamFlag].
81    fn flags(&self) -> InstanceParamFlag {
82        ObjectExt::property(self.as_ref(), "flags")
83    }
84
85    /// The flags for user instance, as a set of [`InstanceParamFlag`][crate::InstanceParamFlag].
86    fn set_flags(&self, flags: InstanceParamFlag) {
87        ObjectExt::set_property(self.as_ref(), "flags", flags)
88    }
89
90    /// The interval to generate event in tick count.
91    fn interval(&self) -> u32 {
92        ObjectExt::property(self.as_ref(), "interval")
93    }
94
95    /// The interval to generate event in tick count.
96    fn set_interval(&self, interval: u32) {
97        ObjectExt::set_property(self.as_ref(), "interval", interval)
98    }
99
100    /// The size of queue.
101    #[doc(alias = "queue-size")]
102    fn queue_size(&self) -> u32 {
103        ObjectExt::property(self.as_ref(), "queue-size")
104    }
105
106    /// The size of queue.
107    #[doc(alias = "queue-size")]
108    fn set_queue_size(&self, queue_size: u32) {
109        ObjectExt::set_property(self.as_ref(), "queue-size", queue_size)
110    }
111
112    #[doc(alias = "flags")]
113    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
114        unsafe extern "C" fn notify_flags_trampoline<
115            P: IsA<InstanceParams>,
116            F: Fn(&P) + 'static,
117        >(
118            this: *mut ffi::ALSATimerInstanceParams,
119            _param_spec: glib::ffi::gpointer,
120            f: glib::ffi::gpointer,
121        ) {
122            let f: &F = &*(f as *const F);
123            f(InstanceParams::from_glib_borrow(this).unsafe_cast_ref())
124        }
125        unsafe {
126            let f: Box_<F> = Box_::new(f);
127            connect_raw(
128                self.as_ptr() as *mut _,
129                c"notify::flags".as_ptr() as *const _,
130                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
131                    notify_flags_trampoline::<Self, F> as *const (),
132                )),
133                Box_::into_raw(f),
134            )
135        }
136    }
137
138    #[doc(alias = "interval")]
139    fn connect_interval_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
140        unsafe extern "C" fn notify_interval_trampoline<
141            P: IsA<InstanceParams>,
142            F: Fn(&P) + 'static,
143        >(
144            this: *mut ffi::ALSATimerInstanceParams,
145            _param_spec: glib::ffi::gpointer,
146            f: glib::ffi::gpointer,
147        ) {
148            let f: &F = &*(f as *const F);
149            f(InstanceParams::from_glib_borrow(this).unsafe_cast_ref())
150        }
151        unsafe {
152            let f: Box_<F> = Box_::new(f);
153            connect_raw(
154                self.as_ptr() as *mut _,
155                c"notify::interval".as_ptr() as *const _,
156                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
157                    notify_interval_trampoline::<Self, F> as *const (),
158                )),
159                Box_::into_raw(f),
160            )
161        }
162    }
163
164    #[doc(alias = "queue-size")]
165    fn connect_queue_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
166        unsafe extern "C" fn notify_queue_size_trampoline<
167            P: IsA<InstanceParams>,
168            F: Fn(&P) + 'static,
169        >(
170            this: *mut ffi::ALSATimerInstanceParams,
171            _param_spec: glib::ffi::gpointer,
172            f: glib::ffi::gpointer,
173        ) {
174            let f: &F = &*(f as *const F);
175            f(InstanceParams::from_glib_borrow(this).unsafe_cast_ref())
176        }
177        unsafe {
178            let f: Box_<F> = Box_::new(f);
179            connect_raw(
180                self.as_ptr() as *mut _,
181                c"notify::queue-size".as_ptr() as *const _,
182                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
183                    notify_queue_size_trampoline::<Self, F> as *const (),
184                )),
185                Box_::into_raw(f),
186            )
187        }
188    }
189}
190
191impl<O: IsA<InstanceParams>> InstanceParamsExt for O {}