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 pub struct GesturePanBuilder { 112 orientation: Option<Orientation>, 113 button: Option<u32>, 114 exclusive: Option<bool>, 115 touch_only: Option<bool>, 116 n_points: Option<u32>, 117 window: Option<gdk::Window>, 118 propagation_phase: Option<PropagationPhase>, 119 widget: Option<Widget>, 120 } 121 122 impl GesturePanBuilder { new() -> Self123 pub fn new() -> Self { 124 Self { 125 orientation: None, 126 button: None, 127 exclusive: None, 128 touch_only: None, 129 n_points: None, 130 window: None, 131 propagation_phase: None, 132 widget: None, 133 } 134 } 135 build(self) -> GesturePan136 pub fn build(self) -> GesturePan { 137 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 138 if let Some(ref orientation) = self.orientation { 139 properties.push(("orientation", orientation)); 140 } 141 if let Some(ref button) = self.button { 142 properties.push(("button", button)); 143 } 144 if let Some(ref exclusive) = self.exclusive { 145 properties.push(("exclusive", exclusive)); 146 } 147 if let Some(ref touch_only) = self.touch_only { 148 properties.push(("touch-only", touch_only)); 149 } 150 if let Some(ref n_points) = self.n_points { 151 properties.push(("n-points", n_points)); 152 } 153 if let Some(ref window) = self.window { 154 properties.push(("window", window)); 155 } 156 if let Some(ref propagation_phase) = self.propagation_phase { 157 properties.push(("propagation-phase", propagation_phase)); 158 } 159 if let Some(ref widget) = self.widget { 160 properties.push(("widget", widget)); 161 } 162 glib::Object::new(GesturePan::static_type(), &properties) 163 .expect("object new") 164 .downcast() 165 .expect("downcast") 166 } 167 orientation(mut self, orientation: Orientation) -> Self168 pub fn orientation(mut self, orientation: Orientation) -> Self { 169 self.orientation = Some(orientation); 170 self 171 } 172 button(mut self, button: u32) -> Self173 pub fn button(mut self, button: u32) -> Self { 174 self.button = Some(button); 175 self 176 } 177 exclusive(mut self, exclusive: bool) -> Self178 pub fn exclusive(mut self, exclusive: bool) -> Self { 179 self.exclusive = Some(exclusive); 180 self 181 } 182 touch_only(mut self, touch_only: bool) -> Self183 pub fn touch_only(mut self, touch_only: bool) -> Self { 184 self.touch_only = Some(touch_only); 185 self 186 } 187 n_points(mut self, n_points: u32) -> Self188 pub fn n_points(mut self, n_points: u32) -> Self { 189 self.n_points = Some(n_points); 190 self 191 } 192 window(mut self, window: &gdk::Window) -> Self193 pub fn window(mut self, window: &gdk::Window) -> Self { 194 self.window = Some(window.clone()); 195 self 196 } 197 propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self198 pub fn propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self { 199 self.propagation_phase = Some(propagation_phase); 200 self 201 } 202 widget(mut self, widget: &Widget) -> Self203 pub fn widget(mut self, widget: &Widget) -> Self { 204 self.widget = Some(widget.clone()); 205 self 206 } 207 } 208 209 impl fmt::Display for GesturePan { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result210 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 211 write!(f, "GesturePan") 212 } 213 } 214