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::Widget;
7 use glib::object::Cast;
8 use glib::object::IsA;
9 use glib::object::ObjectType as ObjectType_;
10 use glib::signal::connect_raw;
11 use glib::signal::SignalHandlerId;
12 use glib::translate::*;
13 use std::boxed::Box as Box_;
14 use std::fmt;
15 use std::mem::transmute;
16 
17 glib::wrapper! {
18     #[doc(alias = "GtkEventControllerMotion")]
19     pub struct EventControllerMotion(Object<ffi::GtkEventControllerMotion, ffi::GtkEventControllerMotionClass>) @extends EventController;
20 
21     match fn {
22         type_ => || ffi::gtk_event_controller_motion_get_type(),
23     }
24 }
25 
26 impl EventControllerMotion {
27     #[doc(alias = "gtk_event_controller_motion_new")]
new<P: IsA<Widget>>(widget: &P) -> EventControllerMotion28     pub fn new<P: IsA<Widget>>(widget: &P) -> EventControllerMotion {
29         skip_assert_initialized!();
30         unsafe {
31             EventController::from_glib_full(ffi::gtk_event_controller_motion_new(
32                 widget.as_ref().to_glib_none().0,
33             ))
34             .unsafe_cast()
35         }
36     }
37 
38     #[doc(alias = "enter")]
connect_enter<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId39     pub fn connect_enter<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
40         unsafe extern "C" fn enter_trampoline<F: Fn(&EventControllerMotion, f64, f64) + 'static>(
41             this: *mut ffi::GtkEventControllerMotion,
42             x: libc::c_double,
43             y: libc::c_double,
44             f: glib::ffi::gpointer,
45         ) {
46             let f: &F = &*(f as *const F);
47             f(&from_glib_borrow(this), x, y)
48         }
49         unsafe {
50             let f: Box_<F> = Box_::new(f);
51             connect_raw(
52                 self.as_ptr() as *mut _,
53                 b"enter\0".as_ptr() as *const _,
54                 Some(transmute::<_, unsafe extern "C" fn()>(
55                     enter_trampoline::<F> as *const (),
56                 )),
57                 Box_::into_raw(f),
58             )
59         }
60     }
61 
62     #[doc(alias = "leave")]
connect_leave<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId63     pub fn connect_leave<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
64         unsafe extern "C" fn leave_trampoline<F: Fn(&EventControllerMotion) + 'static>(
65             this: *mut ffi::GtkEventControllerMotion,
66             f: glib::ffi::gpointer,
67         ) {
68             let f: &F = &*(f as *const F);
69             f(&from_glib_borrow(this))
70         }
71         unsafe {
72             let f: Box_<F> = Box_::new(f);
73             connect_raw(
74                 self.as_ptr() as *mut _,
75                 b"leave\0".as_ptr() as *const _,
76                 Some(transmute::<_, unsafe extern "C" fn()>(
77                     leave_trampoline::<F> as *const (),
78                 )),
79                 Box_::into_raw(f),
80             )
81         }
82     }
83 
84     #[doc(alias = "motion")]
connect_motion<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId85     pub fn connect_motion<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
86         unsafe extern "C" fn motion_trampoline<
87             F: Fn(&EventControllerMotion, f64, f64) + 'static,
88         >(
89             this: *mut ffi::GtkEventControllerMotion,
90             x: libc::c_double,
91             y: libc::c_double,
92             f: glib::ffi::gpointer,
93         ) {
94             let f: &F = &*(f as *const F);
95             f(&from_glib_borrow(this), x, y)
96         }
97         unsafe {
98             let f: Box_<F> = Box_::new(f);
99             connect_raw(
100                 self.as_ptr() as *mut _,
101                 b"motion\0".as_ptr() as *const _,
102                 Some(transmute::<_, unsafe extern "C" fn()>(
103                     motion_trampoline::<F> as *const (),
104                 )),
105                 Box_::into_raw(f),
106             )
107         }
108     }
109 }
110 
111 impl fmt::Display for EventControllerMotion {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result112     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
113         f.write_str("EventControllerMotion")
114     }
115 }
116