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 gdk;
6 use glib::object::Cast;
7 use glib::object::IsA;
8 use glib::object::ObjectType as ObjectType_;
9 use glib::signal::connect_raw;
10 use glib::signal::SignalHandlerId;
11 use glib::translate::*;
12 use glib::StaticType;
13 use glib::ToValue;
14 use glib_sys;
15 use gtk_sys;
16 use libc;
17 use std::boxed::Box as Box_;
18 use std::fmt;
19 use std::mem::transmute;
20 use EventController;
21 use Gesture;
22 use GestureSingle;
23 use PropagationPhase;
24 use Widget;
25 
26 glib_wrapper! {
27     pub struct GestureMultiPress(Object<gtk_sys::GtkGestureMultiPress, gtk_sys::GtkGestureMultiPressClass, GestureMultiPressClass>) @extends GestureSingle, Gesture, EventController;
28 
29     match fn {
30         get_type => || gtk_sys::gtk_gesture_multi_press_get_type(),
31     }
32 }
33 
34 impl GestureMultiPress {
new<P: IsA<Widget>>(widget: &P) -> GestureMultiPress35     pub fn new<P: IsA<Widget>>(widget: &P) -> GestureMultiPress {
36         skip_assert_initialized!();
37         unsafe {
38             Gesture::from_glib_full(gtk_sys::gtk_gesture_multi_press_new(
39                 widget.as_ref().to_glib_none().0,
40             ))
41             .unsafe_cast()
42         }
43     }
44 
get_area(&self) -> Option<gdk::Rectangle>45     pub fn get_area(&self) -> Option<gdk::Rectangle> {
46         unsafe {
47             let mut rect = gdk::Rectangle::uninitialized();
48             let ret = from_glib(gtk_sys::gtk_gesture_multi_press_get_area(
49                 self.to_glib_none().0,
50                 rect.to_glib_none_mut().0,
51             ));
52             if ret {
53                 Some(rect)
54             } else {
55                 None
56             }
57         }
58     }
59 
set_area(&self, rect: Option<&gdk::Rectangle>)60     pub fn set_area(&self, rect: Option<&gdk::Rectangle>) {
61         unsafe {
62             gtk_sys::gtk_gesture_multi_press_set_area(self.to_glib_none().0, rect.to_glib_none().0);
63         }
64     }
65 
connect_pressed<F: Fn(&GestureMultiPress, i32, f64, f64) + 'static>( &self, f: F, ) -> SignalHandlerId66     pub fn connect_pressed<F: Fn(&GestureMultiPress, i32, f64, f64) + 'static>(
67         &self,
68         f: F,
69     ) -> SignalHandlerId {
70         unsafe extern "C" fn pressed_trampoline<
71             F: Fn(&GestureMultiPress, i32, f64, f64) + 'static,
72         >(
73             this: *mut gtk_sys::GtkGestureMultiPress,
74             n_press: libc::c_int,
75             x: libc::c_double,
76             y: libc::c_double,
77             f: glib_sys::gpointer,
78         ) {
79             let f: &F = &*(f as *const F);
80             f(&from_glib_borrow(this), n_press, x, y)
81         }
82         unsafe {
83             let f: Box_<F> = Box_::new(f);
84             connect_raw(
85                 self.as_ptr() as *mut _,
86                 b"pressed\0".as_ptr() as *const _,
87                 Some(transmute(pressed_trampoline::<F> as usize)),
88                 Box_::into_raw(f),
89             )
90         }
91     }
92 
connect_released<F: Fn(&GestureMultiPress, i32, f64, f64) + 'static>( &self, f: F, ) -> SignalHandlerId93     pub fn connect_released<F: Fn(&GestureMultiPress, i32, f64, f64) + 'static>(
94         &self,
95         f: F,
96     ) -> SignalHandlerId {
97         unsafe extern "C" fn released_trampoline<
98             F: Fn(&GestureMultiPress, i32, f64, f64) + 'static,
99         >(
100             this: *mut gtk_sys::GtkGestureMultiPress,
101             n_press: libc::c_int,
102             x: libc::c_double,
103             y: libc::c_double,
104             f: glib_sys::gpointer,
105         ) {
106             let f: &F = &*(f as *const F);
107             f(&from_glib_borrow(this), n_press, x, y)
108         }
109         unsafe {
110             let f: Box_<F> = Box_::new(f);
111             connect_raw(
112                 self.as_ptr() as *mut _,
113                 b"released\0".as_ptr() as *const _,
114                 Some(transmute(released_trampoline::<F> as usize)),
115                 Box_::into_raw(f),
116             )
117         }
118     }
119 
connect_stopped<F: Fn(&GestureMultiPress) + 'static>(&self, f: F) -> SignalHandlerId120     pub fn connect_stopped<F: Fn(&GestureMultiPress) + 'static>(&self, f: F) -> SignalHandlerId {
121         unsafe extern "C" fn stopped_trampoline<F: Fn(&GestureMultiPress) + 'static>(
122             this: *mut gtk_sys::GtkGestureMultiPress,
123             f: glib_sys::gpointer,
124         ) {
125             let f: &F = &*(f as *const F);
126             f(&from_glib_borrow(this))
127         }
128         unsafe {
129             let f: Box_<F> = Box_::new(f);
130             connect_raw(
131                 self.as_ptr() as *mut _,
132                 b"stopped\0".as_ptr() as *const _,
133                 Some(transmute(stopped_trampoline::<F> as usize)),
134                 Box_::into_raw(f),
135             )
136         }
137     }
138 }
139 
140 pub struct GestureMultiPressBuilder {
141     button: Option<u32>,
142     exclusive: Option<bool>,
143     touch_only: Option<bool>,
144     n_points: Option<u32>,
145     window: Option<gdk::Window>,
146     propagation_phase: Option<PropagationPhase>,
147     widget: Option<Widget>,
148 }
149 
150 impl GestureMultiPressBuilder {
new() -> Self151     pub fn new() -> Self {
152         Self {
153             button: None,
154             exclusive: None,
155             touch_only: None,
156             n_points: None,
157             window: None,
158             propagation_phase: None,
159             widget: None,
160         }
161     }
162 
build(self) -> GestureMultiPress163     pub fn build(self) -> GestureMultiPress {
164         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
165         if let Some(ref button) = self.button {
166             properties.push(("button", button));
167         }
168         if let Some(ref exclusive) = self.exclusive {
169             properties.push(("exclusive", exclusive));
170         }
171         if let Some(ref touch_only) = self.touch_only {
172             properties.push(("touch-only", touch_only));
173         }
174         if let Some(ref n_points) = self.n_points {
175             properties.push(("n-points", n_points));
176         }
177         if let Some(ref window) = self.window {
178             properties.push(("window", window));
179         }
180         if let Some(ref propagation_phase) = self.propagation_phase {
181             properties.push(("propagation-phase", propagation_phase));
182         }
183         if let Some(ref widget) = self.widget {
184             properties.push(("widget", widget));
185         }
186         glib::Object::new(GestureMultiPress::static_type(), &properties)
187             .expect("object new")
188             .downcast()
189             .expect("downcast")
190     }
191 
button(mut self, button: u32) -> Self192     pub fn button(mut self, button: u32) -> Self {
193         self.button = Some(button);
194         self
195     }
196 
exclusive(mut self, exclusive: bool) -> Self197     pub fn exclusive(mut self, exclusive: bool) -> Self {
198         self.exclusive = Some(exclusive);
199         self
200     }
201 
touch_only(mut self, touch_only: bool) -> Self202     pub fn touch_only(mut self, touch_only: bool) -> Self {
203         self.touch_only = Some(touch_only);
204         self
205     }
206 
n_points(mut self, n_points: u32) -> Self207     pub fn n_points(mut self, n_points: u32) -> Self {
208         self.n_points = Some(n_points);
209         self
210     }
211 
window(mut self, window: &gdk::Window) -> Self212     pub fn window(mut self, window: &gdk::Window) -> Self {
213         self.window = Some(window.clone());
214         self
215     }
216 
propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self217     pub fn propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self {
218         self.propagation_phase = Some(propagation_phase);
219         self
220     }
221 
widget(mut self, widget: &Widget) -> Self222     pub fn widget(mut self, widget: &Widget) -> Self {
223         self.widget = Some(widget.clone());
224         self
225     }
226 }
227 
228 impl fmt::Display for GestureMultiPress {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result229     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
230         write!(f, "GestureMultiPress")
231     }
232 }
233