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::Orientation;
6 use glib::object::Cast;
7 use glib::object::IsA;
8 use glib::signal::connect_raw;
9 use glib::signal::SignalHandlerId;
10 use glib::translate::*;
11 use std::boxed::Box as Box_;
12 use std::fmt;
13 use std::mem::transmute;
14 
15 glib::wrapper! {
16     #[doc(alias = "GtkOrientable")]
17     pub struct Orientable(Interface<ffi::GtkOrientable, ffi::GtkOrientableIface>);
18 
19     match fn {
20         type_ => || ffi::gtk_orientable_get_type(),
21     }
22 }
23 
24 pub const NONE_ORIENTABLE: Option<&Orientable> = None;
25 
26 pub trait OrientableExt: 'static {
27     #[doc(alias = "gtk_orientable_get_orientation")]
28     #[doc(alias = "get_orientation")]
orientation(&self) -> Orientation29     fn orientation(&self) -> Orientation;
30 
31     #[doc(alias = "gtk_orientable_set_orientation")]
set_orientation(&self, orientation: Orientation)32     fn set_orientation(&self, orientation: Orientation);
33 
34     #[doc(alias = "orientation")]
connect_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId35     fn connect_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
36 }
37 
38 impl<O: IsA<Orientable>> OrientableExt for O {
orientation(&self) -> Orientation39     fn orientation(&self) -> Orientation {
40         unsafe {
41             from_glib(ffi::gtk_orientable_get_orientation(
42                 self.as_ref().to_glib_none().0,
43             ))
44         }
45     }
46 
set_orientation(&self, orientation: Orientation)47     fn set_orientation(&self, orientation: Orientation) {
48         unsafe {
49             ffi::gtk_orientable_set_orientation(
50                 self.as_ref().to_glib_none().0,
51                 orientation.into_glib(),
52             );
53         }
54     }
55 
connect_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId56     fn connect_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
57         unsafe extern "C" fn notify_orientation_trampoline<
58             P: IsA<Orientable>,
59             F: Fn(&P) + 'static,
60         >(
61             this: *mut ffi::GtkOrientable,
62             _param_spec: glib::ffi::gpointer,
63             f: glib::ffi::gpointer,
64         ) {
65             let f: &F = &*(f as *const F);
66             f(Orientable::from_glib_borrow(this).unsafe_cast_ref())
67         }
68         unsafe {
69             let f: Box_<F> = Box_::new(f);
70             connect_raw(
71                 self.as_ptr() as *mut _,
72                 b"notify::orientation\0".as_ptr() as *const _,
73                 Some(transmute::<_, unsafe extern "C" fn()>(
74                     notify_orientation_trampoline::<Self, F> as *const (),
75                 )),
76                 Box_::into_raw(f),
77             )
78         }
79     }
80 }
81 
82 impl fmt::Display for Orientable {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result83     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
84         f.write_str("Orientable")
85     }
86 }
87