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;
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
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 | Writeable
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
46mod sealed {
47 pub trait Sealed {}
48 impl<T: super::IsA<super::Orientable>> Sealed for T {}
49}
50
51/// Trait containing all [`struct@Orientable`] methods.
52///
53/// # Implementors
54///
55/// [`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]
56pub trait OrientableExt: IsA<Orientable> + sealed::Sealed + 'static {
57 /// Retrieves the orientation of the `self`.
58 ///
59 /// # Returns
60 ///
61 /// the orientation of the `self`.
62 #[doc(alias = "gtk_orientable_get_orientation")]
63 #[doc(alias = "get_orientation")]
64 fn orientation(&self) -> Orientation {
65 unsafe {
66 from_glib(ffi::gtk_orientable_get_orientation(
67 self.as_ref().to_glib_none().0,
68 ))
69 }
70 }
71
72 /// Sets the orientation of the `self`.
73 /// ## `orientation`
74 /// the orientable’s new orientation.
75 #[doc(alias = "gtk_orientable_set_orientation")]
76 fn set_orientation(&self, orientation: Orientation) {
77 unsafe {
78 ffi::gtk_orientable_set_orientation(
79 self.as_ref().to_glib_none().0,
80 orientation.into_glib(),
81 );
82 }
83 }
84
85 #[doc(alias = "orientation")]
86 fn connect_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
87 unsafe extern "C" fn notify_orientation_trampoline<
88 P: IsA<Orientable>,
89 F: Fn(&P) + 'static,
90 >(
91 this: *mut ffi::GtkOrientable,
92 _param_spec: glib::ffi::gpointer,
93 f: glib::ffi::gpointer,
94 ) {
95 let f: &F = &*(f as *const F);
96 f(Orientable::from_glib_borrow(this).unsafe_cast_ref())
97 }
98 unsafe {
99 let f: Box_<F> = Box_::new(f);
100 connect_raw(
101 self.as_ptr() as *mut _,
102 b"notify::orientation\0".as_ptr() as *const _,
103 Some(transmute::<_, unsafe extern "C" fn()>(
104 notify_orientation_trampoline::<Self, F> as *const (),
105 )),
106 Box_::into_raw(f),
107 )
108 }
109 }
110}
111
112impl<O: IsA<Orientable>> OrientableExt for O {}
113
114impl fmt::Display for Orientable {
115 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
116 f.write_str("Orientable")
117 }
118}