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 gdk; 6 use glib::object::Cast; 7 use glib::object::IsA; 8 use glib::object::ObjectType as ObjectType_; 9 use glib::signal::connect_raw; 10 use glib::signal::SignalHandlerId; 11 use glib::translate::*; 12 use glib::StaticType; 13 use glib::ToValue; 14 use glib::Value; 15 use glib_sys; 16 use gobject_sys; 17 use gtk_sys; 18 use libc; 19 use std::boxed::Box as Box_; 20 use std::fmt; 21 use std::mem::transmute; 22 use EventController; 23 use Gesture; 24 use GestureSingle; 25 use PropagationPhase; 26 use Widget; 27 28 glib_wrapper! { 29 pub struct GestureLongPress(Object<gtk_sys::GtkGestureLongPress, gtk_sys::GtkGestureLongPressClass, GestureLongPressClass>) @extends GestureSingle, Gesture, EventController; 30 31 match fn { 32 get_type => || gtk_sys::gtk_gesture_long_press_get_type(), 33 } 34 } 35 36 impl GestureLongPress { new<P: IsA<Widget>>(widget: &P) -> GestureLongPress37 pub fn new<P: IsA<Widget>>(widget: &P) -> GestureLongPress { 38 skip_assert_initialized!(); 39 unsafe { 40 Gesture::from_glib_full(gtk_sys::gtk_gesture_long_press_new( 41 widget.as_ref().to_glib_none().0, 42 )) 43 .unsafe_cast() 44 } 45 } 46 get_property_delay_factor(&self) -> f6447 pub fn get_property_delay_factor(&self) -> f64 { 48 unsafe { 49 let mut value = Value::from_type(<f64 as StaticType>::static_type()); 50 gobject_sys::g_object_get_property( 51 self.as_ptr() as *mut gobject_sys::GObject, 52 b"delay-factor\0".as_ptr() as *const _, 53 value.to_glib_none_mut().0, 54 ); 55 value 56 .get() 57 .expect("Return Value for property `delay-factor` getter") 58 .unwrap() 59 } 60 } 61 set_property_delay_factor(&self, delay_factor: f64)62 pub fn set_property_delay_factor(&self, delay_factor: f64) { 63 unsafe { 64 gobject_sys::g_object_set_property( 65 self.as_ptr() as *mut gobject_sys::GObject, 66 b"delay-factor\0".as_ptr() as *const _, 67 Value::from(&delay_factor).to_glib_none().0, 68 ); 69 } 70 } 71 connect_cancelled<F: Fn(&GestureLongPress) + 'static>(&self, f: F) -> SignalHandlerId72 pub fn connect_cancelled<F: Fn(&GestureLongPress) + 'static>(&self, f: F) -> SignalHandlerId { 73 unsafe extern "C" fn cancelled_trampoline<F: Fn(&GestureLongPress) + 'static>( 74 this: *mut gtk_sys::GtkGestureLongPress, 75 f: glib_sys::gpointer, 76 ) { 77 let f: &F = &*(f as *const F); 78 f(&from_glib_borrow(this)) 79 } 80 unsafe { 81 let f: Box_<F> = Box_::new(f); 82 connect_raw( 83 self.as_ptr() as *mut _, 84 b"cancelled\0".as_ptr() as *const _, 85 Some(transmute(cancelled_trampoline::<F> as usize)), 86 Box_::into_raw(f), 87 ) 88 } 89 } 90 connect_pressed<F: Fn(&GestureLongPress, f64, f64) + 'static>( &self, f: F, ) -> SignalHandlerId91 pub fn connect_pressed<F: Fn(&GestureLongPress, f64, f64) + 'static>( 92 &self, 93 f: F, 94 ) -> SignalHandlerId { 95 unsafe extern "C" fn pressed_trampoline<F: Fn(&GestureLongPress, f64, f64) + 'static>( 96 this: *mut gtk_sys::GtkGestureLongPress, 97 x: libc::c_double, 98 y: libc::c_double, 99 f: glib_sys::gpointer, 100 ) { 101 let f: &F = &*(f as *const F); 102 f(&from_glib_borrow(this), x, y) 103 } 104 unsafe { 105 let f: Box_<F> = Box_::new(f); 106 connect_raw( 107 self.as_ptr() as *mut _, 108 b"pressed\0".as_ptr() as *const _, 109 Some(transmute(pressed_trampoline::<F> as usize)), 110 Box_::into_raw(f), 111 ) 112 } 113 } 114 connect_property_delay_factor_notify<F: Fn(&GestureLongPress) + 'static>( &self, f: F, ) -> SignalHandlerId115 pub fn connect_property_delay_factor_notify<F: Fn(&GestureLongPress) + 'static>( 116 &self, 117 f: F, 118 ) -> SignalHandlerId { 119 unsafe extern "C" fn notify_delay_factor_trampoline<F: Fn(&GestureLongPress) + 'static>( 120 this: *mut gtk_sys::GtkGestureLongPress, 121 _param_spec: glib_sys::gpointer, 122 f: glib_sys::gpointer, 123 ) { 124 let f: &F = &*(f as *const F); 125 f(&from_glib_borrow(this)) 126 } 127 unsafe { 128 let f: Box_<F> = Box_::new(f); 129 connect_raw( 130 self.as_ptr() as *mut _, 131 b"notify::delay-factor\0".as_ptr() as *const _, 132 Some(transmute(notify_delay_factor_trampoline::<F> as usize)), 133 Box_::into_raw(f), 134 ) 135 } 136 } 137 } 138 139 #[derive(Clone, Default)] 140 pub struct GestureLongPressBuilder { 141 delay_factor: Option<f64>, 142 button: Option<u32>, 143 exclusive: Option<bool>, 144 touch_only: Option<bool>, 145 n_points: Option<u32>, 146 window: Option<gdk::Window>, 147 propagation_phase: Option<PropagationPhase>, 148 widget: Option<Widget>, 149 } 150 151 impl GestureLongPressBuilder { new() -> Self152 pub fn new() -> Self { 153 Self::default() 154 } 155 build(self) -> GestureLongPress156 pub fn build(self) -> GestureLongPress { 157 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 158 if let Some(ref delay_factor) = self.delay_factor { 159 properties.push(("delay-factor", delay_factor)); 160 } 161 if let Some(ref button) = self.button { 162 properties.push(("button", button)); 163 } 164 if let Some(ref exclusive) = self.exclusive { 165 properties.push(("exclusive", exclusive)); 166 } 167 if let Some(ref touch_only) = self.touch_only { 168 properties.push(("touch-only", touch_only)); 169 } 170 if let Some(ref n_points) = self.n_points { 171 properties.push(("n-points", n_points)); 172 } 173 if let Some(ref window) = self.window { 174 properties.push(("window", window)); 175 } 176 if let Some(ref propagation_phase) = self.propagation_phase { 177 properties.push(("propagation-phase", propagation_phase)); 178 } 179 if let Some(ref widget) = self.widget { 180 properties.push(("widget", widget)); 181 } 182 glib::Object::new(GestureLongPress::static_type(), &properties) 183 .expect("object new") 184 .downcast() 185 .expect("downcast") 186 } 187 delay_factor(mut self, delay_factor: f64) -> Self188 pub fn delay_factor(mut self, delay_factor: f64) -> Self { 189 self.delay_factor = Some(delay_factor); 190 self 191 } 192 button(mut self, button: u32) -> Self193 pub fn button(mut self, button: u32) -> Self { 194 self.button = Some(button); 195 self 196 } 197 exclusive(mut self, exclusive: bool) -> Self198 pub fn exclusive(mut self, exclusive: bool) -> Self { 199 self.exclusive = Some(exclusive); 200 self 201 } 202 touch_only(mut self, touch_only: bool) -> Self203 pub fn touch_only(mut self, touch_only: bool) -> Self { 204 self.touch_only = Some(touch_only); 205 self 206 } 207 n_points(mut self, n_points: u32) -> Self208 pub fn n_points(mut self, n_points: u32) -> Self { 209 self.n_points = Some(n_points); 210 self 211 } 212 window<P: IsA<gdk::Window>>(mut self, window: &P) -> Self213 pub fn window<P: IsA<gdk::Window>>(mut self, window: &P) -> Self { 214 self.window = Some(window.clone().upcast()); 215 self 216 } 217 propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self218 pub fn propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self { 219 self.propagation_phase = Some(propagation_phase); 220 self 221 } 222 widget<P: IsA<Widget>>(mut self, widget: &P) -> Self223 pub fn widget<P: IsA<Widget>>(mut self, widget: &P) -> Self { 224 self.widget = Some(widget.clone().upcast()); 225 self 226 } 227 } 228 229 impl fmt::Display for GestureLongPress { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result230 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 231 write!(f, "GestureLongPress") 232 } 233 } 234