1 // This file was generated by gir (https://github.com/gtk-rs/gir)
2 // from gir-files (https://github.com/gtk-rs/gir-files)
3 // DO NOT EDIT
4 
5 use crate::EventController;
6 use crate::Gesture;
7 use crate::GestureSingle;
8 use crate::Widget;
9 use glib::object::Cast;
10 use glib::object::IsA;
11 use glib::object::ObjectType as ObjectType_;
12 use glib::signal::connect_raw;
13 use glib::signal::SignalHandlerId;
14 use glib::translate::*;
15 use std::boxed::Box as Box_;
16 use std::fmt;
17 use std::mem;
18 use std::mem::transmute;
19 
20 glib::wrapper! {
21     #[doc(alias = "GtkGestureStylus")]
22     pub struct GestureStylus(Object<ffi::GtkGestureStylus, ffi::GtkGestureStylusClass>) @extends GestureSingle, Gesture, EventController;
23 
24     match fn {
25         type_ => || ffi::gtk_gesture_stylus_get_type(),
26     }
27 }
28 
29 impl GestureStylus {
30     #[doc(alias = "gtk_gesture_stylus_new")]
new<P: IsA<Widget>>(widget: &P) -> GestureStylus31     pub fn new<P: IsA<Widget>>(widget: &P) -> GestureStylus {
32         skip_assert_initialized!();
33         unsafe {
34             Gesture::from_glib_full(ffi::gtk_gesture_stylus_new(
35                 widget.as_ref().to_glib_none().0,
36             ))
37             .unsafe_cast()
38         }
39     }
40 
41     #[doc(alias = "gtk_gesture_stylus_get_axis")]
42     #[doc(alias = "get_axis")]
axis(&self, axis: gdk::AxisUse) -> Option<f64>43     pub fn axis(&self, axis: gdk::AxisUse) -> Option<f64> {
44         unsafe {
45             let mut value = mem::MaybeUninit::uninit();
46             let ret = from_glib(ffi::gtk_gesture_stylus_get_axis(
47                 self.to_glib_none().0,
48                 axis.into_glib(),
49                 value.as_mut_ptr(),
50             ));
51             let value = value.assume_init();
52             if ret {
53                 Some(value)
54             } else {
55                 None
56             }
57         }
58     }
59 
60     #[doc(alias = "gtk_gesture_stylus_get_device_tool")]
61     #[doc(alias = "get_device_tool")]
device_tool(&self) -> Option<gdk::DeviceTool>62     pub fn device_tool(&self) -> Option<gdk::DeviceTool> {
63         unsafe {
64             from_glib_none(ffi::gtk_gesture_stylus_get_device_tool(
65                 self.to_glib_none().0,
66             ))
67         }
68     }
69 
70     #[doc(alias = "down")]
connect_down<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId71     pub fn connect_down<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
72         unsafe extern "C" fn down_trampoline<F: Fn(&GestureStylus, f64, f64) + 'static>(
73             this: *mut ffi::GtkGestureStylus,
74             object: libc::c_double,
75             p0: libc::c_double,
76             f: glib::ffi::gpointer,
77         ) {
78             let f: &F = &*(f as *const F);
79             f(&from_glib_borrow(this), object, p0)
80         }
81         unsafe {
82             let f: Box_<F> = Box_::new(f);
83             connect_raw(
84                 self.as_ptr() as *mut _,
85                 b"down\0".as_ptr() as *const _,
86                 Some(transmute::<_, unsafe extern "C" fn()>(
87                     down_trampoline::<F> as *const (),
88                 )),
89                 Box_::into_raw(f),
90             )
91         }
92     }
93 
94     #[doc(alias = "motion")]
connect_motion<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId95     pub fn connect_motion<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
96         unsafe extern "C" fn motion_trampoline<F: Fn(&GestureStylus, f64, f64) + 'static>(
97             this: *mut ffi::GtkGestureStylus,
98             object: libc::c_double,
99             p0: libc::c_double,
100             f: glib::ffi::gpointer,
101         ) {
102             let f: &F = &*(f as *const F);
103             f(&from_glib_borrow(this), object, p0)
104         }
105         unsafe {
106             let f: Box_<F> = Box_::new(f);
107             connect_raw(
108                 self.as_ptr() as *mut _,
109                 b"motion\0".as_ptr() as *const _,
110                 Some(transmute::<_, unsafe extern "C" fn()>(
111                     motion_trampoline::<F> as *const (),
112                 )),
113                 Box_::into_raw(f),
114             )
115         }
116     }
117 
118     #[doc(alias = "proximity")]
connect_proximity<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId119     pub fn connect_proximity<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
120         unsafe extern "C" fn proximity_trampoline<F: Fn(&GestureStylus, f64, f64) + 'static>(
121             this: *mut ffi::GtkGestureStylus,
122             object: libc::c_double,
123             p0: libc::c_double,
124             f: glib::ffi::gpointer,
125         ) {
126             let f: &F = &*(f as *const F);
127             f(&from_glib_borrow(this), object, p0)
128         }
129         unsafe {
130             let f: Box_<F> = Box_::new(f);
131             connect_raw(
132                 self.as_ptr() as *mut _,
133                 b"proximity\0".as_ptr() as *const _,
134                 Some(transmute::<_, unsafe extern "C" fn()>(
135                     proximity_trampoline::<F> as *const (),
136                 )),
137                 Box_::into_raw(f),
138             )
139         }
140     }
141 
142     #[doc(alias = "up")]
connect_up<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId143     pub fn connect_up<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
144         unsafe extern "C" fn up_trampoline<F: Fn(&GestureStylus, f64, f64) + 'static>(
145             this: *mut ffi::GtkGestureStylus,
146             object: libc::c_double,
147             p0: libc::c_double,
148             f: glib::ffi::gpointer,
149         ) {
150             let f: &F = &*(f as *const F);
151             f(&from_glib_borrow(this), object, p0)
152         }
153         unsafe {
154             let f: Box_<F> = Box_::new(f);
155             connect_raw(
156                 self.as_ptr() as *mut _,
157                 b"up\0".as_ptr() as *const _,
158                 Some(transmute::<_, unsafe extern "C" fn()>(
159                     up_trampoline::<F> as *const (),
160                 )),
161                 Box_::into_raw(f),
162             )
163         }
164     }
165 }
166 
167 impl fmt::Display for GestureStylus {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result168     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
169         f.write_str("GestureStylus")
170     }
171 }
172