libadwaita/auto/
layout.rs1use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[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 #[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 #[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 #[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 #[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}