alsatimer/auto/
instance_params.rs1use 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 #[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 #[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
74pub trait InstanceParamsExt: IsA<InstanceParams> + 'static {
80 fn flags(&self) -> InstanceParamFlag {
82 ObjectExt::property(self.as_ref(), "flags")
83 }
84
85 fn set_flags(&self, flags: InstanceParamFlag) {
87 ObjectExt::set_property(self.as_ref(), "flags", flags)
88 }
89
90 fn interval(&self) -> u32 {
92 ObjectExt::property(self.as_ref(), "interval")
93 }
94
95 fn set_interval(&self, interval: u32) {
97 ObjectExt::set_property(self.as_ref(), "interval", interval)
98 }
99
100 #[doc(alias = "queue-size")]
102 fn queue_size(&self) -> u32 {
103 ObjectExt::property(self.as_ref(), "queue-size")
104 }
105
106 #[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 {}