alsaseq/auto/
queue_timer_alsa.rs1use 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 #[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 #[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
79pub trait QueueTimerAlsaExt: IsA<QueueTimerAlsa> + 'static {
85 #[doc(alias = "device-id")]
87 fn device_id(&self) -> Option<alsatimer::DeviceId> {
88 ObjectExt::property(self.as_ref(), "device-id")
89 }
90
91 #[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 #[doc(alias = "resolution-ticks")]
99 fn resolution_ticks(&self) -> u32 {
100 ObjectExt::property(self.as_ref(), "resolution-ticks")
101 }
102
103 #[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 {}