Skip to main content

gtk/auto/
orientable.rs

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
5use crate::{Orientation, ffi};
6use glib::{
7    prelude::*,
8    signal::{SignalHandlerId, connect_raw},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// The [`Orientable`][crate::Orientable] interface is implemented by all widgets that can be
15    /// oriented horizontally or vertically. Historically, such widgets have been
16    /// realized as subclasses of a common base class (e.g [`Box`][crate::Box]/`GtkHBox`/`GtkVBox`
17    /// or [`Scale`][crate::Scale]/`GtkHScale`/`GtkVScale`). [`Orientable`][crate::Orientable] is more flexible in that
18    /// it allows the orientation to be changed at runtime, allowing the widgets
19    /// to “flip”.
20    ///
21    /// [`Orientable`][crate::Orientable] was introduced in GTK+ 2.16.
22    ///
23    /// ## Properties
24    ///
25    ///
26    /// #### `orientation`
27    ///  The orientation of the orientable.
28    ///
29    /// Readable | Writable
30    ///
31    /// # Implements
32    ///
33    /// [`OrientableExt`][trait@crate::prelude::OrientableExt]
34    #[doc(alias = "GtkOrientable")]
35    pub struct Orientable(Interface<ffi::GtkOrientable, ffi::GtkOrientableIface>);
36
37    match fn {
38        type_ => || ffi::gtk_orientable_get_type(),
39    }
40}
41
42impl Orientable {
43    pub const NONE: Option<&'static Orientable> = None;
44}
45
46/// Trait containing all [`struct@Orientable`] methods.
47///
48/// # Implementors
49///
50/// [`AppChooserWidget`][struct@crate::AppChooserWidget], [`Box`][struct@crate::Box], [`ButtonBox`][struct@crate::ButtonBox], [`CellAreaBox`][struct@crate::CellAreaBox], [`CellRendererProgress`][struct@crate::CellRendererProgress], [`CellView`][struct@crate::CellView], [`ColorChooserWidget`][struct@crate::ColorChooserWidget], [`FileChooserButton`][struct@crate::FileChooserButton], [`FileChooserWidget`][struct@crate::FileChooserWidget], [`FlowBox`][struct@crate::FlowBox], [`FontChooserWidget`][struct@crate::FontChooserWidget], [`Grid`][struct@crate::Grid], [`InfoBar`][struct@crate::InfoBar], [`LevelBar`][struct@crate::LevelBar], [`Orientable`][struct@crate::Orientable], [`Paned`][struct@crate::Paned], [`ProgressBar`][struct@crate::ProgressBar], [`Range`][struct@crate::Range], [`RecentChooserWidget`][struct@crate::RecentChooserWidget], [`ScaleButton`][struct@crate::ScaleButton], [`Scale`][struct@crate::Scale], [`Scrollbar`][struct@crate::Scrollbar], [`Separator`][struct@crate::Separator], [`ShortcutLabel`][struct@crate::ShortcutLabel], [`ShortcutsGroup`][struct@crate::ShortcutsGroup], [`ShortcutsSection`][struct@crate::ShortcutsSection], [`ShortcutsShortcut`][struct@crate::ShortcutsShortcut], [`SpinButton`][struct@crate::SpinButton], [`StackSwitcher`][struct@crate::StackSwitcher], [`Statusbar`][struct@crate::Statusbar], [`ToolPalette`][struct@crate::ToolPalette], [`Toolbar`][struct@crate::Toolbar], [`VolumeButton`][struct@crate::VolumeButton]
51pub trait OrientableExt: IsA<Orientable> + 'static {
52    /// Retrieves the orientation of the `self`.
53    ///
54    /// # Returns
55    ///
56    /// the orientation of the `self`.
57    #[doc(alias = "gtk_orientable_get_orientation")]
58    #[doc(alias = "get_orientation")]
59    fn orientation(&self) -> Orientation {
60        unsafe {
61            from_glib(ffi::gtk_orientable_get_orientation(
62                self.as_ref().to_glib_none().0,
63            ))
64        }
65    }
66
67    /// Sets the orientation of the `self`.
68    /// ## `orientation`
69    /// the orientable’s new orientation.
70    #[doc(alias = "gtk_orientable_set_orientation")]
71    #[doc(alias = "orientation")]
72    fn set_orientation(&self, orientation: Orientation) {
73        unsafe {
74            ffi::gtk_orientable_set_orientation(
75                self.as_ref().to_glib_none().0,
76                orientation.into_glib(),
77            );
78        }
79    }
80
81    #[doc(alias = "orientation")]
82    fn connect_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
83        unsafe extern "C" fn notify_orientation_trampoline<
84            P: IsA<Orientable>,
85            F: Fn(&P) + 'static,
86        >(
87            this: *mut ffi::GtkOrientable,
88            _param_spec: glib::ffi::gpointer,
89            f: glib::ffi::gpointer,
90        ) {
91            unsafe {
92                let f: &F = &*(f as *const F);
93                f(Orientable::from_glib_borrow(this).unsafe_cast_ref())
94            }
95        }
96        unsafe {
97            let f: Box_<F> = Box_::new(f);
98            connect_raw(
99                self.as_ptr() as *mut _,
100                c"notify::orientation".as_ptr(),
101                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
102                    notify_orientation_trampoline::<Self, F> as *const (),
103                )),
104                Box_::into_raw(f),
105            )
106        }
107    }
108}
109
110impl<O: IsA<Orientable>> OrientableExt for O {}