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::Gesture; 7 use crate::GestureSingle; 8 use crate::PropagationPhase; 9 use crate::Widget; 10 use glib::object::Cast; 11 use glib::object::IsA; 12 use glib::object::ObjectType as ObjectType_; 13 use glib::signal::connect_raw; 14 use glib::signal::SignalHandlerId; 15 use glib::translate::*; 16 use glib::StaticType; 17 use glib::ToValue; 18 use std::boxed::Box as Box_; 19 use std::fmt; 20 use std::mem::transmute; 21 22 glib::wrapper! { 23 #[doc(alias = "GtkGestureMultiPress")] 24 pub struct GestureMultiPress(Object<ffi::GtkGestureMultiPress, ffi::GtkGestureMultiPressClass>) @extends GestureSingle, Gesture, EventController; 25 26 match fn { 27 type_ => || ffi::gtk_gesture_multi_press_get_type(), 28 } 29 } 30 31 impl GestureMultiPress { 32 #[doc(alias = "gtk_gesture_multi_press_new")] new<P: IsA<Widget>>(widget: &P) -> GestureMultiPress33 pub fn new<P: IsA<Widget>>(widget: &P) -> GestureMultiPress { 34 skip_assert_initialized!(); 35 unsafe { 36 Gesture::from_glib_full(ffi::gtk_gesture_multi_press_new( 37 widget.as_ref().to_glib_none().0, 38 )) 39 .unsafe_cast() 40 } 41 } 42 43 // rustdoc-stripper-ignore-next 44 /// Creates a new builder-pattern struct instance to construct [`GestureMultiPress`] objects. 45 /// 46 /// This method returns an instance of [`GestureMultiPressBuilder`] which can be used to create [`GestureMultiPress`] objects. builder() -> GestureMultiPressBuilder47 pub fn builder() -> GestureMultiPressBuilder { 48 GestureMultiPressBuilder::default() 49 } 50 51 #[doc(alias = "gtk_gesture_multi_press_get_area")] 52 #[doc(alias = "get_area")] area(&self) -> Option<gdk::Rectangle>53 pub fn area(&self) -> Option<gdk::Rectangle> { 54 unsafe { 55 let mut rect = gdk::Rectangle::uninitialized(); 56 let ret = from_glib(ffi::gtk_gesture_multi_press_get_area( 57 self.to_glib_none().0, 58 rect.to_glib_none_mut().0, 59 )); 60 if ret { 61 Some(rect) 62 } else { 63 None 64 } 65 } 66 } 67 68 #[doc(alias = "gtk_gesture_multi_press_set_area")] set_area(&self, rect: Option<&gdk::Rectangle>)69 pub fn set_area(&self, rect: Option<&gdk::Rectangle>) { 70 unsafe { 71 ffi::gtk_gesture_multi_press_set_area(self.to_glib_none().0, rect.to_glib_none().0); 72 } 73 } 74 75 #[doc(alias = "pressed")] connect_pressed<F: Fn(&Self, i32, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId76 pub fn connect_pressed<F: Fn(&Self, i32, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId { 77 unsafe extern "C" fn pressed_trampoline< 78 F: Fn(&GestureMultiPress, i32, f64, f64) + 'static, 79 >( 80 this: *mut ffi::GtkGestureMultiPress, 81 n_press: libc::c_int, 82 x: libc::c_double, 83 y: libc::c_double, 84 f: glib::ffi::gpointer, 85 ) { 86 let f: &F = &*(f as *const F); 87 f(&from_glib_borrow(this), n_press, x, y) 88 } 89 unsafe { 90 let f: Box_<F> = Box_::new(f); 91 connect_raw( 92 self.as_ptr() as *mut _, 93 b"pressed\0".as_ptr() as *const _, 94 Some(transmute::<_, unsafe extern "C" fn()>( 95 pressed_trampoline::<F> as *const (), 96 )), 97 Box_::into_raw(f), 98 ) 99 } 100 } 101 102 #[doc(alias = "released")] connect_released<F: Fn(&Self, i32, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId103 pub fn connect_released<F: Fn(&Self, i32, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId { 104 unsafe extern "C" fn released_trampoline< 105 F: Fn(&GestureMultiPress, i32, f64, f64) + 'static, 106 >( 107 this: *mut ffi::GtkGestureMultiPress, 108 n_press: libc::c_int, 109 x: libc::c_double, 110 y: libc::c_double, 111 f: glib::ffi::gpointer, 112 ) { 113 let f: &F = &*(f as *const F); 114 f(&from_glib_borrow(this), n_press, x, y) 115 } 116 unsafe { 117 let f: Box_<F> = Box_::new(f); 118 connect_raw( 119 self.as_ptr() as *mut _, 120 b"released\0".as_ptr() as *const _, 121 Some(transmute::<_, unsafe extern "C" fn()>( 122 released_trampoline::<F> as *const (), 123 )), 124 Box_::into_raw(f), 125 ) 126 } 127 } 128 129 #[doc(alias = "stopped")] connect_stopped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId130 pub fn connect_stopped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 131 unsafe extern "C" fn stopped_trampoline<F: Fn(&GestureMultiPress) + 'static>( 132 this: *mut ffi::GtkGestureMultiPress, 133 f: glib::ffi::gpointer, 134 ) { 135 let f: &F = &*(f as *const F); 136 f(&from_glib_borrow(this)) 137 } 138 unsafe { 139 let f: Box_<F> = Box_::new(f); 140 connect_raw( 141 self.as_ptr() as *mut _, 142 b"stopped\0".as_ptr() as *const _, 143 Some(transmute::<_, unsafe extern "C" fn()>( 144 stopped_trampoline::<F> as *const (), 145 )), 146 Box_::into_raw(f), 147 ) 148 } 149 } 150 } 151 152 #[derive(Clone, Default)] 153 // rustdoc-stripper-ignore-next 154 /// A [builder-pattern] type to construct [`GestureMultiPress`] objects. 155 /// 156 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 157 pub struct GestureMultiPressBuilder { 158 button: Option<u32>, 159 exclusive: Option<bool>, 160 touch_only: Option<bool>, 161 n_points: Option<u32>, 162 window: Option<gdk::Window>, 163 propagation_phase: Option<PropagationPhase>, 164 widget: Option<Widget>, 165 } 166 167 impl GestureMultiPressBuilder { 168 // rustdoc-stripper-ignore-next 169 /// Create a new [`GestureMultiPressBuilder`]. new() -> Self170 pub fn new() -> Self { 171 Self::default() 172 } 173 174 // rustdoc-stripper-ignore-next 175 /// Build the [`GestureMultiPress`]. build(self) -> GestureMultiPress176 pub fn build(self) -> GestureMultiPress { 177 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 178 if let Some(ref button) = self.button { 179 properties.push(("button", button)); 180 } 181 if let Some(ref exclusive) = self.exclusive { 182 properties.push(("exclusive", exclusive)); 183 } 184 if let Some(ref touch_only) = self.touch_only { 185 properties.push(("touch-only", touch_only)); 186 } 187 if let Some(ref n_points) = self.n_points { 188 properties.push(("n-points", n_points)); 189 } 190 if let Some(ref window) = self.window { 191 properties.push(("window", window)); 192 } 193 if let Some(ref propagation_phase) = self.propagation_phase { 194 properties.push(("propagation-phase", propagation_phase)); 195 } 196 if let Some(ref widget) = self.widget { 197 properties.push(("widget", widget)); 198 } 199 glib::Object::new::<GestureMultiPress>(&properties) 200 .expect("Failed to create an instance of GestureMultiPress") 201 } 202 button(mut self, button: u32) -> Self203 pub fn button(mut self, button: u32) -> Self { 204 self.button = Some(button); 205 self 206 } 207 exclusive(mut self, exclusive: bool) -> Self208 pub fn exclusive(mut self, exclusive: bool) -> Self { 209 self.exclusive = Some(exclusive); 210 self 211 } 212 touch_only(mut self, touch_only: bool) -> Self213 pub fn touch_only(mut self, touch_only: bool) -> Self { 214 self.touch_only = Some(touch_only); 215 self 216 } 217 n_points(mut self, n_points: u32) -> Self218 pub fn n_points(mut self, n_points: u32) -> Self { 219 self.n_points = Some(n_points); 220 self 221 } 222 window(mut self, window: &gdk::Window) -> Self223 pub fn window(mut self, window: &gdk::Window) -> Self { 224 self.window = Some(window.clone()); 225 self 226 } 227 propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self228 pub fn propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self { 229 self.propagation_phase = Some(propagation_phase); 230 self 231 } 232 widget<P: IsA<Widget>>(mut self, widget: &P) -> Self233 pub fn widget<P: IsA<Widget>>(mut self, widget: &P) -> Self { 234 self.widget = Some(widget.clone().upcast()); 235 self 236 } 237 } 238 239 impl fmt::Display for GestureMultiPress { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result240 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 241 f.write_str("GestureMultiPress") 242 } 243 } 244