libadwaita/auto/
layout.rs1use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "AdwLayout")]
16 pub struct Layout(Object<ffi::AdwLayout, ffi::AdwLayoutClass>) @implements gtk::Buildable;
17
18 match fn {
19 type_ => || ffi::adw_layout_get_type(),
20 }
21}
22
23impl Layout {
24 #[doc(alias = "adw_layout_new")]
25 pub fn new(content: &impl IsA<gtk::Widget>) -> Layout {
26 assert_initialized_main_thread!();
27 unsafe { from_glib_full(ffi::adw_layout_new(content.as_ref().to_glib_none().0)) }
28 }
29
30 #[doc(alias = "adw_layout_get_content")]
31 #[doc(alias = "get_content")]
32 pub fn content(&self) -> gtk::Widget {
33 unsafe { from_glib_none(ffi::adw_layout_get_content(self.to_glib_none().0)) }
34 }
35
36 #[doc(alias = "adw_layout_get_name")]
37 #[doc(alias = "get_name")]
38 pub fn name(&self) -> Option<glib::GString> {
39 unsafe { from_glib_none(ffi::adw_layout_get_name(self.to_glib_none().0)) }
40 }
41
42 #[doc(alias = "adw_layout_set_name")]
43 #[doc(alias = "name")]
44 pub fn set_name(&self, name: Option<&str>) {
45 unsafe {
46 ffi::adw_layout_set_name(self.to_glib_none().0, name.to_glib_none().0);
47 }
48 }
49
50 #[cfg(feature = "v1_6")]
51 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
52 #[doc(alias = "name")]
53 pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
54 unsafe extern "C" fn notify_name_trampoline<F: Fn(&Layout) + 'static>(
55 this: *mut ffi::AdwLayout,
56 _param_spec: glib::ffi::gpointer,
57 f: glib::ffi::gpointer,
58 ) {
59 let f: &F = &*(f as *const F);
60 f(&from_glib_borrow(this))
61 }
62 unsafe {
63 let f: Box_<F> = Box_::new(f);
64 connect_raw(
65 self.as_ptr() as *mut _,
66 c"notify::name".as_ptr() as *const _,
67 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
68 notify_name_trampoline::<F> as *const (),
69 )),
70 Box_::into_raw(f),
71 )
72 }
73 }
74}