1use crate::ffi;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 #[doc(alias = "LightDMLayout")]
30 pub struct Layout(Object<ffi::LightDMLayout, ffi::LightDMLayoutClass>);
31
32 match fn {
33 type_ => || ffi::lightdm_layout_get_type(),
34 }
35}
36
37impl Layout {
38 pub const NONE: Option<&'static Layout> = None;
39
40 pub fn builder() -> LayoutBuilder {
45 LayoutBuilder::new()
46 }
47}
48
49#[must_use = "The builder must be built to be used"]
54pub struct LayoutBuilder {
55 builder: glib::object::ObjectBuilder<'static, Layout>,
56}
57
58impl LayoutBuilder {
59 fn new() -> Self {
60 Self {
61 builder: glib::object::Object::builder(),
62 }
63 }
64
65 pub fn description(self, description: impl Into<glib::GString>) -> Self {
66 Self {
67 builder: self.builder.property("description", description.into()),
68 }
69 }
70
71 pub fn name(self, name: impl Into<glib::GString>) -> Self {
72 Self {
73 builder: self.builder.property("name", name.into()),
74 }
75 }
76
77 pub fn short_description(self, short_description: impl Into<glib::GString>) -> Self {
78 Self {
79 builder: self
80 .builder
81 .property("short-description", short_description.into()),
82 }
83 }
84
85 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
88 pub fn build(self) -> Layout {
89 assert_initialized_main_thread!();
90 self.builder.build()
91 }
92}
93
94pub trait LayoutExt: IsA<Layout> + 'static {
100 #[doc(alias = "lightdm_layout_get_description")]
106 #[doc(alias = "get_description")]
107 fn description(&self) -> Option<glib::GString> {
108 unsafe {
109 from_glib_none(ffi::lightdm_layout_get_description(
110 self.as_ref().to_glib_none().0,
111 ))
112 }
113 }
114
115 #[doc(alias = "lightdm_layout_get_name")]
121 #[doc(alias = "get_name")]
122 fn name(&self) -> Option<glib::GString> {
123 unsafe { from_glib_none(ffi::lightdm_layout_get_name(self.as_ref().to_glib_none().0)) }
124 }
125
126 #[doc(alias = "lightdm_layout_get_short_description")]
132 #[doc(alias = "get_short_description")]
133 #[doc(alias = "short-description")]
134 fn short_description(&self) -> Option<glib::GString> {
135 unsafe {
136 from_glib_none(ffi::lightdm_layout_get_short_description(
137 self.as_ref().to_glib_none().0,
138 ))
139 }
140 }
141}
142
143impl<O: IsA<Layout>> LayoutExt for O {}