gtk4/auto/
event_controller.rs

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
5use crate::{ffi, PropagationLimit, PropagationPhase, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkEventController")]
15    pub struct EventController(Object<ffi::GtkEventController, ffi::GtkEventControllerClass>);
16
17    match fn {
18        type_ => || ffi::gtk_event_controller_get_type(),
19    }
20}
21
22impl EventController {
23    pub const NONE: Option<&'static EventController> = None;
24}
25
26mod sealed {
27    pub trait Sealed {}
28    impl<T: super::IsA<super::EventController>> Sealed for T {}
29}
30
31pub trait EventControllerExt: IsA<EventController> + sealed::Sealed + 'static {
32    #[doc(alias = "gtk_event_controller_get_current_event")]
33    #[doc(alias = "get_current_event")]
34    fn current_event(&self) -> Option<gdk::Event> {
35        unsafe {
36            from_glib_none(ffi::gtk_event_controller_get_current_event(
37                self.as_ref().to_glib_none().0,
38            ))
39        }
40    }
41
42    #[doc(alias = "gtk_event_controller_get_current_event_device")]
43    #[doc(alias = "get_current_event_device")]
44    fn current_event_device(&self) -> Option<gdk::Device> {
45        unsafe {
46            from_glib_none(ffi::gtk_event_controller_get_current_event_device(
47                self.as_ref().to_glib_none().0,
48            ))
49        }
50    }
51
52    #[doc(alias = "gtk_event_controller_get_current_event_state")]
53    #[doc(alias = "get_current_event_state")]
54    fn current_event_state(&self) -> gdk::ModifierType {
55        unsafe {
56            from_glib(ffi::gtk_event_controller_get_current_event_state(
57                self.as_ref().to_glib_none().0,
58            ))
59        }
60    }
61
62    #[doc(alias = "gtk_event_controller_get_current_event_time")]
63    #[doc(alias = "get_current_event_time")]
64    fn current_event_time(&self) -> u32 {
65        unsafe { ffi::gtk_event_controller_get_current_event_time(self.as_ref().to_glib_none().0) }
66    }
67
68    #[doc(alias = "gtk_event_controller_get_name")]
69    #[doc(alias = "get_name")]
70    fn name(&self) -> Option<glib::GString> {
71        unsafe {
72            from_glib_none(ffi::gtk_event_controller_get_name(
73                self.as_ref().to_glib_none().0,
74            ))
75        }
76    }
77
78    #[doc(alias = "gtk_event_controller_get_propagation_limit")]
79    #[doc(alias = "get_propagation_limit")]
80    #[doc(alias = "propagation-limit")]
81    fn propagation_limit(&self) -> PropagationLimit {
82        unsafe {
83            from_glib(ffi::gtk_event_controller_get_propagation_limit(
84                self.as_ref().to_glib_none().0,
85            ))
86        }
87    }
88
89    #[doc(alias = "gtk_event_controller_get_propagation_phase")]
90    #[doc(alias = "get_propagation_phase")]
91    #[doc(alias = "propagation-phase")]
92    fn propagation_phase(&self) -> PropagationPhase {
93        unsafe {
94            from_glib(ffi::gtk_event_controller_get_propagation_phase(
95                self.as_ref().to_glib_none().0,
96            ))
97        }
98    }
99
100    #[doc(alias = "gtk_event_controller_get_widget")]
101    #[doc(alias = "get_widget")]
102    fn widget(&self) -> Option<Widget> {
103        unsafe {
104            from_glib_none(ffi::gtk_event_controller_get_widget(
105                self.as_ref().to_glib_none().0,
106            ))
107        }
108    }
109
110    #[doc(alias = "gtk_event_controller_reset")]
111    fn reset(&self) {
112        unsafe {
113            ffi::gtk_event_controller_reset(self.as_ref().to_glib_none().0);
114        }
115    }
116
117    #[doc(alias = "gtk_event_controller_set_name")]
118    #[doc(alias = "name")]
119    fn set_name(&self, name: Option<&str>) {
120        unsafe {
121            ffi::gtk_event_controller_set_name(
122                self.as_ref().to_glib_none().0,
123                name.to_glib_none().0,
124            );
125        }
126    }
127
128    #[doc(alias = "gtk_event_controller_set_propagation_limit")]
129    #[doc(alias = "propagation-limit")]
130    fn set_propagation_limit(&self, limit: PropagationLimit) {
131        unsafe {
132            ffi::gtk_event_controller_set_propagation_limit(
133                self.as_ref().to_glib_none().0,
134                limit.into_glib(),
135            );
136        }
137    }
138
139    #[doc(alias = "gtk_event_controller_set_propagation_phase")]
140    #[doc(alias = "propagation-phase")]
141    fn set_propagation_phase(&self, phase: PropagationPhase) {
142        unsafe {
143            ffi::gtk_event_controller_set_propagation_phase(
144                self.as_ref().to_glib_none().0,
145                phase.into_glib(),
146            );
147        }
148    }
149
150    #[doc(alias = "name")]
151    fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
152        unsafe extern "C" fn notify_name_trampoline<
153            P: IsA<EventController>,
154            F: Fn(&P) + 'static,
155        >(
156            this: *mut ffi::GtkEventController,
157            _param_spec: glib::ffi::gpointer,
158            f: glib::ffi::gpointer,
159        ) {
160            let f: &F = &*(f as *const F);
161            f(EventController::from_glib_borrow(this).unsafe_cast_ref())
162        }
163        unsafe {
164            let f: Box_<F> = Box_::new(f);
165            connect_raw(
166                self.as_ptr() as *mut _,
167                b"notify::name\0".as_ptr() as *const _,
168                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
169                    notify_name_trampoline::<Self, F> as *const (),
170                )),
171                Box_::into_raw(f),
172            )
173        }
174    }
175
176    #[doc(alias = "propagation-limit")]
177    fn connect_propagation_limit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
178        unsafe extern "C" fn notify_propagation_limit_trampoline<
179            P: IsA<EventController>,
180            F: Fn(&P) + 'static,
181        >(
182            this: *mut ffi::GtkEventController,
183            _param_spec: glib::ffi::gpointer,
184            f: glib::ffi::gpointer,
185        ) {
186            let f: &F = &*(f as *const F);
187            f(EventController::from_glib_borrow(this).unsafe_cast_ref())
188        }
189        unsafe {
190            let f: Box_<F> = Box_::new(f);
191            connect_raw(
192                self.as_ptr() as *mut _,
193                b"notify::propagation-limit\0".as_ptr() as *const _,
194                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
195                    notify_propagation_limit_trampoline::<Self, F> as *const (),
196                )),
197                Box_::into_raw(f),
198            )
199        }
200    }
201
202    #[doc(alias = "propagation-phase")]
203    fn connect_propagation_phase_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
204        unsafe extern "C" fn notify_propagation_phase_trampoline<
205            P: IsA<EventController>,
206            F: Fn(&P) + 'static,
207        >(
208            this: *mut ffi::GtkEventController,
209            _param_spec: glib::ffi::gpointer,
210            f: glib::ffi::gpointer,
211        ) {
212            let f: &F = &*(f as *const F);
213            f(EventController::from_glib_borrow(this).unsafe_cast_ref())
214        }
215        unsafe {
216            let f: Box_<F> = Box_::new(f);
217            connect_raw(
218                self.as_ptr() as *mut _,
219                b"notify::propagation-phase\0".as_ptr() as *const _,
220                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
221                    notify_propagation_phase_trampoline::<Self, F> as *const (),
222                )),
223                Box_::into_raw(f),
224            )
225        }
226    }
227
228    #[doc(alias = "widget")]
229    fn connect_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
230        unsafe extern "C" fn notify_widget_trampoline<
231            P: IsA<EventController>,
232            F: Fn(&P) + 'static,
233        >(
234            this: *mut ffi::GtkEventController,
235            _param_spec: glib::ffi::gpointer,
236            f: glib::ffi::gpointer,
237        ) {
238            let f: &F = &*(f as *const F);
239            f(EventController::from_glib_borrow(this).unsafe_cast_ref())
240        }
241        unsafe {
242            let f: Box_<F> = Box_::new(f);
243            connect_raw(
244                self.as_ptr() as *mut _,
245                b"notify::widget\0".as_ptr() as *const _,
246                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
247                    notify_widget_trampoline::<Self, F> as *const (),
248                )),
249                Box_::into_raw(f),
250            )
251        }
252    }
253}
254
255impl<O: IsA<EventController>> EventControllerExt for O {}