Skip to main content

libadwaita/auto/
layout.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// An individual layout in [`MultiLayoutView`][crate::MultiLayoutView].
16    ///
17    /// ## Properties
18    ///
19    ///
20    /// #### `content`
21    ///  The content widget.
22    ///
23    /// Readable | Writable | Construct Only
24    ///
25    ///
26    /// #### `name`
27    ///  The name of the layout.
28    ///
29    /// Readable | Writable
30    ///
31    /// # Implements
32    ///
33    /// [`trait@glib::ObjectExt`], [`trait@gtk::prelude::BuildableExt`]
34    #[doc(alias = "AdwLayout")]
35    pub struct Layout(Object<ffi::AdwLayout, ffi::AdwLayoutClass>) @implements gtk::Buildable;
36
37    match fn {
38        type_ => || ffi::adw_layout_get_type(),
39    }
40}
41
42impl Layout {
43    /// Creates a new [`Layout`][crate::Layout] that contains @content.
44    /// ## `content`
45    /// the content widget to use
46    ///
47    /// # Returns
48    ///
49    /// a new [`Layout`][crate::Layout]
50    #[doc(alias = "adw_layout_new")]
51    pub fn new(content: &impl IsA<gtk::Widget>) -> Layout {
52        assert_initialized_main_thread!();
53        unsafe { from_glib_full(ffi::adw_layout_new(content.as_ref().to_glib_none().0)) }
54    }
55
56    /// Gets the content widget.
57    ///
58    /// # Returns
59    ///
60    /// The content
61    #[doc(alias = "adw_layout_get_content")]
62    #[doc(alias = "get_content")]
63    pub fn content(&self) -> gtk::Widget {
64        unsafe { from_glib_none(ffi::adw_layout_get_content(self.to_glib_none().0)) }
65    }
66
67    /// Gets the name of the layout.
68    ///
69    /// # Returns
70    ///
71    /// the name of the layout
72    #[doc(alias = "adw_layout_get_name")]
73    #[doc(alias = "get_name")]
74    pub fn name(&self) -> Option<glib::GString> {
75        unsafe { from_glib_none(ffi::adw_layout_get_name(self.to_glib_none().0)) }
76    }
77
78    /// Sets the name of the layout.
79    /// ## `name`
80    /// the layout name
81    #[doc(alias = "adw_layout_set_name")]
82    #[doc(alias = "name")]
83    pub fn set_name(&self, name: Option<&str>) {
84        unsafe {
85            ffi::adw_layout_set_name(self.to_glib_none().0, name.to_glib_none().0);
86        }
87    }
88
89    #[cfg(feature = "v1_6")]
90    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
91    #[doc(alias = "name")]
92    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
93        unsafe extern "C" fn notify_name_trampoline<F: Fn(&Layout) + 'static>(
94            this: *mut ffi::AdwLayout,
95            _param_spec: glib::ffi::gpointer,
96            f: glib::ffi::gpointer,
97        ) {
98            unsafe {
99                let f: &F = &*(f as *const F);
100                f(&from_glib_borrow(this))
101            }
102        }
103        unsafe {
104            let f: Box_<F> = Box_::new(f);
105            connect_raw(
106                self.as_ptr() as *mut _,
107                c"notify::name".as_ptr(),
108                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
109                    notify_name_trampoline::<F> as *const (),
110                )),
111                Box_::into_raw(f),
112            )
113        }
114    }
115}