alsaseq/auto/
queue_timer_alsa.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, QueueTimerCommon};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// An object to express queue timer specific to instance in ALSA Timer.
16    ///
17    /// A [`glib::object::Object`][crate::glib::object::Object] derived object class for queue timer specific to any instance in ALSA
18    /// Timer.
19    ///
20    /// ## Properties
21    ///
22    ///
23    /// #### `device-id`
24    /// [`alsatimer::DeviceId`][crate::alsatimer::DeviceId] for the associated timer instance in ALSA Timer.
25    ///
26    /// Readable | Writeable
27    ///
28    ///
29    /// #### `resolution-ticks`
30    ///  The number of ticks as resolution of timer.
31    ///
32    /// Readable | Writeable
33    /// <details><summary><h4>QueueTimerCommon</h4></summary>
34    ///
35    ///
36    /// #### `queue-id`
37    ///  The numeric identifier of queue. An entry of [`SpecificClientId`][crate::SpecificClientId] is available as well.
38    ///
39    /// Readable
40    ///
41    ///
42    /// #### `timer-type`
43    ///  The type of timer for the queue, one of [`QueueTimerType`][crate::QueueTimerType].
44    ///
45    /// Readable
46    /// </details>
47    ///
48    /// # Implements
49    ///
50    /// [`QueueTimerAlsaExt`][trait@crate::prelude::QueueTimerAlsaExt], [`QueueTimerCommonExt`][trait@crate::prelude::QueueTimerCommonExt]
51    #[doc(alias = "ALSASeqQueueTimerAlsa")]
52    pub struct QueueTimerAlsa(Object<ffi::ALSASeqQueueTimerAlsa, ffi::ALSASeqQueueTimerAlsaClass>) @implements QueueTimerCommon;
53
54    match fn {
55        type_ => || ffi::alsaseq_queue_timer_alsa_get_type(),
56    }
57}
58
59impl QueueTimerAlsa {
60    pub const NONE: Option<&'static QueueTimerAlsa> = None;
61
62    /// Allocate and return an instance of [`QueueTimerAlsa`][crate::QueueTimerAlsa].
63    ///
64    /// # Returns
65    ///
66    /// An instance of [`QueueTimerAlsa`][crate::QueueTimerAlsa].
67    #[doc(alias = "alsaseq_queue_timer_alsa_new")]
68    pub fn new() -> QueueTimerAlsa {
69        unsafe { from_glib_full(ffi::alsaseq_queue_timer_alsa_new()) }
70    }
71}
72
73impl Default for QueueTimerAlsa {
74    fn default() -> Self {
75        Self::new()
76    }
77}
78
79/// Trait containing all [`struct@QueueTimerAlsa`] methods.
80///
81/// # Implementors
82///
83/// [`QueueTimerAlsa`][struct@crate::QueueTimerAlsa]
84pub trait QueueTimerAlsaExt: IsA<QueueTimerAlsa> + 'static {
85    /// [`alsatimer::DeviceId`][crate::alsatimer::DeviceId] for the associated timer instance in ALSA Timer.
86    #[doc(alias = "device-id")]
87    fn device_id(&self) -> Option<alsatimer::DeviceId> {
88        ObjectExt::property(self.as_ref(), "device-id")
89    }
90
91    /// [`alsatimer::DeviceId`][crate::alsatimer::DeviceId] for the associated timer instance in ALSA Timer.
92    #[doc(alias = "device-id")]
93    fn set_device_id(&self, device_id: Option<&alsatimer::DeviceId>) {
94        ObjectExt::set_property(self.as_ref(), "device-id", device_id)
95    }
96
97    /// The number of ticks as resolution of timer.
98    #[doc(alias = "resolution-ticks")]
99    fn resolution_ticks(&self) -> u32 {
100        ObjectExt::property(self.as_ref(), "resolution-ticks")
101    }
102
103    /// The number of ticks as resolution of timer.
104    #[doc(alias = "resolution-ticks")]
105    fn set_resolution_ticks(&self, resolution_ticks: u32) {
106        ObjectExt::set_property(self.as_ref(), "resolution-ticks", resolution_ticks)
107    }
108
109    #[doc(alias = "device-id")]
110    fn connect_device_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
111        unsafe extern "C" fn notify_device_id_trampoline<
112            P: IsA<QueueTimerAlsa>,
113            F: Fn(&P) + 'static,
114        >(
115            this: *mut ffi::ALSASeqQueueTimerAlsa,
116            _param_spec: glib::ffi::gpointer,
117            f: glib::ffi::gpointer,
118        ) {
119            let f: &F = &*(f as *const F);
120            f(QueueTimerAlsa::from_glib_borrow(this).unsafe_cast_ref())
121        }
122        unsafe {
123            let f: Box_<F> = Box_::new(f);
124            connect_raw(
125                self.as_ptr() as *mut _,
126                c"notify::device-id".as_ptr() as *const _,
127                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
128                    notify_device_id_trampoline::<Self, F> as *const (),
129                )),
130                Box_::into_raw(f),
131            )
132        }
133    }
134
135    #[doc(alias = "resolution-ticks")]
136    fn connect_resolution_ticks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
137        unsafe extern "C" fn notify_resolution_ticks_trampoline<
138            P: IsA<QueueTimerAlsa>,
139            F: Fn(&P) + 'static,
140        >(
141            this: *mut ffi::ALSASeqQueueTimerAlsa,
142            _param_spec: glib::ffi::gpointer,
143            f: glib::ffi::gpointer,
144        ) {
145            let f: &F = &*(f as *const F);
146            f(QueueTimerAlsa::from_glib_borrow(this).unsafe_cast_ref())
147        }
148        unsafe {
149            let f: Box_<F> = Box_::new(f);
150            connect_raw(
151                self.as_ptr() as *mut _,
152                c"notify::resolution-ticks".as_ptr() as *const _,
153                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
154                    notify_resolution_ticks_trampoline::<Self, F> as *const (),
155                )),
156                Box_::into_raw(f),
157            )
158        }
159    }
160}
161
162impl<O: IsA<QueueTimerAlsa>> QueueTimerAlsaExt for O {}