[go: up one dir, main page]

gtk4/auto/
gesture_click.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, Gesture, GestureSingle, 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 = "GtkGestureClick")]
16    pub struct GestureClick(Object<ffi::GtkGestureClick, ffi::GtkGestureClickClass>) @extends GestureSingle, Gesture, EventController;
17
18    match fn {
19        type_ => || ffi::gtk_gesture_click_get_type(),
20    }
21}
22
23impl GestureClick {
24    #[doc(alias = "gtk_gesture_click_new")]
25    pub fn new() -> GestureClick {
26        assert_initialized_main_thread!();
27        unsafe { Gesture::from_glib_full(ffi::gtk_gesture_click_new()).unsafe_cast() }
28    }
29
30    // rustdoc-stripper-ignore-next
31    /// Creates a new builder-pattern struct instance to construct [`GestureClick`] objects.
32    ///
33    /// This method returns an instance of [`GestureClickBuilder`](crate::builders::GestureClickBuilder) which can be used to create [`GestureClick`] objects.
34    pub fn builder() -> GestureClickBuilder {
35        GestureClickBuilder::new()
36    }
37
38    #[doc(alias = "pressed")]
39    pub fn connect_pressed<F: Fn(&Self, i32, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
40        unsafe extern "C" fn pressed_trampoline<F: Fn(&GestureClick, i32, f64, f64) + 'static>(
41            this: *mut ffi::GtkGestureClick,
42            n_press: std::ffi::c_int,
43            x: std::ffi::c_double,
44            y: std::ffi::c_double,
45            f: glib::ffi::gpointer,
46        ) {
47            let f: &F = &*(f as *const F);
48            f(&from_glib_borrow(this), n_press, x, y)
49        }
50        unsafe {
51            let f: Box_<F> = Box_::new(f);
52            connect_raw(
53                self.as_ptr() as *mut _,
54                c"pressed".as_ptr() as *const _,
55                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
56                    pressed_trampoline::<F> as *const (),
57                )),
58                Box_::into_raw(f),
59            )
60        }
61    }
62
63    #[doc(alias = "released")]
64    pub fn connect_released<F: Fn(&Self, i32, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId {
65        unsafe extern "C" fn released_trampoline<F: Fn(&GestureClick, i32, f64, f64) + 'static>(
66            this: *mut ffi::GtkGestureClick,
67            n_press: std::ffi::c_int,
68            x: std::ffi::c_double,
69            y: std::ffi::c_double,
70            f: glib::ffi::gpointer,
71        ) {
72            let f: &F = &*(f as *const F);
73            f(&from_glib_borrow(this), n_press, x, y)
74        }
75        unsafe {
76            let f: Box_<F> = Box_::new(f);
77            connect_raw(
78                self.as_ptr() as *mut _,
79                c"released".as_ptr() as *const _,
80                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
81                    released_trampoline::<F> as *const (),
82                )),
83                Box_::into_raw(f),
84            )
85        }
86    }
87
88    #[doc(alias = "stopped")]
89    pub fn connect_stopped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
90        unsafe extern "C" fn stopped_trampoline<F: Fn(&GestureClick) + 'static>(
91            this: *mut ffi::GtkGestureClick,
92            f: glib::ffi::gpointer,
93        ) {
94            let f: &F = &*(f as *const F);
95            f(&from_glib_borrow(this))
96        }
97        unsafe {
98            let f: Box_<F> = Box_::new(f);
99            connect_raw(
100                self.as_ptr() as *mut _,
101                c"stopped".as_ptr() as *const _,
102                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
103                    stopped_trampoline::<F> as *const (),
104                )),
105                Box_::into_raw(f),
106            )
107        }
108    }
109
110    #[doc(alias = "unpaired-release")]
111    pub fn connect_unpaired_release<
112        F: Fn(&Self, f64, f64, u32, Option<&gdk::EventSequence>) + 'static,
113    >(
114        &self,
115        f: F,
116    ) -> SignalHandlerId {
117        unsafe extern "C" fn unpaired_release_trampoline<
118            F: Fn(&GestureClick, f64, f64, u32, Option<&gdk::EventSequence>) + 'static,
119        >(
120            this: *mut ffi::GtkGestureClick,
121            x: std::ffi::c_double,
122            y: std::ffi::c_double,
123            button: std::ffi::c_uint,
124            sequence: *mut gdk::ffi::GdkEventSequence,
125            f: glib::ffi::gpointer,
126        ) {
127            let f: &F = &*(f as *const F);
128            f(
129                &from_glib_borrow(this),
130                x,
131                y,
132                button,
133                Option::<gdk::EventSequence>::from_glib_borrow(sequence)
134                    .as_ref()
135                    .as_ref(),
136            )
137        }
138        unsafe {
139            let f: Box_<F> = Box_::new(f);
140            connect_raw(
141                self.as_ptr() as *mut _,
142                c"unpaired-release".as_ptr() as *const _,
143                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
144                    unpaired_release_trampoline::<F> as *const (),
145                )),
146                Box_::into_raw(f),
147            )
148        }
149    }
150}
151
152impl Default for GestureClick {
153    fn default() -> Self {
154        Self::new()
155    }
156}
157
158// rustdoc-stripper-ignore-next
159/// A [builder-pattern] type to construct [`GestureClick`] objects.
160///
161/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
162#[must_use = "The builder must be built to be used"]
163pub struct GestureClickBuilder {
164    builder: glib::object::ObjectBuilder<'static, GestureClick>,
165}
166
167impl GestureClickBuilder {
168    fn new() -> Self {
169        Self {
170            builder: glib::object::Object::builder(),
171        }
172    }
173
174    pub fn button(self, button: u32) -> Self {
175        Self {
176            builder: self.builder.property("button", button),
177        }
178    }
179
180    pub fn exclusive(self, exclusive: bool) -> Self {
181        Self {
182            builder: self.builder.property("exclusive", exclusive),
183        }
184    }
185
186    pub fn touch_only(self, touch_only: bool) -> Self {
187        Self {
188            builder: self.builder.property("touch-only", touch_only),
189        }
190    }
191
192    pub fn n_points(self, n_points: u32) -> Self {
193        Self {
194            builder: self.builder.property("n-points", n_points),
195        }
196    }
197
198    pub fn name(self, name: impl Into<glib::GString>) -> Self {
199        Self {
200            builder: self.builder.property("name", name.into()),
201        }
202    }
203
204    pub fn propagation_limit(self, propagation_limit: PropagationLimit) -> Self {
205        Self {
206            builder: self
207                .builder
208                .property("propagation-limit", propagation_limit),
209        }
210    }
211
212    pub fn propagation_phase(self, propagation_phase: PropagationPhase) -> Self {
213        Self {
214            builder: self
215                .builder
216                .property("propagation-phase", propagation_phase),
217        }
218    }
219
220    // rustdoc-stripper-ignore-next
221    /// Build the [`GestureClick`].
222    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
223    pub fn build(self) -> GestureClick {
224        assert_initialized_main_thread!();
225        self.builder.build()
226    }
227}