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 glib::object::Cast; 6 use glib::object::IsA; 7 use glib::signal::connect_raw; 8 use glib::signal::SignalHandlerId; 9 use glib::translate::*; 10 use glib_sys; 11 use gtk_sys; 12 use std::boxed::Box as Box_; 13 use std::fmt; 14 use std::mem::transmute; 15 use Orientation; 16 17 glib_wrapper! { 18 pub struct Orientable(Interface<gtk_sys::GtkOrientable>); 19 20 match fn { 21 get_type => || gtk_sys::gtk_orientable_get_type(), 22 } 23 } 24 25 pub const NONE_ORIENTABLE: Option<&Orientable> = None; 26 27 pub trait OrientableExt: 'static { get_orientation(&self) -> Orientation28 fn get_orientation(&self) -> Orientation; 29 set_orientation(&self, orientation: Orientation)30 fn set_orientation(&self, orientation: Orientation); 31 connect_property_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId32 fn connect_property_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 33 } 34 35 impl<O: IsA<Orientable>> OrientableExt for O { get_orientation(&self) -> Orientation36 fn get_orientation(&self) -> Orientation { 37 unsafe { 38 from_glib(gtk_sys::gtk_orientable_get_orientation( 39 self.as_ref().to_glib_none().0, 40 )) 41 } 42 } 43 set_orientation(&self, orientation: Orientation)44 fn set_orientation(&self, orientation: Orientation) { 45 unsafe { 46 gtk_sys::gtk_orientable_set_orientation( 47 self.as_ref().to_glib_none().0, 48 orientation.to_glib(), 49 ); 50 } 51 } 52 connect_property_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId53 fn connect_property_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 54 unsafe extern "C" fn notify_orientation_trampoline<P, F: Fn(&P) + 'static>( 55 this: *mut gtk_sys::GtkOrientable, 56 _param_spec: glib_sys::gpointer, 57 f: glib_sys::gpointer, 58 ) where 59 P: IsA<Orientable>, 60 { 61 let f: &F = &*(f as *const F); 62 f(&Orientable::from_glib_borrow(this).unsafe_cast()) 63 } 64 unsafe { 65 let f: Box_<F> = Box_::new(f); 66 connect_raw( 67 self.as_ptr() as *mut _, 68 b"notify::orientation\0".as_ptr() as *const _, 69 Some(transmute(notify_orientation_trampoline::<Self, F> as usize)), 70 Box_::into_raw(f), 71 ) 72 } 73 } 74 } 75 76 impl fmt::Display for Orientable { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result77 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 78 write!(f, "Orientable") 79 } 80 } 81