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 gdk_sys;
7 use glib::object::Cast;
8 use glib::object::IsA;
9 use glib::signal::connect_raw;
10 use glib::signal::SignalHandlerId;
11 use glib::translate::*;
12 use glib::StaticType;
13 use glib::Value;
14 use glib_sys;
15 use gobject_sys;
16 use gtk_sys;
17 use std::boxed::Box as Box_;
18 use std::fmt;
19 use std::mem;
20 use std::mem::transmute;
21 use EventController;
22 use EventSequenceState;
23 
24 glib_wrapper! {
25     pub struct Gesture(Object<gtk_sys::GtkGesture, gtk_sys::GtkGestureClass, GestureClass>) @extends EventController;
26 
27     match fn {
28         get_type => || gtk_sys::gtk_gesture_get_type(),
29     }
30 }
31 
32 pub const NONE_GESTURE: Option<&Gesture> = None;
33 
34 pub trait GestureExt: 'static {
get_bounding_box(&self) -> Option<gdk::Rectangle>35     fn get_bounding_box(&self) -> Option<gdk::Rectangle>;
36 
get_bounding_box_center(&self) -> Option<(f64, f64)>37     fn get_bounding_box_center(&self) -> Option<(f64, f64)>;
38 
get_device(&self) -> Option<gdk::Device>39     fn get_device(&self) -> Option<gdk::Device>;
40 
get_group(&self) -> Vec<Gesture>41     fn get_group(&self) -> Vec<Gesture>;
42 
get_last_event(&self, sequence: Option<&gdk::EventSequence>) -> Option<gdk::Event>43     fn get_last_event(&self, sequence: Option<&gdk::EventSequence>) -> Option<gdk::Event>;
44 
get_last_updated_sequence(&self) -> Option<gdk::EventSequence>45     fn get_last_updated_sequence(&self) -> Option<gdk::EventSequence>;
46 
get_point(&self, sequence: Option<&gdk::EventSequence>) -> Option<(f64, f64)>47     fn get_point(&self, sequence: Option<&gdk::EventSequence>) -> Option<(f64, f64)>;
48 
get_sequence_state(&self, sequence: &gdk::EventSequence) -> EventSequenceState49     fn get_sequence_state(&self, sequence: &gdk::EventSequence) -> EventSequenceState;
50 
get_sequences(&self) -> Vec<gdk::EventSequence>51     fn get_sequences(&self) -> Vec<gdk::EventSequence>;
52 
get_window(&self) -> Option<gdk::Window>53     fn get_window(&self) -> Option<gdk::Window>;
54 
group<P: IsA<Gesture>>(&self, gesture: &P)55     fn group<P: IsA<Gesture>>(&self, gesture: &P);
56 
handles_sequence(&self, sequence: Option<&gdk::EventSequence>) -> bool57     fn handles_sequence(&self, sequence: Option<&gdk::EventSequence>) -> bool;
58 
is_active(&self) -> bool59     fn is_active(&self) -> bool;
60 
is_grouped_with<P: IsA<Gesture>>(&self, other: &P) -> bool61     fn is_grouped_with<P: IsA<Gesture>>(&self, other: &P) -> bool;
62 
is_recognized(&self) -> bool63     fn is_recognized(&self) -> bool;
64 
set_sequence_state(&self, sequence: &gdk::EventSequence, state: EventSequenceState) -> bool65     fn set_sequence_state(&self, sequence: &gdk::EventSequence, state: EventSequenceState) -> bool;
66 
set_state(&self, state: EventSequenceState) -> bool67     fn set_state(&self, state: EventSequenceState) -> bool;
68 
set_window<P: IsA<gdk::Window>>(&self, window: Option<&P>)69     fn set_window<P: IsA<gdk::Window>>(&self, window: Option<&P>);
70 
ungroup(&self)71     fn ungroup(&self);
72 
get_property_n_points(&self) -> u3273     fn get_property_n_points(&self) -> u32;
74 
connect_begin<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId75     fn connect_begin<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId;
76 
connect_cancel<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId77     fn connect_cancel<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId;
78 
connect_end<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId79     fn connect_end<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId;
80 
connect_sequence_state_changed< F: Fn(&Self, &gdk::EventSequence, EventSequenceState) + 'static, >( &self, f: F, ) -> SignalHandlerId81     fn connect_sequence_state_changed<
82         F: Fn(&Self, &gdk::EventSequence, EventSequenceState) + 'static,
83     >(
84         &self,
85         f: F,
86     ) -> SignalHandlerId;
87 
connect_update<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId88     fn connect_update<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId;
89 
connect_property_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId90     fn connect_property_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
91 }
92 
93 impl<O: IsA<Gesture>> GestureExt for O {
get_bounding_box(&self) -> Option<gdk::Rectangle>94     fn get_bounding_box(&self) -> Option<gdk::Rectangle> {
95         unsafe {
96             let mut rect = gdk::Rectangle::uninitialized();
97             let ret = from_glib(gtk_sys::gtk_gesture_get_bounding_box(
98                 self.as_ref().to_glib_none().0,
99                 rect.to_glib_none_mut().0,
100             ));
101             if ret {
102                 Some(rect)
103             } else {
104                 None
105             }
106         }
107     }
108 
get_bounding_box_center(&self) -> Option<(f64, f64)>109     fn get_bounding_box_center(&self) -> Option<(f64, f64)> {
110         unsafe {
111             let mut x = mem::MaybeUninit::uninit();
112             let mut y = mem::MaybeUninit::uninit();
113             let ret = from_glib(gtk_sys::gtk_gesture_get_bounding_box_center(
114                 self.as_ref().to_glib_none().0,
115                 x.as_mut_ptr(),
116                 y.as_mut_ptr(),
117             ));
118             let x = x.assume_init();
119             let y = y.assume_init();
120             if ret {
121                 Some((x, y))
122             } else {
123                 None
124             }
125         }
126     }
127 
get_device(&self) -> Option<gdk::Device>128     fn get_device(&self) -> Option<gdk::Device> {
129         unsafe {
130             from_glib_none(gtk_sys::gtk_gesture_get_device(
131                 self.as_ref().to_glib_none().0,
132             ))
133         }
134     }
135 
get_group(&self) -> Vec<Gesture>136     fn get_group(&self) -> Vec<Gesture> {
137         unsafe {
138             FromGlibPtrContainer::from_glib_container(gtk_sys::gtk_gesture_get_group(
139                 self.as_ref().to_glib_none().0,
140             ))
141         }
142     }
143 
get_last_event(&self, sequence: Option<&gdk::EventSequence>) -> Option<gdk::Event>144     fn get_last_event(&self, sequence: Option<&gdk::EventSequence>) -> Option<gdk::Event> {
145         unsafe {
146             from_glib_none(gtk_sys::gtk_gesture_get_last_event(
147                 self.as_ref().to_glib_none().0,
148                 mut_override(sequence.to_glib_none().0),
149             ))
150         }
151     }
152 
get_last_updated_sequence(&self) -> Option<gdk::EventSequence>153     fn get_last_updated_sequence(&self) -> Option<gdk::EventSequence> {
154         unsafe {
155             from_glib_none(gtk_sys::gtk_gesture_get_last_updated_sequence(
156                 self.as_ref().to_glib_none().0,
157             ))
158         }
159     }
160 
get_point(&self, sequence: Option<&gdk::EventSequence>) -> Option<(f64, f64)>161     fn get_point(&self, sequence: Option<&gdk::EventSequence>) -> Option<(f64, f64)> {
162         unsafe {
163             let mut x = mem::MaybeUninit::uninit();
164             let mut y = mem::MaybeUninit::uninit();
165             let ret = from_glib(gtk_sys::gtk_gesture_get_point(
166                 self.as_ref().to_glib_none().0,
167                 mut_override(sequence.to_glib_none().0),
168                 x.as_mut_ptr(),
169                 y.as_mut_ptr(),
170             ));
171             let x = x.assume_init();
172             let y = y.assume_init();
173             if ret {
174                 Some((x, y))
175             } else {
176                 None
177             }
178         }
179     }
180 
get_sequence_state(&self, sequence: &gdk::EventSequence) -> EventSequenceState181     fn get_sequence_state(&self, sequence: &gdk::EventSequence) -> EventSequenceState {
182         unsafe {
183             from_glib(gtk_sys::gtk_gesture_get_sequence_state(
184                 self.as_ref().to_glib_none().0,
185                 mut_override(sequence.to_glib_none().0),
186             ))
187         }
188     }
189 
get_sequences(&self) -> Vec<gdk::EventSequence>190     fn get_sequences(&self) -> Vec<gdk::EventSequence> {
191         unsafe {
192             FromGlibPtrContainer::from_glib_container(gtk_sys::gtk_gesture_get_sequences(
193                 self.as_ref().to_glib_none().0,
194             ))
195         }
196     }
197 
get_window(&self) -> Option<gdk::Window>198     fn get_window(&self) -> Option<gdk::Window> {
199         unsafe {
200             from_glib_none(gtk_sys::gtk_gesture_get_window(
201                 self.as_ref().to_glib_none().0,
202             ))
203         }
204     }
205 
group<P: IsA<Gesture>>(&self, gesture: &P)206     fn group<P: IsA<Gesture>>(&self, gesture: &P) {
207         unsafe {
208             gtk_sys::gtk_gesture_group(
209                 self.as_ref().to_glib_none().0,
210                 gesture.as_ref().to_glib_none().0,
211             );
212         }
213     }
214 
handles_sequence(&self, sequence: Option<&gdk::EventSequence>) -> bool215     fn handles_sequence(&self, sequence: Option<&gdk::EventSequence>) -> bool {
216         unsafe {
217             from_glib(gtk_sys::gtk_gesture_handles_sequence(
218                 self.as_ref().to_glib_none().0,
219                 mut_override(sequence.to_glib_none().0),
220             ))
221         }
222     }
223 
is_active(&self) -> bool224     fn is_active(&self) -> bool {
225         unsafe {
226             from_glib(gtk_sys::gtk_gesture_is_active(
227                 self.as_ref().to_glib_none().0,
228             ))
229         }
230     }
231 
is_grouped_with<P: IsA<Gesture>>(&self, other: &P) -> bool232     fn is_grouped_with<P: IsA<Gesture>>(&self, other: &P) -> bool {
233         unsafe {
234             from_glib(gtk_sys::gtk_gesture_is_grouped_with(
235                 self.as_ref().to_glib_none().0,
236                 other.as_ref().to_glib_none().0,
237             ))
238         }
239     }
240 
is_recognized(&self) -> bool241     fn is_recognized(&self) -> bool {
242         unsafe {
243             from_glib(gtk_sys::gtk_gesture_is_recognized(
244                 self.as_ref().to_glib_none().0,
245             ))
246         }
247     }
248 
set_sequence_state(&self, sequence: &gdk::EventSequence, state: EventSequenceState) -> bool249     fn set_sequence_state(&self, sequence: &gdk::EventSequence, state: EventSequenceState) -> bool {
250         unsafe {
251             from_glib(gtk_sys::gtk_gesture_set_sequence_state(
252                 self.as_ref().to_glib_none().0,
253                 mut_override(sequence.to_glib_none().0),
254                 state.to_glib(),
255             ))
256         }
257     }
258 
set_state(&self, state: EventSequenceState) -> bool259     fn set_state(&self, state: EventSequenceState) -> bool {
260         unsafe {
261             from_glib(gtk_sys::gtk_gesture_set_state(
262                 self.as_ref().to_glib_none().0,
263                 state.to_glib(),
264             ))
265         }
266     }
267 
set_window<P: IsA<gdk::Window>>(&self, window: Option<&P>)268     fn set_window<P: IsA<gdk::Window>>(&self, window: Option<&P>) {
269         unsafe {
270             gtk_sys::gtk_gesture_set_window(
271                 self.as_ref().to_glib_none().0,
272                 window.map(|p| p.as_ref()).to_glib_none().0,
273             );
274         }
275     }
276 
ungroup(&self)277     fn ungroup(&self) {
278         unsafe {
279             gtk_sys::gtk_gesture_ungroup(self.as_ref().to_glib_none().0);
280         }
281     }
282 
get_property_n_points(&self) -> u32283     fn get_property_n_points(&self) -> u32 {
284         unsafe {
285             let mut value = Value::from_type(<u32 as StaticType>::static_type());
286             gobject_sys::g_object_get_property(
287                 self.to_glib_none().0 as *mut gobject_sys::GObject,
288                 b"n-points\0".as_ptr() as *const _,
289                 value.to_glib_none_mut().0,
290             );
291             value
292                 .get()
293                 .expect("Return Value for property `n-points` getter")
294                 .unwrap()
295         }
296     }
297 
connect_begin<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId298     fn connect_begin<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId {
299         unsafe extern "C" fn begin_trampoline<P, F: Fn(&P, &gdk::EventSequence) + 'static>(
300             this: *mut gtk_sys::GtkGesture,
301             sequence: *mut gdk_sys::GdkEventSequence,
302             f: glib_sys::gpointer,
303         ) where
304             P: IsA<Gesture>,
305         {
306             let f: &F = &*(f as *const F);
307             f(
308                 &Gesture::from_glib_borrow(this).unsafe_cast(),
309                 &from_glib_borrow(sequence),
310             )
311         }
312         unsafe {
313             let f: Box_<F> = Box_::new(f);
314             connect_raw(
315                 self.as_ptr() as *mut _,
316                 b"begin\0".as_ptr() as *const _,
317                 Some(transmute(begin_trampoline::<Self, F> as usize)),
318                 Box_::into_raw(f),
319             )
320         }
321     }
322 
connect_cancel<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId323     fn connect_cancel<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId {
324         unsafe extern "C" fn cancel_trampoline<P, F: Fn(&P, &gdk::EventSequence) + 'static>(
325             this: *mut gtk_sys::GtkGesture,
326             sequence: *mut gdk_sys::GdkEventSequence,
327             f: glib_sys::gpointer,
328         ) where
329             P: IsA<Gesture>,
330         {
331             let f: &F = &*(f as *const F);
332             f(
333                 &Gesture::from_glib_borrow(this).unsafe_cast(),
334                 &from_glib_borrow(sequence),
335             )
336         }
337         unsafe {
338             let f: Box_<F> = Box_::new(f);
339             connect_raw(
340                 self.as_ptr() as *mut _,
341                 b"cancel\0".as_ptr() as *const _,
342                 Some(transmute(cancel_trampoline::<Self, F> as usize)),
343                 Box_::into_raw(f),
344             )
345         }
346     }
347 
connect_end<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId348     fn connect_end<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId {
349         unsafe extern "C" fn end_trampoline<P, F: Fn(&P, &gdk::EventSequence) + 'static>(
350             this: *mut gtk_sys::GtkGesture,
351             sequence: *mut gdk_sys::GdkEventSequence,
352             f: glib_sys::gpointer,
353         ) where
354             P: IsA<Gesture>,
355         {
356             let f: &F = &*(f as *const F);
357             f(
358                 &Gesture::from_glib_borrow(this).unsafe_cast(),
359                 &from_glib_borrow(sequence),
360             )
361         }
362         unsafe {
363             let f: Box_<F> = Box_::new(f);
364             connect_raw(
365                 self.as_ptr() as *mut _,
366                 b"end\0".as_ptr() as *const _,
367                 Some(transmute(end_trampoline::<Self, F> as usize)),
368                 Box_::into_raw(f),
369             )
370         }
371     }
372 
connect_sequence_state_changed< F: Fn(&Self, &gdk::EventSequence, EventSequenceState) + 'static, >( &self, f: F, ) -> SignalHandlerId373     fn connect_sequence_state_changed<
374         F: Fn(&Self, &gdk::EventSequence, EventSequenceState) + 'static,
375     >(
376         &self,
377         f: F,
378     ) -> SignalHandlerId {
379         unsafe extern "C" fn sequence_state_changed_trampoline<
380             P,
381             F: Fn(&P, &gdk::EventSequence, EventSequenceState) + 'static,
382         >(
383             this: *mut gtk_sys::GtkGesture,
384             sequence: *mut gdk_sys::GdkEventSequence,
385             state: gtk_sys::GtkEventSequenceState,
386             f: glib_sys::gpointer,
387         ) where
388             P: IsA<Gesture>,
389         {
390             let f: &F = &*(f as *const F);
391             f(
392                 &Gesture::from_glib_borrow(this).unsafe_cast(),
393                 &from_glib_borrow(sequence),
394                 from_glib(state),
395             )
396         }
397         unsafe {
398             let f: Box_<F> = Box_::new(f);
399             connect_raw(
400                 self.as_ptr() as *mut _,
401                 b"sequence-state-changed\0".as_ptr() as *const _,
402                 Some(transmute(
403                     sequence_state_changed_trampoline::<Self, F> as usize,
404                 )),
405                 Box_::into_raw(f),
406             )
407         }
408     }
409 
connect_update<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId410     fn connect_update<F: Fn(&Self, &gdk::EventSequence) + 'static>(&self, f: F) -> SignalHandlerId {
411         unsafe extern "C" fn update_trampoline<P, F: Fn(&P, &gdk::EventSequence) + 'static>(
412             this: *mut gtk_sys::GtkGesture,
413             sequence: *mut gdk_sys::GdkEventSequence,
414             f: glib_sys::gpointer,
415         ) where
416             P: IsA<Gesture>,
417         {
418             let f: &F = &*(f as *const F);
419             f(
420                 &Gesture::from_glib_borrow(this).unsafe_cast(),
421                 &from_glib_borrow(sequence),
422             )
423         }
424         unsafe {
425             let f: Box_<F> = Box_::new(f);
426             connect_raw(
427                 self.as_ptr() as *mut _,
428                 b"update\0".as_ptr() as *const _,
429                 Some(transmute(update_trampoline::<Self, F> as usize)),
430                 Box_::into_raw(f),
431             )
432         }
433     }
434 
connect_property_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId435     fn connect_property_window_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
436         unsafe extern "C" fn notify_window_trampoline<P, F: Fn(&P) + 'static>(
437             this: *mut gtk_sys::GtkGesture,
438             _param_spec: glib_sys::gpointer,
439             f: glib_sys::gpointer,
440         ) where
441             P: IsA<Gesture>,
442         {
443             let f: &F = &*(f as *const F);
444             f(&Gesture::from_glib_borrow(this).unsafe_cast())
445         }
446         unsafe {
447             let f: Box_<F> = Box_::new(f);
448             connect_raw(
449                 self.as_ptr() as *mut _,
450                 b"notify::window\0".as_ptr() as *const _,
451                 Some(transmute(notify_window_trampoline::<Self, F> as usize)),
452                 Box_::into_raw(f),
453             )
454         }
455     }
456 }
457 
458 impl fmt::Display for Gesture {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result459     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
460         write!(f, "Gesture")
461     }
462 }
463