gtk4/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 /// .
15 ///
16 /// ## CSS nodes
17 ///
18 /// [`Widget`][crate::Widget] types implementing the [`Orientable`][crate::Orientable] interface will
19 /// automatically acquire the `horizontal` or `vertical` CSS class depending on
20 /// the value of the [`orientation`][struct@crate::Orientable#orientation] property.
21 ///
22 /// ## Properties
23 ///
24 ///
25 /// #### `orientation`
26 /// The orientation of the orientable.
27 ///
28 /// Readable | Writable
29 ///
30 /// # Implements
31 ///
32 /// [`OrientableExt`][trait@crate::prelude::OrientableExt]
33 #[doc(alias = "GtkOrientable")]
34 pub struct Orientable(Interface<ffi::GtkOrientable, ffi::GtkOrientableIface>);
35
36 match fn {
37 type_ => || ffi::gtk_orientable_get_type(),
38 }
39}
40
41impl Orientable {
42 pub const NONE: Option<&'static Orientable> = None;
43}
44
45/// Trait containing all [`struct@Orientable`] methods.
46///
47/// # Implementors
48///
49/// [`BoxLayout`][struct@crate::BoxLayout], [`Box`][struct@crate::Box], [`CellAreaBox`][struct@crate::CellAreaBox], [`CellRendererProgress`][struct@crate::CellRendererProgress], [`CellView`][struct@crate::CellView], [`CenterBox`][struct@crate::CenterBox], [`FlowBox`][struct@crate::FlowBox], [`GridView`][struct@crate::GridView], [`Grid`][struct@crate::Grid], [`LevelBar`][struct@crate::LevelBar], [`ListBase`][struct@crate::ListBase], [`ListView`][struct@crate::ListView], [`Orientable`][struct@crate::Orientable], [`Paned`][struct@crate::Paned], [`ProgressBar`][struct@crate::ProgressBar], [`Range`][struct@crate::Range], [`ScaleButton`][struct@crate::ScaleButton], [`Scale`][struct@crate::Scale], [`Scrollbar`][struct@crate::Scrollbar], [`Separator`][struct@crate::Separator], [`ShortcutsGroup`][struct@crate::ShortcutsGroup], [`ShortcutsSection`][struct@crate::ShortcutsSection], [`SpinButton`][struct@crate::SpinButton], [`StackSwitcher`][struct@crate::StackSwitcher], [`VolumeButton`][struct@crate::VolumeButton]
50pub trait OrientableExt: IsA<Orientable> + 'static {
51 /// Retrieves the orientation of the @self.
52 ///
53 /// # Returns
54 ///
55 /// the orientation of the @self
56 #[doc(alias = "gtk_orientable_get_orientation")]
57 #[doc(alias = "get_orientation")]
58 fn orientation(&self) -> Orientation {
59 unsafe {
60 from_glib(ffi::gtk_orientable_get_orientation(
61 self.as_ref().to_glib_none().0,
62 ))
63 }
64 }
65
66 /// Sets the orientation of the @self.
67 /// ## `orientation`
68 /// s new orientation
69 #[doc(alias = "gtk_orientable_set_orientation")]
70 #[doc(alias = "orientation")]
71 fn set_orientation(&self, orientation: Orientation) {
72 unsafe {
73 ffi::gtk_orientable_set_orientation(
74 self.as_ref().to_glib_none().0,
75 orientation.into_glib(),
76 );
77 }
78 }
79
80 #[doc(alias = "orientation")]
81 fn connect_orientation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
82 unsafe extern "C" fn notify_orientation_trampoline<
83 P: IsA<Orientable>,
84 F: Fn(&P) + 'static,
85 >(
86 this: *mut ffi::GtkOrientable,
87 _param_spec: glib::ffi::gpointer,
88 f: glib::ffi::gpointer,
89 ) {
90 unsafe {
91 let f: &F = &*(f as *const F);
92 f(Orientable::from_glib_borrow(this).unsafe_cast_ref())
93 }
94 }
95 unsafe {
96 let f: Box_<F> = Box_::new(f);
97 connect_raw(
98 self.as_ptr() as *mut _,
99 c"notify::orientation".as_ptr(),
100 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
101 notify_orientation_trampoline::<Self, F> as *const (),
102 )),
103 Box_::into_raw(f),
104 )
105 }
106 }
107}
108
109impl<O: IsA<Orientable>> OrientableExt for O {}