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::PropagationPhase; 8 use crate::Widget; 9 use glib::object::Cast; 10 use glib::object::IsA; 11 use glib::object::ObjectType as ObjectType_; 12 use glib::signal::connect_raw; 13 use glib::signal::SignalHandlerId; 14 use glib::translate::*; 15 use glib::StaticType; 16 use glib::ToValue; 17 use std::boxed::Box as Box_; 18 use std::fmt; 19 use std::mem::transmute; 20 21 glib::wrapper! { 22 #[doc(alias = "GtkGestureZoom")] 23 pub struct GestureZoom(Object<ffi::GtkGestureZoom, ffi::GtkGestureZoomClass>) @extends Gesture, EventController; 24 25 match fn { 26 type_ => || ffi::gtk_gesture_zoom_get_type(), 27 } 28 } 29 30 impl GestureZoom { 31 #[doc(alias = "gtk_gesture_zoom_new")] new<P: IsA<Widget>>(widget: &P) -> GestureZoom32 pub fn new<P: IsA<Widget>>(widget: &P) -> GestureZoom { 33 skip_assert_initialized!(); 34 unsafe { 35 Gesture::from_glib_full(ffi::gtk_gesture_zoom_new(widget.as_ref().to_glib_none().0)) 36 .unsafe_cast() 37 } 38 } 39 40 // rustdoc-stripper-ignore-next 41 /// Creates a new builder-pattern struct instance to construct [`GestureZoom`] objects. 42 /// 43 /// This method returns an instance of [`GestureZoomBuilder`] which can be used to create [`GestureZoom`] objects. builder() -> GestureZoomBuilder44 pub fn builder() -> GestureZoomBuilder { 45 GestureZoomBuilder::default() 46 } 47 48 #[doc(alias = "gtk_gesture_zoom_get_scale_delta")] 49 #[doc(alias = "get_scale_delta")] scale_delta(&self) -> f6450 pub fn scale_delta(&self) -> f64 { 51 unsafe { ffi::gtk_gesture_zoom_get_scale_delta(self.to_glib_none().0) } 52 } 53 54 #[doc(alias = "scale-changed")] connect_scale_changed<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId55 pub fn connect_scale_changed<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId { 56 unsafe extern "C" fn scale_changed_trampoline<F: Fn(&GestureZoom, f64) + 'static>( 57 this: *mut ffi::GtkGestureZoom, 58 scale: libc::c_double, 59 f: glib::ffi::gpointer, 60 ) { 61 let f: &F = &*(f as *const F); 62 f(&from_glib_borrow(this), scale) 63 } 64 unsafe { 65 let f: Box_<F> = Box_::new(f); 66 connect_raw( 67 self.as_ptr() as *mut _, 68 b"scale-changed\0".as_ptr() as *const _, 69 Some(transmute::<_, unsafe extern "C" fn()>( 70 scale_changed_trampoline::<F> as *const (), 71 )), 72 Box_::into_raw(f), 73 ) 74 } 75 } 76 } 77 78 #[derive(Clone, Default)] 79 // rustdoc-stripper-ignore-next 80 /// A [builder-pattern] type to construct [`GestureZoom`] objects. 81 /// 82 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 83 pub struct GestureZoomBuilder { 84 n_points: Option<u32>, 85 window: Option<gdk::Window>, 86 propagation_phase: Option<PropagationPhase>, 87 widget: Option<Widget>, 88 } 89 90 impl GestureZoomBuilder { 91 // rustdoc-stripper-ignore-next 92 /// Create a new [`GestureZoomBuilder`]. new() -> Self93 pub fn new() -> Self { 94 Self::default() 95 } 96 97 // rustdoc-stripper-ignore-next 98 /// Build the [`GestureZoom`]. build(self) -> GestureZoom99 pub fn build(self) -> GestureZoom { 100 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 101 if let Some(ref n_points) = self.n_points { 102 properties.push(("n-points", n_points)); 103 } 104 if let Some(ref window) = self.window { 105 properties.push(("window", window)); 106 } 107 if let Some(ref propagation_phase) = self.propagation_phase { 108 properties.push(("propagation-phase", propagation_phase)); 109 } 110 if let Some(ref widget) = self.widget { 111 properties.push(("widget", widget)); 112 } 113 glib::Object::new::<GestureZoom>(&properties) 114 .expect("Failed to create an instance of GestureZoom") 115 } 116 n_points(mut self, n_points: u32) -> Self117 pub fn n_points(mut self, n_points: u32) -> Self { 118 self.n_points = Some(n_points); 119 self 120 } 121 window(mut self, window: &gdk::Window) -> Self122 pub fn window(mut self, window: &gdk::Window) -> Self { 123 self.window = Some(window.clone()); 124 self 125 } 126 propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self127 pub fn propagation_phase(mut self, propagation_phase: PropagationPhase) -> Self { 128 self.propagation_phase = Some(propagation_phase); 129 self 130 } 131 widget<P: IsA<Widget>>(mut self, widget: &P) -> Self132 pub fn widget<P: IsA<Widget>>(mut self, widget: &P) -> Self { 133 self.widget = Some(widget.clone().upcast()); 134 self 135 } 136 } 137 138 impl fmt::Display for GestureZoom { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result139 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 140 f.write_str("GestureZoom") 141 } 142 } 143