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::EventControllerScrollFlags; 7 use crate::Widget; 8 use glib::object::Cast; 9 use glib::object::IsA; 10 use glib::object::ObjectType as ObjectType_; 11 use glib::signal::connect_raw; 12 use glib::signal::SignalHandlerId; 13 use glib::translate::*; 14 use std::boxed::Box as Box_; 15 use std::fmt; 16 use std::mem::transmute; 17 18 glib::wrapper! { 19 #[doc(alias = "GtkEventControllerScroll")] 20 pub struct EventControllerScroll(Object<ffi::GtkEventControllerScroll, ffi::GtkEventControllerScrollClass>) @extends EventController; 21 22 match fn { 23 type_ => || ffi::gtk_event_controller_scroll_get_type(), 24 } 25 } 26 27 impl EventControllerScroll { 28 #[doc(alias = "gtk_event_controller_scroll_new")] new<P: IsA<Widget>>( widget: &P, flags: EventControllerScrollFlags, ) -> EventControllerScroll29 pub fn new<P: IsA<Widget>>( 30 widget: &P, 31 flags: EventControllerScrollFlags, 32 ) -> EventControllerScroll { 33 skip_assert_initialized!(); 34 unsafe { 35 EventController::from_glib_full(ffi::gtk_event_controller_scroll_new( 36 widget.as_ref().to_glib_none().0, 37 flags.into_glib(), 38 )) 39 .unsafe_cast() 40 } 41 } 42 43 #[doc(alias = "gtk_event_controller_scroll_get_flags")] 44 #[doc(alias = "get_flags")] flags(&self) -> EventControllerScrollFlags45 pub fn flags(&self) -> EventControllerScrollFlags { 46 unsafe { 47 from_glib(ffi::gtk_event_controller_scroll_get_flags( 48 self.to_glib_none().0, 49 )) 50 } 51 } 52 53 #[doc(alias = "gtk_event_controller_scroll_set_flags")] set_flags(&self, flags: EventControllerScrollFlags)54 pub fn set_flags(&self, flags: EventControllerScrollFlags) { 55 unsafe { 56 ffi::gtk_event_controller_scroll_set_flags(self.to_glib_none().0, flags.into_glib()); 57 } 58 } 59 60 #[doc(alias = "decelerate")] connect_decelerate<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId61 pub fn connect_decelerate<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId { 62 unsafe extern "C" fn decelerate_trampoline< 63 F: Fn(&EventControllerScroll, f64, f64) + 'static, 64 >( 65 this: *mut ffi::GtkEventControllerScroll, 66 vel_x: libc::c_double, 67 vel_y: libc::c_double, 68 f: glib::ffi::gpointer, 69 ) { 70 let f: &F = &*(f as *const F); 71 f(&from_glib_borrow(this), vel_x, vel_y) 72 } 73 unsafe { 74 let f: Box_<F> = Box_::new(f); 75 connect_raw( 76 self.as_ptr() as *mut _, 77 b"decelerate\0".as_ptr() as *const _, 78 Some(transmute::<_, unsafe extern "C" fn()>( 79 decelerate_trampoline::<F> as *const (), 80 )), 81 Box_::into_raw(f), 82 ) 83 } 84 } 85 86 #[doc(alias = "scroll")] connect_scroll<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId87 pub fn connect_scroll<F: Fn(&Self, f64, f64) + 'static>(&self, f: F) -> SignalHandlerId { 88 unsafe extern "C" fn scroll_trampoline< 89 F: Fn(&EventControllerScroll, f64, f64) + 'static, 90 >( 91 this: *mut ffi::GtkEventControllerScroll, 92 dx: libc::c_double, 93 dy: libc::c_double, 94 f: glib::ffi::gpointer, 95 ) { 96 let f: &F = &*(f as *const F); 97 f(&from_glib_borrow(this), dx, dy) 98 } 99 unsafe { 100 let f: Box_<F> = Box_::new(f); 101 connect_raw( 102 self.as_ptr() as *mut _, 103 b"scroll\0".as_ptr() as *const _, 104 Some(transmute::<_, unsafe extern "C" fn()>( 105 scroll_trampoline::<F> as *const (), 106 )), 107 Box_::into_raw(f), 108 ) 109 } 110 } 111 112 #[doc(alias = "scroll-begin")] connect_scroll_begin<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId113 pub fn connect_scroll_begin<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 114 unsafe extern "C" fn scroll_begin_trampoline<F: Fn(&EventControllerScroll) + 'static>( 115 this: *mut ffi::GtkEventControllerScroll, 116 f: glib::ffi::gpointer, 117 ) { 118 let f: &F = &*(f as *const F); 119 f(&from_glib_borrow(this)) 120 } 121 unsafe { 122 let f: Box_<F> = Box_::new(f); 123 connect_raw( 124 self.as_ptr() as *mut _, 125 b"scroll-begin\0".as_ptr() as *const _, 126 Some(transmute::<_, unsafe extern "C" fn()>( 127 scroll_begin_trampoline::<F> as *const (), 128 )), 129 Box_::into_raw(f), 130 ) 131 } 132 } 133 134 #[doc(alias = "scroll-end")] connect_scroll_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId135 pub fn connect_scroll_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 136 unsafe extern "C" fn scroll_end_trampoline<F: Fn(&EventControllerScroll) + 'static>( 137 this: *mut ffi::GtkEventControllerScroll, 138 f: glib::ffi::gpointer, 139 ) { 140 let f: &F = &*(f as *const F); 141 f(&from_glib_borrow(this)) 142 } 143 unsafe { 144 let f: Box_<F> = Box_::new(f); 145 connect_raw( 146 self.as_ptr() as *mut _, 147 b"scroll-end\0".as_ptr() as *const _, 148 Some(transmute::<_, unsafe extern "C" fn()>( 149 scroll_end_trampoline::<F> as *const (), 150 )), 151 Box_::into_raw(f), 152 ) 153 } 154 } 155 156 #[cfg(any(feature = "v3_24", feature = "dox"))] 157 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_24")))] 158 #[doc(alias = "flags")] connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId159 pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 160 unsafe extern "C" fn notify_flags_trampoline<F: Fn(&EventControllerScroll) + 'static>( 161 this: *mut ffi::GtkEventControllerScroll, 162 _param_spec: glib::ffi::gpointer, 163 f: glib::ffi::gpointer, 164 ) { 165 let f: &F = &*(f as *const F); 166 f(&from_glib_borrow(this)) 167 } 168 unsafe { 169 let f: Box_<F> = Box_::new(f); 170 connect_raw( 171 self.as_ptr() as *mut _, 172 b"notify::flags\0".as_ptr() as *const _, 173 Some(transmute::<_, unsafe extern "C" fn()>( 174 notify_flags_trampoline::<F> as *const (), 175 )), 176 Box_::into_raw(f), 177 ) 178 } 179 } 180 } 181 182 impl fmt::Display for EventControllerScroll { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result183 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 184 f.write_str("EventControllerScroll") 185 } 186 } 187