libadwaita/auto/
animation.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.git)
4// DO NOT EDIT
5
6use crate::{ffi, AnimationState, AnimationTarget};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "AdwAnimation")]
17    pub struct Animation(Object<ffi::AdwAnimation, ffi::AdwAnimationClass>);
18
19    match fn {
20        type_ => || ffi::adw_animation_get_type(),
21    }
22}
23
24impl Animation {
25    pub const NONE: Option<&'static Animation> = None;
26}
27
28pub trait AnimationExt: IsA<Animation> + 'static {
29    #[cfg(feature = "v1_3")]
30    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
31    #[doc(alias = "adw_animation_get_follow_enable_animations_setting")]
32    #[doc(alias = "get_follow_enable_animations_setting")]
33    #[doc(alias = "follow-enable-animations-setting")]
34    fn follows_enable_animations_setting(&self) -> bool {
35        unsafe {
36            from_glib(ffi::adw_animation_get_follow_enable_animations_setting(
37                self.as_ref().to_glib_none().0,
38            ))
39        }
40    }
41
42    #[doc(alias = "adw_animation_get_state")]
43    #[doc(alias = "get_state")]
44    fn state(&self) -> AnimationState {
45        unsafe { from_glib(ffi::adw_animation_get_state(self.as_ref().to_glib_none().0)) }
46    }
47
48    #[doc(alias = "adw_animation_get_target")]
49    #[doc(alias = "get_target")]
50    fn target(&self) -> AnimationTarget {
51        unsafe {
52            from_glib_none(ffi::adw_animation_get_target(
53                self.as_ref().to_glib_none().0,
54            ))
55        }
56    }
57
58    #[doc(alias = "adw_animation_get_value")]
59    #[doc(alias = "get_value")]
60    fn value(&self) -> f64 {
61        unsafe { ffi::adw_animation_get_value(self.as_ref().to_glib_none().0) }
62    }
63
64    #[doc(alias = "adw_animation_get_widget")]
65    #[doc(alias = "get_widget")]
66    fn widget(&self) -> gtk::Widget {
67        unsafe {
68            from_glib_none(ffi::adw_animation_get_widget(
69                self.as_ref().to_glib_none().0,
70            ))
71        }
72    }
73
74    #[doc(alias = "adw_animation_pause")]
75    fn pause(&self) {
76        unsafe {
77            ffi::adw_animation_pause(self.as_ref().to_glib_none().0);
78        }
79    }
80
81    #[doc(alias = "adw_animation_play")]
82    fn play(&self) {
83        unsafe {
84            ffi::adw_animation_play(self.as_ref().to_glib_none().0);
85        }
86    }
87
88    #[doc(alias = "adw_animation_reset")]
89    fn reset(&self) {
90        unsafe {
91            ffi::adw_animation_reset(self.as_ref().to_glib_none().0);
92        }
93    }
94
95    #[doc(alias = "adw_animation_resume")]
96    fn resume(&self) {
97        unsafe {
98            ffi::adw_animation_resume(self.as_ref().to_glib_none().0);
99        }
100    }
101
102    #[cfg(feature = "v1_3")]
103    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
104    #[doc(alias = "adw_animation_set_follow_enable_animations_setting")]
105    #[doc(alias = "follow-enable-animations-setting")]
106    fn set_follow_enable_animations_setting(&self, setting: bool) {
107        unsafe {
108            ffi::adw_animation_set_follow_enable_animations_setting(
109                self.as_ref().to_glib_none().0,
110                setting.into_glib(),
111            );
112        }
113    }
114
115    #[doc(alias = "adw_animation_set_target")]
116    #[doc(alias = "target")]
117    fn set_target(&self, target: &impl IsA<AnimationTarget>) {
118        unsafe {
119            ffi::adw_animation_set_target(
120                self.as_ref().to_glib_none().0,
121                target.as_ref().to_glib_none().0,
122            );
123        }
124    }
125
126    #[doc(alias = "adw_animation_skip")]
127    fn skip(&self) {
128        unsafe {
129            ffi::adw_animation_skip(self.as_ref().to_glib_none().0);
130        }
131    }
132
133    #[doc(alias = "done")]
134    fn connect_done<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
135        unsafe extern "C" fn done_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
136            this: *mut ffi::AdwAnimation,
137            f: glib::ffi::gpointer,
138        ) {
139            let f: &F = &*(f as *const F);
140            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
141        }
142        unsafe {
143            let f: Box_<F> = Box_::new(f);
144            connect_raw(
145                self.as_ptr() as *mut _,
146                c"done".as_ptr() as *const _,
147                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
148                    done_trampoline::<Self, F> as *const (),
149                )),
150                Box_::into_raw(f),
151            )
152        }
153    }
154
155    #[cfg(feature = "v1_3")]
156    #[cfg_attr(docsrs, doc(cfg(feature = "v1_3")))]
157    #[doc(alias = "follow-enable-animations-setting")]
158    fn connect_follow_enable_animations_setting_notify<F: Fn(&Self) + 'static>(
159        &self,
160        f: F,
161    ) -> SignalHandlerId {
162        unsafe extern "C" fn notify_follow_enable_animations_setting_trampoline<
163            P: IsA<Animation>,
164            F: Fn(&P) + 'static,
165        >(
166            this: *mut ffi::AdwAnimation,
167            _param_spec: glib::ffi::gpointer,
168            f: glib::ffi::gpointer,
169        ) {
170            let f: &F = &*(f as *const F);
171            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
172        }
173        unsafe {
174            let f: Box_<F> = Box_::new(f);
175            connect_raw(
176                self.as_ptr() as *mut _,
177                c"notify::follow-enable-animations-setting".as_ptr() as *const _,
178                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
179                    notify_follow_enable_animations_setting_trampoline::<Self, F> as *const (),
180                )),
181                Box_::into_raw(f),
182            )
183        }
184    }
185
186    #[doc(alias = "state")]
187    fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
188        unsafe extern "C" fn notify_state_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
189            this: *mut ffi::AdwAnimation,
190            _param_spec: glib::ffi::gpointer,
191            f: glib::ffi::gpointer,
192        ) {
193            let f: &F = &*(f as *const F);
194            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
195        }
196        unsafe {
197            let f: Box_<F> = Box_::new(f);
198            connect_raw(
199                self.as_ptr() as *mut _,
200                c"notify::state".as_ptr() as *const _,
201                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
202                    notify_state_trampoline::<Self, F> as *const (),
203                )),
204                Box_::into_raw(f),
205            )
206        }
207    }
208
209    #[doc(alias = "target")]
210    fn connect_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
211        unsafe extern "C" fn notify_target_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
212            this: *mut ffi::AdwAnimation,
213            _param_spec: glib::ffi::gpointer,
214            f: glib::ffi::gpointer,
215        ) {
216            let f: &F = &*(f as *const F);
217            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
218        }
219        unsafe {
220            let f: Box_<F> = Box_::new(f);
221            connect_raw(
222                self.as_ptr() as *mut _,
223                c"notify::target".as_ptr() as *const _,
224                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
225                    notify_target_trampoline::<Self, F> as *const (),
226                )),
227                Box_::into_raw(f),
228            )
229        }
230    }
231
232    #[doc(alias = "value")]
233    fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
234        unsafe extern "C" fn notify_value_trampoline<P: IsA<Animation>, F: Fn(&P) + 'static>(
235            this: *mut ffi::AdwAnimation,
236            _param_spec: glib::ffi::gpointer,
237            f: glib::ffi::gpointer,
238        ) {
239            let f: &F = &*(f as *const F);
240            f(Animation::from_glib_borrow(this).unsafe_cast_ref())
241        }
242        unsafe {
243            let f: Box_<F> = Box_::new(f);
244            connect_raw(
245                self.as_ptr() as *mut _,
246                c"notify::value".as_ptr() as *const _,
247                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
248                    notify_value_trampoline::<Self, F> as *const (),
249                )),
250                Box_::into_raw(f),
251            )
252        }
253    }
254}
255
256impl<O: IsA<Animation>> AnimationExt for O {}