[go: up one dir, main page]

gtk4/auto/
center_layout.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::{ffi, BaselinePosition, LayoutManager, Orientation, Widget};
6#[cfg(feature = "v4_12")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
8use glib::signal::{connect_raw, SignalHandlerId};
9use glib::{prelude::*, translate::*};
10#[cfg(feature = "v4_12")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkCenterLayout")]
16    pub struct CenterLayout(Object<ffi::GtkCenterLayout, ffi::GtkCenterLayoutClass>) @extends LayoutManager;
17
18    match fn {
19        type_ => || ffi::gtk_center_layout_get_type(),
20    }
21}
22
23impl CenterLayout {
24    #[doc(alias = "gtk_center_layout_new")]
25    pub fn new() -> CenterLayout {
26        assert_initialized_main_thread!();
27        unsafe { LayoutManager::from_glib_full(ffi::gtk_center_layout_new()).unsafe_cast() }
28    }
29
30    #[doc(alias = "gtk_center_layout_get_baseline_position")]
31    #[doc(alias = "get_baseline_position")]
32    pub fn baseline_position(&self) -> BaselinePosition {
33        unsafe {
34            from_glib(ffi::gtk_center_layout_get_baseline_position(
35                self.to_glib_none().0,
36            ))
37        }
38    }
39
40    #[doc(alias = "gtk_center_layout_get_center_widget")]
41    #[doc(alias = "get_center_widget")]
42    pub fn center_widget(&self) -> Option<Widget> {
43        unsafe {
44            from_glib_none(ffi::gtk_center_layout_get_center_widget(
45                self.to_glib_none().0,
46            ))
47        }
48    }
49
50    #[doc(alias = "gtk_center_layout_get_end_widget")]
51    #[doc(alias = "get_end_widget")]
52    pub fn end_widget(&self) -> Option<Widget> {
53        unsafe { from_glib_none(ffi::gtk_center_layout_get_end_widget(self.to_glib_none().0)) }
54    }
55
56    #[doc(alias = "gtk_center_layout_get_orientation")]
57    #[doc(alias = "get_orientation")]
58    pub fn orientation(&self) -> Orientation {
59        unsafe {
60            from_glib(ffi::gtk_center_layout_get_orientation(
61                self.to_glib_none().0,
62            ))
63        }
64    }
65
66    #[cfg(feature = "v4_12")]
67    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
68    #[doc(alias = "gtk_center_layout_get_shrink_center_last")]
69    #[doc(alias = "get_shrink_center_last")]
70    #[doc(alias = "shrink-center-last")]
71    pub fn shrinks_center_last(&self) -> bool {
72        unsafe {
73            from_glib(ffi::gtk_center_layout_get_shrink_center_last(
74                self.to_glib_none().0,
75            ))
76        }
77    }
78
79    #[doc(alias = "gtk_center_layout_get_start_widget")]
80    #[doc(alias = "get_start_widget")]
81    pub fn start_widget(&self) -> Option<Widget> {
82        unsafe {
83            from_glib_none(ffi::gtk_center_layout_get_start_widget(
84                self.to_glib_none().0,
85            ))
86        }
87    }
88
89    #[doc(alias = "gtk_center_layout_set_baseline_position")]
90    pub fn set_baseline_position(&self, baseline_position: BaselinePosition) {
91        unsafe {
92            ffi::gtk_center_layout_set_baseline_position(
93                self.to_glib_none().0,
94                baseline_position.into_glib(),
95            );
96        }
97    }
98
99    #[doc(alias = "gtk_center_layout_set_center_widget")]
100    pub fn set_center_widget(&self, widget: Option<&impl IsA<Widget>>) {
101        unsafe {
102            ffi::gtk_center_layout_set_center_widget(
103                self.to_glib_none().0,
104                widget.map(|p| p.as_ref()).to_glib_none().0,
105            );
106        }
107    }
108
109    #[doc(alias = "gtk_center_layout_set_end_widget")]
110    pub fn set_end_widget(&self, widget: Option<&impl IsA<Widget>>) {
111        unsafe {
112            ffi::gtk_center_layout_set_end_widget(
113                self.to_glib_none().0,
114                widget.map(|p| p.as_ref()).to_glib_none().0,
115            );
116        }
117    }
118
119    #[doc(alias = "gtk_center_layout_set_orientation")]
120    pub fn set_orientation(&self, orientation: Orientation) {
121        unsafe {
122            ffi::gtk_center_layout_set_orientation(self.to_glib_none().0, orientation.into_glib());
123        }
124    }
125
126    #[cfg(feature = "v4_12")]
127    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
128    #[doc(alias = "gtk_center_layout_set_shrink_center_last")]
129    #[doc(alias = "shrink-center-last")]
130    pub fn set_shrink_center_last(&self, shrink_center_last: bool) {
131        unsafe {
132            ffi::gtk_center_layout_set_shrink_center_last(
133                self.to_glib_none().0,
134                shrink_center_last.into_glib(),
135            );
136        }
137    }
138
139    #[doc(alias = "gtk_center_layout_set_start_widget")]
140    pub fn set_start_widget(&self, widget: Option<&impl IsA<Widget>>) {
141        unsafe {
142            ffi::gtk_center_layout_set_start_widget(
143                self.to_glib_none().0,
144                widget.map(|p| p.as_ref()).to_glib_none().0,
145            );
146        }
147    }
148
149    #[cfg(feature = "v4_12")]
150    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
151    #[doc(alias = "shrink-center-last")]
152    pub fn connect_shrink_center_last_notify<F: Fn(&Self) + 'static>(
153        &self,
154        f: F,
155    ) -> SignalHandlerId {
156        unsafe extern "C" fn notify_shrink_center_last_trampoline<
157            F: Fn(&CenterLayout) + 'static,
158        >(
159            this: *mut ffi::GtkCenterLayout,
160            _param_spec: glib::ffi::gpointer,
161            f: glib::ffi::gpointer,
162        ) {
163            let f: &F = &*(f as *const F);
164            f(&from_glib_borrow(this))
165        }
166        unsafe {
167            let f: Box_<F> = Box_::new(f);
168            connect_raw(
169                self.as_ptr() as *mut _,
170                c"notify::shrink-center-last".as_ptr() as *const _,
171                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
172                    notify_shrink_center_last_trampoline::<F> as *const (),
173                )),
174                Box_::into_raw(f),
175            )
176        }
177    }
178}
179
180impl Default for CenterLayout {
181    fn default() -> Self {
182        Self::new()
183    }
184}