libadwaita/auto/
swipe_tracker.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, NavigationDirection, Swipeable};
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 = "AdwSwipeTracker")]
17    pub struct SwipeTracker(Object<ffi::AdwSwipeTracker, ffi::AdwSwipeTrackerClass>) @implements gtk::Orientable;
18
19    match fn {
20        type_ => || ffi::adw_swipe_tracker_get_type(),
21    }
22}
23
24impl SwipeTracker {
25    #[doc(alias = "adw_swipe_tracker_new")]
26    pub fn new(swipeable: &impl IsA<Swipeable>) -> SwipeTracker {
27        skip_assert_initialized!();
28        unsafe {
29            from_glib_full(ffi::adw_swipe_tracker_new(
30                swipeable.as_ref().to_glib_none().0,
31            ))
32        }
33    }
34
35    // rustdoc-stripper-ignore-next
36    /// Creates a new builder-pattern struct instance to construct [`SwipeTracker`] objects.
37    ///
38    /// This method returns an instance of [`SwipeTrackerBuilder`](crate::builders::SwipeTrackerBuilder) which can be used to create [`SwipeTracker`] objects.
39    pub fn builder() -> SwipeTrackerBuilder {
40        SwipeTrackerBuilder::new()
41    }
42
43    #[doc(alias = "adw_swipe_tracker_get_allow_long_swipes")]
44    #[doc(alias = "get_allow_long_swipes")]
45    #[doc(alias = "allow-long-swipes")]
46    pub fn allows_long_swipes(&self) -> bool {
47        unsafe {
48            from_glib(ffi::adw_swipe_tracker_get_allow_long_swipes(
49                self.to_glib_none().0,
50            ))
51        }
52    }
53
54    #[doc(alias = "adw_swipe_tracker_get_allow_mouse_drag")]
55    #[doc(alias = "get_allow_mouse_drag")]
56    #[doc(alias = "allow-mouse-drag")]
57    pub fn allows_mouse_drag(&self) -> bool {
58        unsafe {
59            from_glib(ffi::adw_swipe_tracker_get_allow_mouse_drag(
60                self.to_glib_none().0,
61            ))
62        }
63    }
64
65    #[cfg(feature = "v1_5")]
66    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
67    #[doc(alias = "adw_swipe_tracker_get_allow_window_handle")]
68    #[doc(alias = "get_allow_window_handle")]
69    #[doc(alias = "allow-window-handle")]
70    pub fn allows_window_handle(&self) -> bool {
71        unsafe {
72            from_glib(ffi::adw_swipe_tracker_get_allow_window_handle(
73                self.to_glib_none().0,
74            ))
75        }
76    }
77
78    #[doc(alias = "adw_swipe_tracker_get_enabled")]
79    #[doc(alias = "get_enabled")]
80    #[doc(alias = "enabled")]
81    pub fn is_enabled(&self) -> bool {
82        unsafe { from_glib(ffi::adw_swipe_tracker_get_enabled(self.to_glib_none().0)) }
83    }
84
85    #[cfg(feature = "v1_4")]
86    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
87    #[doc(alias = "adw_swipe_tracker_get_lower_overshoot")]
88    #[doc(alias = "get_lower_overshoot")]
89    #[doc(alias = "lower-overshoot")]
90    pub fn is_lower_overshoot(&self) -> bool {
91        unsafe {
92            from_glib(ffi::adw_swipe_tracker_get_lower_overshoot(
93                self.to_glib_none().0,
94            ))
95        }
96    }
97
98    #[doc(alias = "adw_swipe_tracker_get_reversed")]
99    #[doc(alias = "get_reversed")]
100    #[doc(alias = "reversed")]
101    pub fn is_reversed(&self) -> bool {
102        unsafe { from_glib(ffi::adw_swipe_tracker_get_reversed(self.to_glib_none().0)) }
103    }
104
105    #[doc(alias = "adw_swipe_tracker_get_swipeable")]
106    #[doc(alias = "get_swipeable")]
107    pub fn swipeable(&self) -> Swipeable {
108        unsafe { from_glib_none(ffi::adw_swipe_tracker_get_swipeable(self.to_glib_none().0)) }
109    }
110
111    #[cfg(feature = "v1_4")]
112    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
113    #[doc(alias = "adw_swipe_tracker_get_upper_overshoot")]
114    #[doc(alias = "get_upper_overshoot")]
115    #[doc(alias = "upper-overshoot")]
116    pub fn is_upper_overshoot(&self) -> bool {
117        unsafe {
118            from_glib(ffi::adw_swipe_tracker_get_upper_overshoot(
119                self.to_glib_none().0,
120            ))
121        }
122    }
123
124    #[doc(alias = "adw_swipe_tracker_set_allow_long_swipes")]
125    #[doc(alias = "allow-long-swipes")]
126    pub fn set_allow_long_swipes(&self, allow_long_swipes: bool) {
127        unsafe {
128            ffi::adw_swipe_tracker_set_allow_long_swipes(
129                self.to_glib_none().0,
130                allow_long_swipes.into_glib(),
131            );
132        }
133    }
134
135    #[doc(alias = "adw_swipe_tracker_set_allow_mouse_drag")]
136    #[doc(alias = "allow-mouse-drag")]
137    pub fn set_allow_mouse_drag(&self, allow_mouse_drag: bool) {
138        unsafe {
139            ffi::adw_swipe_tracker_set_allow_mouse_drag(
140                self.to_glib_none().0,
141                allow_mouse_drag.into_glib(),
142            );
143        }
144    }
145
146    #[cfg(feature = "v1_5")]
147    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
148    #[doc(alias = "adw_swipe_tracker_set_allow_window_handle")]
149    #[doc(alias = "allow-window-handle")]
150    pub fn set_allow_window_handle(&self, allow_window_handle: bool) {
151        unsafe {
152            ffi::adw_swipe_tracker_set_allow_window_handle(
153                self.to_glib_none().0,
154                allow_window_handle.into_glib(),
155            );
156        }
157    }
158
159    #[doc(alias = "adw_swipe_tracker_set_enabled")]
160    #[doc(alias = "enabled")]
161    pub fn set_enabled(&self, enabled: bool) {
162        unsafe {
163            ffi::adw_swipe_tracker_set_enabled(self.to_glib_none().0, enabled.into_glib());
164        }
165    }
166
167    #[cfg(feature = "v1_4")]
168    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
169    #[doc(alias = "adw_swipe_tracker_set_lower_overshoot")]
170    #[doc(alias = "lower-overshoot")]
171    pub fn set_lower_overshoot(&self, overshoot: bool) {
172        unsafe {
173            ffi::adw_swipe_tracker_set_lower_overshoot(
174                self.to_glib_none().0,
175                overshoot.into_glib(),
176            );
177        }
178    }
179
180    #[doc(alias = "adw_swipe_tracker_set_reversed")]
181    #[doc(alias = "reversed")]
182    pub fn set_reversed(&self, reversed: bool) {
183        unsafe {
184            ffi::adw_swipe_tracker_set_reversed(self.to_glib_none().0, reversed.into_glib());
185        }
186    }
187
188    #[cfg(feature = "v1_4")]
189    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
190    #[doc(alias = "adw_swipe_tracker_set_upper_overshoot")]
191    #[doc(alias = "upper-overshoot")]
192    pub fn set_upper_overshoot(&self, overshoot: bool) {
193        unsafe {
194            ffi::adw_swipe_tracker_set_upper_overshoot(
195                self.to_glib_none().0,
196                overshoot.into_glib(),
197            );
198        }
199    }
200
201    #[doc(alias = "adw_swipe_tracker_shift_position")]
202    pub fn shift_position(&self, delta: f64) {
203        unsafe {
204            ffi::adw_swipe_tracker_shift_position(self.to_glib_none().0, delta);
205        }
206    }
207
208    #[doc(alias = "begin-swipe")]
209    pub fn connect_begin_swipe<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
210        unsafe extern "C" fn begin_swipe_trampoline<F: Fn(&SwipeTracker) + 'static>(
211            this: *mut ffi::AdwSwipeTracker,
212            f: glib::ffi::gpointer,
213        ) {
214            let f: &F = &*(f as *const F);
215            f(&from_glib_borrow(this))
216        }
217        unsafe {
218            let f: Box_<F> = Box_::new(f);
219            connect_raw(
220                self.as_ptr() as *mut _,
221                c"begin-swipe".as_ptr() as *const _,
222                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
223                    begin_swipe_trampoline::<F> as *const (),
224                )),
225                Box_::into_raw(f),
226            )
227        }
228    }
229
230    #[doc(alias = "end-swipe")]
231    pub fn connect_end_swipe<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
232        unsafe extern "C" fn end_swipe_trampoline<F: Fn(&SwipeTracker, f64, f64) + 'static>(
233            this: *mut ffi::AdwSwipeTracker,
234            velocity: std::ffi::c_double,
235            to: std::ffi::c_double,
236            f: glib::ffi::gpointer,
237        ) {
238            let f: &F = &*(f as *const F);
239            f(&from_glib_borrow(this), velocity, to)
240        }
241        unsafe {
242            let f: Box_<F> = Box_::new(f);
243            connect_raw(
244                self.as_ptr() as *mut _,
245                c"end-swipe".as_ptr() as *const _,
246                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
247                    end_swipe_trampoline::<F> as *const (),
248                )),
249                Box_::into_raw(f),
250            )
251        }
252    }
253
254    #[doc(alias = "prepare")]
255    pub fn connect_prepare<F: Fn(&Self, NavigationDirection) + 'static>(
256        &self,
257        f: F,
258    ) -> SignalHandlerId {
259        unsafe extern "C" fn prepare_trampoline<
260            F: Fn(&SwipeTracker, NavigationDirection) + 'static,
261        >(
262            this: *mut ffi::AdwSwipeTracker,
263            direction: ffi::AdwNavigationDirection,
264            f: glib::ffi::gpointer,
265        ) {
266            let f: &F = &*(f as *const F);
267            f(&from_glib_borrow(this), from_glib(direction))
268        }
269        unsafe {
270            let f: Box_<F> = Box_::new(f);
271            connect_raw(
272                self.as_ptr() as *mut _,
273                c"prepare".as_ptr() as *const _,
274                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
275                    prepare_trampoline::<F> as *const (),
276                )),
277                Box_::into_raw(f),
278            )
279        }
280    }
281
282    #[doc(alias = "update-swipe")]
283    pub fn connect_update_swipe<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId {
284        unsafe extern "C" fn update_swipe_trampoline<F: Fn(&SwipeTracker, f64) + 'static>(
285            this: *mut ffi::AdwSwipeTracker,
286            progress: std::ffi::c_double,
287            f: glib::ffi::gpointer,
288        ) {
289            let f: &F = &*(f as *const F);
290            f(&from_glib_borrow(this), progress)
291        }
292        unsafe {
293            let f: Box_<F> = Box_::new(f);
294            connect_raw(
295                self.as_ptr() as *mut _,
296                c"update-swipe".as_ptr() as *const _,
297                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
298                    update_swipe_trampoline::<F> as *const (),
299                )),
300                Box_::into_raw(f),
301            )
302        }
303    }
304
305    #[doc(alias = "allow-long-swipes")]
306    pub fn connect_allow_long_swipes_notify<F: Fn(&Self) + 'static>(
307        &self,
308        f: F,
309    ) -> SignalHandlerId {
310        unsafe extern "C" fn notify_allow_long_swipes_trampoline<F: Fn(&SwipeTracker) + 'static>(
311            this: *mut ffi::AdwSwipeTracker,
312            _param_spec: glib::ffi::gpointer,
313            f: glib::ffi::gpointer,
314        ) {
315            let f: &F = &*(f as *const F);
316            f(&from_glib_borrow(this))
317        }
318        unsafe {
319            let f: Box_<F> = Box_::new(f);
320            connect_raw(
321                self.as_ptr() as *mut _,
322                c"notify::allow-long-swipes".as_ptr() as *const _,
323                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
324                    notify_allow_long_swipes_trampoline::<F> as *const (),
325                )),
326                Box_::into_raw(f),
327            )
328        }
329    }
330
331    #[doc(alias = "allow-mouse-drag")]
332    pub fn connect_allow_mouse_drag_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
333        unsafe extern "C" fn notify_allow_mouse_drag_trampoline<F: Fn(&SwipeTracker) + 'static>(
334            this: *mut ffi::AdwSwipeTracker,
335            _param_spec: glib::ffi::gpointer,
336            f: glib::ffi::gpointer,
337        ) {
338            let f: &F = &*(f as *const F);
339            f(&from_glib_borrow(this))
340        }
341        unsafe {
342            let f: Box_<F> = Box_::new(f);
343            connect_raw(
344                self.as_ptr() as *mut _,
345                c"notify::allow-mouse-drag".as_ptr() as *const _,
346                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
347                    notify_allow_mouse_drag_trampoline::<F> as *const (),
348                )),
349                Box_::into_raw(f),
350            )
351        }
352    }
353
354    #[cfg(feature = "v1_5")]
355    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
356    #[doc(alias = "allow-window-handle")]
357    pub fn connect_allow_window_handle_notify<F: Fn(&Self) + 'static>(
358        &self,
359        f: F,
360    ) -> SignalHandlerId {
361        unsafe extern "C" fn notify_allow_window_handle_trampoline<
362            F: Fn(&SwipeTracker) + 'static,
363        >(
364            this: *mut ffi::AdwSwipeTracker,
365            _param_spec: glib::ffi::gpointer,
366            f: glib::ffi::gpointer,
367        ) {
368            let f: &F = &*(f as *const F);
369            f(&from_glib_borrow(this))
370        }
371        unsafe {
372            let f: Box_<F> = Box_::new(f);
373            connect_raw(
374                self.as_ptr() as *mut _,
375                c"notify::allow-window-handle".as_ptr() as *const _,
376                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
377                    notify_allow_window_handle_trampoline::<F> as *const (),
378                )),
379                Box_::into_raw(f),
380            )
381        }
382    }
383
384    #[doc(alias = "enabled")]
385    pub fn connect_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
386        unsafe extern "C" fn notify_enabled_trampoline<F: Fn(&SwipeTracker) + 'static>(
387            this: *mut ffi::AdwSwipeTracker,
388            _param_spec: glib::ffi::gpointer,
389            f: glib::ffi::gpointer,
390        ) {
391            let f: &F = &*(f as *const F);
392            f(&from_glib_borrow(this))
393        }
394        unsafe {
395            let f: Box_<F> = Box_::new(f);
396            connect_raw(
397                self.as_ptr() as *mut _,
398                c"notify::enabled".as_ptr() as *const _,
399                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
400                    notify_enabled_trampoline::<F> as *const (),
401                )),
402                Box_::into_raw(f),
403            )
404        }
405    }
406
407    #[cfg(feature = "v1_4")]
408    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
409    #[doc(alias = "lower-overshoot")]
410    pub fn connect_lower_overshoot_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
411        unsafe extern "C" fn notify_lower_overshoot_trampoline<F: Fn(&SwipeTracker) + 'static>(
412            this: *mut ffi::AdwSwipeTracker,
413            _param_spec: glib::ffi::gpointer,
414            f: glib::ffi::gpointer,
415        ) {
416            let f: &F = &*(f as *const F);
417            f(&from_glib_borrow(this))
418        }
419        unsafe {
420            let f: Box_<F> = Box_::new(f);
421            connect_raw(
422                self.as_ptr() as *mut _,
423                c"notify::lower-overshoot".as_ptr() as *const _,
424                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
425                    notify_lower_overshoot_trampoline::<F> as *const (),
426                )),
427                Box_::into_raw(f),
428            )
429        }
430    }
431
432    #[doc(alias = "reversed")]
433    pub fn connect_reversed_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
434        unsafe extern "C" fn notify_reversed_trampoline<F: Fn(&SwipeTracker) + 'static>(
435            this: *mut ffi::AdwSwipeTracker,
436            _param_spec: glib::ffi::gpointer,
437            f: glib::ffi::gpointer,
438        ) {
439            let f: &F = &*(f as *const F);
440            f(&from_glib_borrow(this))
441        }
442        unsafe {
443            let f: Box_<F> = Box_::new(f);
444            connect_raw(
445                self.as_ptr() as *mut _,
446                c"notify::reversed".as_ptr() as *const _,
447                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
448                    notify_reversed_trampoline::<F> as *const (),
449                )),
450                Box_::into_raw(f),
451            )
452        }
453    }
454
455    #[cfg(feature = "v1_4")]
456    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
457    #[doc(alias = "upper-overshoot")]
458    pub fn connect_upper_overshoot_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
459        unsafe extern "C" fn notify_upper_overshoot_trampoline<F: Fn(&SwipeTracker) + 'static>(
460            this: *mut ffi::AdwSwipeTracker,
461            _param_spec: glib::ffi::gpointer,
462            f: glib::ffi::gpointer,
463        ) {
464            let f: &F = &*(f as *const F);
465            f(&from_glib_borrow(this))
466        }
467        unsafe {
468            let f: Box_<F> = Box_::new(f);
469            connect_raw(
470                self.as_ptr() as *mut _,
471                c"notify::upper-overshoot".as_ptr() as *const _,
472                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
473                    notify_upper_overshoot_trampoline::<F> as *const (),
474                )),
475                Box_::into_raw(f),
476            )
477        }
478    }
479}
480
481impl Default for SwipeTracker {
482    fn default() -> Self {
483        glib::object::Object::new::<Self>()
484    }
485}
486
487// rustdoc-stripper-ignore-next
488/// A [builder-pattern] type to construct [`SwipeTracker`] objects.
489///
490/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
491#[must_use = "The builder must be built to be used"]
492pub struct SwipeTrackerBuilder {
493    builder: glib::object::ObjectBuilder<'static, SwipeTracker>,
494}
495
496impl SwipeTrackerBuilder {
497    fn new() -> Self {
498        Self {
499            builder: glib::object::Object::builder(),
500        }
501    }
502
503    pub fn allow_long_swipes(self, allow_long_swipes: bool) -> Self {
504        Self {
505            builder: self
506                .builder
507                .property("allow-long-swipes", allow_long_swipes),
508        }
509    }
510
511    pub fn allow_mouse_drag(self, allow_mouse_drag: bool) -> Self {
512        Self {
513            builder: self.builder.property("allow-mouse-drag", allow_mouse_drag),
514        }
515    }
516
517    #[cfg(feature = "v1_5")]
518    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
519    pub fn allow_window_handle(self, allow_window_handle: bool) -> Self {
520        Self {
521            builder: self
522                .builder
523                .property("allow-window-handle", allow_window_handle),
524        }
525    }
526
527    pub fn enabled(self, enabled: bool) -> Self {
528        Self {
529            builder: self.builder.property("enabled", enabled),
530        }
531    }
532
533    #[cfg(feature = "v1_4")]
534    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
535    pub fn lower_overshoot(self, lower_overshoot: bool) -> Self {
536        Self {
537            builder: self.builder.property("lower-overshoot", lower_overshoot),
538        }
539    }
540
541    pub fn reversed(self, reversed: bool) -> Self {
542        Self {
543            builder: self.builder.property("reversed", reversed),
544        }
545    }
546
547    pub fn swipeable(self, swipeable: &impl IsA<Swipeable>) -> Self {
548        Self {
549            builder: self
550                .builder
551                .property("swipeable", swipeable.clone().upcast()),
552        }
553    }
554
555    #[cfg(feature = "v1_4")]
556    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
557    pub fn upper_overshoot(self, upper_overshoot: bool) -> Self {
558        Self {
559            builder: self.builder.property("upper-overshoot", upper_overshoot),
560        }
561    }
562
563    pub fn orientation(self, orientation: gtk::Orientation) -> Self {
564        Self {
565            builder: self.builder.property("orientation", orientation),
566        }
567    }
568
569    // rustdoc-stripper-ignore-next
570    /// Build the [`SwipeTracker`].
571    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
572    pub fn build(self) -> SwipeTracker {
573        assert_initialized_main_thread!();
574        self.builder.build()
575    }
576}