gtk4/auto/
drop_controller_motion.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, EventController, PropagationLimit, PropagationPhase};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkDropControllerMotion")]
16    pub struct DropControllerMotion(Object<ffi::GtkDropControllerMotion, ffi::GtkDropControllerMotionClass>) @extends EventController;
17
18    match fn {
19        type_ => || ffi::gtk_drop_controller_motion_get_type(),
20    }
21}
22
23impl DropControllerMotion {
24    #[doc(alias = "gtk_drop_controller_motion_new")]
25    pub fn new() -> DropControllerMotion {
26        assert_initialized_main_thread!();
27        unsafe {
28            EventController::from_glib_full(ffi::gtk_drop_controller_motion_new()).unsafe_cast()
29        }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`DropControllerMotion`] objects.
34    ///
35    /// This method returns an instance of [`DropControllerMotionBuilder`](crate::builders::DropControllerMotionBuilder) which can be used to create [`DropControllerMotion`] objects.
36    pub fn builder() -> DropControllerMotionBuilder {
37        DropControllerMotionBuilder::new()
38    }
39
40    #[doc(alias = "gtk_drop_controller_motion_contains_pointer")]
41    #[doc(alias = "contains-pointer")]
42    pub fn contains_pointer(&self) -> bool {
43        unsafe {
44            from_glib(ffi::gtk_drop_controller_motion_contains_pointer(
45                self.to_glib_none().0,
46            ))
47        }
48    }
49
50    #[doc(alias = "gtk_drop_controller_motion_get_drop")]
51    #[doc(alias = "get_drop")]
52    pub fn drop(&self) -> Option<gdk::Drop> {
53        unsafe {
54            from_glib_none(ffi::gtk_drop_controller_motion_get_drop(
55                self.to_glib_none().0,
56            ))
57        }
58    }
59
60    #[doc(alias = "gtk_drop_controller_motion_is_pointer")]
61    #[doc(alias = "is-pointer")]
62    pub fn is_pointer(&self) -> bool {
63        unsafe {
64            from_glib(ffi::gtk_drop_controller_motion_is_pointer(
65                self.to_glib_none().0,
66            ))
67        }
68    }
69
70    #[doc(alias = "enter")]
71    pub fn connect_enter<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
72        unsafe extern "C" fn enter_trampoline<F: Fn(&DropControllerMotion, f64, f64) + 'static>(
73            this: *mut ffi::GtkDropControllerMotion,
74            x: std::ffi::c_double,
75            y: std::ffi::c_double,
76            f: glib::ffi::gpointer,
77        ) {
78            let f: &F = &*(f as *const F);
79            f(&from_glib_borrow(this), x, y)
80        }
81        unsafe {
82            let f: Box_<F> = Box_::new(f);
83            connect_raw(
84                self.as_ptr() as *mut _,
85                c"enter".as_ptr() as *const _,
86                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
87                    enter_trampoline::<F> as *const (),
88                )),
89                Box_::into_raw(f),
90            )
91        }
92    }
93
94    #[doc(alias = "leave")]
95    pub fn connect_leave<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
96        unsafe extern "C" fn leave_trampoline<F: Fn(&DropControllerMotion) + 'static>(
97            this: *mut ffi::GtkDropControllerMotion,
98            f: glib::ffi::gpointer,
99        ) {
100            let f: &F = &*(f as *const F);
101            f(&from_glib_borrow(this))
102        }
103        unsafe {
104            let f: Box_<F> = Box_::new(f);
105            connect_raw(
106                self.as_ptr() as *mut _,
107                c"leave".as_ptr() as *const _,
108                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
109                    leave_trampoline::<F> as *const (),
110                )),
111                Box_::into_raw(f),
112            )
113        }
114    }
115
116    #[doc(alias = "motion")]
117    pub fn connect_motion<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
118        unsafe extern "C" fn motion_trampoline<F: Fn(&DropControllerMotion, f64, f64) + 'static>(
119            this: *mut ffi::GtkDropControllerMotion,
120            x: std::ffi::c_double,
121            y: std::ffi::c_double,
122            f: glib::ffi::gpointer,
123        ) {
124            let f: &F = &*(f as *const F);
125            f(&from_glib_borrow(this), x, y)
126        }
127        unsafe {
128            let f: Box_<F> = Box_::new(f);
129            connect_raw(
130                self.as_ptr() as *mut _,
131                c"motion".as_ptr() as *const _,
132                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
133                    motion_trampoline::<F> as *const (),
134                )),
135                Box_::into_raw(f),
136            )
137        }
138    }
139
140    #[doc(alias = "contains-pointer")]
141    pub fn connect_contains_pointer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
142        unsafe extern "C" fn notify_contains_pointer_trampoline<
143            F: Fn(&DropControllerMotion) + 'static,
144        >(
145            this: *mut ffi::GtkDropControllerMotion,
146            _param_spec: glib::ffi::gpointer,
147            f: glib::ffi::gpointer,
148        ) {
149            let f: &F = &*(f as *const F);
150            f(&from_glib_borrow(this))
151        }
152        unsafe {
153            let f: Box_<F> = Box_::new(f);
154            connect_raw(
155                self.as_ptr() as *mut _,
156                c"notify::contains-pointer".as_ptr() as *const _,
157                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
158                    notify_contains_pointer_trampoline::<F> as *const (),
159                )),
160                Box_::into_raw(f),
161            )
162        }
163    }
164
165    #[doc(alias = "drop")]
166    pub fn connect_drop_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
167        unsafe extern "C" fn notify_drop_trampoline<F: Fn(&DropControllerMotion) + 'static>(
168            this: *mut ffi::GtkDropControllerMotion,
169            _param_spec: glib::ffi::gpointer,
170            f: glib::ffi::gpointer,
171        ) {
172            let f: &F = &*(f as *const F);
173            f(&from_glib_borrow(this))
174        }
175        unsafe {
176            let f: Box_<F> = Box_::new(f);
177            connect_raw(
178                self.as_ptr() as *mut _,
179                c"notify::drop".as_ptr() as *const _,
180                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
181                    notify_drop_trampoline::<F> as *const (),
182                )),
183                Box_::into_raw(f),
184            )
185        }
186    }
187
188    #[doc(alias = "is-pointer")]
189    pub fn connect_is_pointer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
190        unsafe extern "C" fn notify_is_pointer_trampoline<
191            F: Fn(&DropControllerMotion) + 'static,
192        >(
193            this: *mut ffi::GtkDropControllerMotion,
194            _param_spec: glib::ffi::gpointer,
195            f: glib::ffi::gpointer,
196        ) {
197            let f: &F = &*(f as *const F);
198            f(&from_glib_borrow(this))
199        }
200        unsafe {
201            let f: Box_<F> = Box_::new(f);
202            connect_raw(
203                self.as_ptr() as *mut _,
204                c"notify::is-pointer".as_ptr() as *const _,
205                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
206                    notify_is_pointer_trampoline::<F> as *const (),
207                )),
208                Box_::into_raw(f),
209            )
210        }
211    }
212}
213
214impl Default for DropControllerMotion {
215    fn default() -> Self {
216        Self::new()
217    }
218}
219
220// rustdoc-stripper-ignore-next
221/// A [builder-pattern] type to construct [`DropControllerMotion`] objects.
222///
223/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
224#[must_use = "The builder must be built to be used"]
225pub struct DropControllerMotionBuilder {
226    builder: glib::object::ObjectBuilder<'static, DropControllerMotion>,
227}
228
229impl DropControllerMotionBuilder {
230    fn new() -> Self {
231        Self {
232            builder: glib::object::Object::builder(),
233        }
234    }
235
236    pub fn name(self, name: impl Into<glib::GString>) -> Self {
237        Self {
238            builder: self.builder.property("name", name.into()),
239        }
240    }
241
242    pub fn propagation_limit(self, propagation_limit: PropagationLimit) -> Self {
243        Self {
244            builder: self
245                .builder
246                .property("propagation-limit", propagation_limit),
247        }
248    }
249
250    pub fn propagation_phase(self, propagation_phase: PropagationPhase) -> Self {
251        Self {
252            builder: self
253                .builder
254                .property("propagation-phase", propagation_phase),
255        }
256    }
257
258    // rustdoc-stripper-ignore-next
259    /// Build the [`DropControllerMotion`].
260    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
261    pub fn build(self) -> DropControllerMotion {
262        assert_initialized_main_thread!();
263        self.builder.build()
264    }
265}