gtk4/auto/
gesture_single.rs1use crate::{ffi, EventController, Gesture};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GtkGestureSingle")]
15 pub struct GestureSingle(Object<ffi::GtkGestureSingle, ffi::GtkGestureSingleClass>) @extends Gesture, EventController;
16
17 match fn {
18 type_ => || ffi::gtk_gesture_single_get_type(),
19 }
20}
21
22impl GestureSingle {
23 pub const NONE: Option<&'static GestureSingle> = None;
24}
25
26pub trait GestureSingleExt: IsA<GestureSingle> + 'static {
27 #[doc(alias = "gtk_gesture_single_get_button")]
28 #[doc(alias = "get_button")]
29 fn button(&self) -> u32 {
30 unsafe { ffi::gtk_gesture_single_get_button(self.as_ref().to_glib_none().0) }
31 }
32
33 #[doc(alias = "gtk_gesture_single_get_current_button")]
34 #[doc(alias = "get_current_button")]
35 fn current_button(&self) -> u32 {
36 unsafe { ffi::gtk_gesture_single_get_current_button(self.as_ref().to_glib_none().0) }
37 }
38
39 #[doc(alias = "gtk_gesture_single_get_current_sequence")]
40 #[doc(alias = "get_current_sequence")]
41 fn current_sequence(&self) -> Option<gdk::EventSequence> {
42 unsafe {
43 from_glib_full(ffi::gtk_gesture_single_get_current_sequence(
44 self.as_ref().to_glib_none().0,
45 ))
46 }
47 }
48
49 #[doc(alias = "gtk_gesture_single_get_exclusive")]
50 #[doc(alias = "get_exclusive")]
51 #[doc(alias = "exclusive")]
52 fn is_exclusive(&self) -> bool {
53 unsafe {
54 from_glib(ffi::gtk_gesture_single_get_exclusive(
55 self.as_ref().to_glib_none().0,
56 ))
57 }
58 }
59
60 #[doc(alias = "gtk_gesture_single_get_touch_only")]
61 #[doc(alias = "get_touch_only")]
62 #[doc(alias = "touch-only")]
63 fn is_touch_only(&self) -> bool {
64 unsafe {
65 from_glib(ffi::gtk_gesture_single_get_touch_only(
66 self.as_ref().to_glib_none().0,
67 ))
68 }
69 }
70
71 #[doc(alias = "gtk_gesture_single_set_button")]
72 #[doc(alias = "button")]
73 fn set_button(&self, button: u32) {
74 unsafe {
75 ffi::gtk_gesture_single_set_button(self.as_ref().to_glib_none().0, button);
76 }
77 }
78
79 #[doc(alias = "gtk_gesture_single_set_exclusive")]
80 #[doc(alias = "exclusive")]
81 fn set_exclusive(&self, exclusive: bool) {
82 unsafe {
83 ffi::gtk_gesture_single_set_exclusive(
84 self.as_ref().to_glib_none().0,
85 exclusive.into_glib(),
86 );
87 }
88 }
89
90 #[doc(alias = "gtk_gesture_single_set_touch_only")]
91 #[doc(alias = "touch-only")]
92 fn set_touch_only(&self, touch_only: bool) {
93 unsafe {
94 ffi::gtk_gesture_single_set_touch_only(
95 self.as_ref().to_glib_none().0,
96 touch_only.into_glib(),
97 );
98 }
99 }
100
101 #[doc(alias = "button")]
102 fn connect_button_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
103 unsafe extern "C" fn notify_button_trampoline<
104 P: IsA<GestureSingle>,
105 F: Fn(&P) + 'static,
106 >(
107 this: *mut ffi::GtkGestureSingle,
108 _param_spec: glib::ffi::gpointer,
109 f: glib::ffi::gpointer,
110 ) {
111 let f: &F = &*(f as *const F);
112 f(GestureSingle::from_glib_borrow(this).unsafe_cast_ref())
113 }
114 unsafe {
115 let f: Box_<F> = Box_::new(f);
116 connect_raw(
117 self.as_ptr() as *mut _,
118 c"notify::button".as_ptr() as *const _,
119 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
120 notify_button_trampoline::<Self, F> as *const (),
121 )),
122 Box_::into_raw(f),
123 )
124 }
125 }
126
127 #[doc(alias = "exclusive")]
128 fn connect_exclusive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
129 unsafe extern "C" fn notify_exclusive_trampoline<
130 P: IsA<GestureSingle>,
131 F: Fn(&P) + 'static,
132 >(
133 this: *mut ffi::GtkGestureSingle,
134 _param_spec: glib::ffi::gpointer,
135 f: glib::ffi::gpointer,
136 ) {
137 let f: &F = &*(f as *const F);
138 f(GestureSingle::from_glib_borrow(this).unsafe_cast_ref())
139 }
140 unsafe {
141 let f: Box_<F> = Box_::new(f);
142 connect_raw(
143 self.as_ptr() as *mut _,
144 c"notify::exclusive".as_ptr() as *const _,
145 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
146 notify_exclusive_trampoline::<Self, F> as *const (),
147 )),
148 Box_::into_raw(f),
149 )
150 }
151 }
152
153 #[doc(alias = "touch-only")]
154 fn connect_touch_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
155 unsafe extern "C" fn notify_touch_only_trampoline<
156 P: IsA<GestureSingle>,
157 F: Fn(&P) + 'static,
158 >(
159 this: *mut ffi::GtkGestureSingle,
160 _param_spec: glib::ffi::gpointer,
161 f: glib::ffi::gpointer,
162 ) {
163 let f: &F = &*(f as *const F);
164 f(GestureSingle::from_glib_borrow(this).unsafe_cast_ref())
165 }
166 unsafe {
167 let f: Box_<F> = Box_::new(f);
168 connect_raw(
169 self.as_ptr() as *mut _,
170 c"notify::touch-only".as_ptr() as *const _,
171 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
172 notify_touch_only_trampoline::<Self, F> as *const (),
173 )),
174 Box_::into_raw(f),
175 )
176 }
177 }
178}
179
180impl<O: IsA<GestureSingle>> GestureSingleExt for O {}