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_sys; 15 use gtk_sys; 16 use libc; 17 use std::boxed::Box as Box_; 18 use std::fmt; 19 use std::mem::transmute; 20 use EventController; 21 use Gesture; 22 use GestureDrag; 23 use GestureSingle; 24 use Orientation; 25 use PanDirection; 26 use PropagationPhase; 27 use Widget; 28 29 glib_wrapper! { 30 pub struct GesturePan(Object<gtk_sys::GtkGesturePan, gtk_sys::GtkGesturePanClass, GesturePanClass>) @extends GestureDrag, GestureSingle, Gesture, EventController; 31 32 match fn { 33 get_type => || gtk_sys::gtk_gesture_pan_get_type(), 34 } 35 } 36 37 impl GesturePan { new<P: IsA<Widget>>(widget: &P, orientation: Orientation) -> GesturePan38 pub fn new<P: IsA<Widget>>(widget: &P, orientation: Orientation) -> GesturePan { 39 skip_assert_initialized!(); 40 unsafe { 41 Gesture::from_glib_full(gtk_sys::gtk_gesture_pan_new( 42 widget.as_ref().to_glib_none().0, 43 orientation.to_glib(), 44 )) 45 .unsafe_cast() 46 } 47 } 48 get_orientation(&self) -> Orientation49 pub fn get_orientation(&self) -> Orientation { 50 unsafe { 51 from_glib(gtk_sys::gtk_gesture_pan_get_orientation( 52 self.to_glib_none().0, 53 )) 54 } 55 } 56 set_orientation(&self, orientation: Orientation)57 pub fn set_orientation(&self, orientation: Orientation) { 58 unsafe { 59 gtk_sys::gtk_gesture_pan_set_orientation(self.to_glib_none().0, orientation.to_glib()); 60 } 61 } 62 connect_pan<F: Fn(&GesturePan, PanDirection, f64) + 'static>( &self, f: F, ) -> SignalHandlerId63 pub fn connect_pan<F: Fn(&GesturePan, PanDirection, f64) + 'static>( 64 &self, 65 f: F, 66 ) -> SignalHandlerId { 67 unsafe extern "C" fn pan_trampoline<F: Fn(&GesturePan, PanDirection, f64) + 'static>( 68 this: *mut gtk_sys::GtkGesturePan, 69 direction: gtk_sys::GtkPanDirection, 70 offset: libc::c_double, 71 f: glib_sys::gpointer, 72 ) { 73 let f: &F = &*(f as *const F); 74 f(&from_glib_borrow(this), from_glib(direction), offset) 75 } 76 unsafe { 77 let f: Box_<F> = Box_::new(f); 78 connect_raw( 79 self.as_ptr() as *mut _, 80 b"pan\0".as_ptr() as *const _, 81 Some(transmute(pan_trampoline::<F> as usize)), 82 Box_::into_raw(f), 83 ) 84 } 85 } 86 connect_property_orientation_notify<F: Fn(&GesturePan) + 'static>( &self, f: F, ) -> SignalHandlerId87 pub fn connect_property_orientation_notify<F: Fn(&GesturePan) + 'static>( 88 &self, 89 f: F, 90 ) -> SignalHandlerId { 91 unsafe extern "C" fn notify_orientation_trampoline<F: Fn(&GesturePan) + 'static>( 92 this: *mut gtk_sys::GtkGesturePan, 93 _param_spec: glib_sys::gpointer, 94 f: glib_sys::gpointer, 95 ) { 96 let f: &F = &*(f as *const F); 97 f(&from_glib_borrow(this)) 98 } 99 unsafe { 100 let f: Box_<F> = Box_::new(f); 101 connect_raw( 102 self.as_ptr() as *mut _, 103 b"notify::orientation\0".as_ptr() as *const _, 104 Some(transmute(notify_orientation_trampoline::<F> as usize)), 105 Box_::into_raw(f), 106 ) 107 } 108 } 109 } 110 111 #[derive(Clone, Default)] 112 pub struct GesturePanBuilder { 113 orientation: Option<Orientation>, 114 button: Option<u32>, 115 exclusive: Option<bool>, 116 touch_only: Option<bool>, 117 n_points: Option<u32>, 118 window: Option<gdk::Window>, 119 propagation_phase: Option<PropagationPhase>, 120 widget: Option<Widget>, 121 } 122 123 impl GesturePanBuilder { new() -> Self124 pub fn new() -> Self { 125 Self::default() 126 } 127 build(self) -> GesturePan128 pub fn build(self) -> GesturePan { 129 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 130 if let Some(ref orientation) = self.orientation { 131 properties.push(("orientation", orientation)); 132 } 133 if let Some(ref button) = self.button { 134 properties.push(("button", button)); 135 } 136 if let Some(ref exclusive) = self.exclusive { 137 properties.push(("exclusive", exclusive)); 138 } 139 if let Some(ref touch_only) = self.touch_only { 140 properties.push(("touch-only", touch_only)); 141 } 142 if let Some(ref n_points) = self.n_points { 143 properties.push(("n-points", n_points)); 144 } 145 if let Some(ref window) = self.window { 146 properties.push(("window", window)); 147 } 148 if let Some(ref propagation_phase) = self.propagation_phase { 149 properties.push(("propagation-phase", propagation_phase)); 150 } 151 if let Some(ref widget) = self.widget { 152 properties.push(("widget", widget)); 153 } 154 glib::Object::new(GesturePan::static_type(), &properties) 155 .expect("object new") 156 .downcast() 157 .expect("downcast") 158 } 159 orientation(mut self, orientation: Orientation) -> Self160 pub fn orientation(mut self, orientation: Orientation) -> Self { 161 self.orientation = Some(orientation); 162 self 163 } 164 button(mut self, button: u32) -> Self165 pub fn button(mut self, button: u32) -> Self { 166 self.button = Some(button); 167 self 168 } 169 exclusive(mut self, exclusive: bool) -> Self170 pub fn exclusive(mut self, exclusive: bool) -> Self { 171 self.exclusive = Some(exclusive); 172 self 173 } 174 touch_only(mut self, touch_only: bool) -> Self175 pub fn touch_only(mut self, touch_only: bool) -> Self { 176 self.touch_only = Some(touch_only); 177 self 178 } 179 n_points(mut self, n_points: u32) -> Self180 pub fn n_points(mut self, n_points: u32) -> Self { 181 self.n_points = Some(n_points); 182 self 183 } 184 window<P: IsA<gdk::Window>>(mut self, window: &P) -> Self185 pub fn window<P: IsA<gdk::Window>>(mut self, window: &P) -> Self { 186 self.window = Some(window.clone().upcast()); 187 self 188 } 189 propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self190 pub fn propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self { 191 self.propagation_phase = Some(propagation_phase); 192 self 193 } 194 widget<P: IsA<Widget>>(mut self, widget: &P) -> Self195 pub fn widget<P: IsA<Widget>>(mut self, widget: &P) -> Self { 196 self.widget = Some(widget.clone().upcast()); 197 self 198 } 199 } 200 201 impl fmt::Display for GesturePan { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result202 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 203 write!(f, "GesturePan") 204 } 205 } 206