lightdm/auto/
functions.rs1use crate::{Language, Layout, Session, ffi};
6use glib::{prelude::*, translate::*};
7
8#[doc(alias = "lightdm_get_can_hibernate")]
14#[doc(alias = "get_can_hibernate")]
15pub fn can_hibernate() -> bool {
16 assert_initialized_main_thread!();
17 unsafe { from_glib(ffi::lightdm_get_can_hibernate()) }
18}
19
20#[doc(alias = "lightdm_get_can_restart")]
26#[doc(alias = "get_can_restart")]
27pub fn can_restart() -> bool {
28 assert_initialized_main_thread!();
29 unsafe { from_glib(ffi::lightdm_get_can_restart()) }
30}
31
32#[doc(alias = "lightdm_get_can_shutdown")]
38#[doc(alias = "get_can_shutdown")]
39pub fn can_shutdown() -> bool {
40 assert_initialized_main_thread!();
41 unsafe { from_glib(ffi::lightdm_get_can_shutdown()) }
42}
43
44#[doc(alias = "lightdm_get_can_suspend")]
50#[doc(alias = "get_can_suspend")]
51pub fn can_suspend() -> bool {
52 assert_initialized_main_thread!();
53 unsafe { from_glib(ffi::lightdm_get_can_suspend()) }
54}
55
56#[doc(alias = "lightdm_get_hostname")]
61#[doc(alias = "get_hostname")]
62pub fn hostname() -> Option<glib::GString> {
63 assert_initialized_main_thread!();
64 unsafe { from_glib_none(ffi::lightdm_get_hostname()) }
65}
66
67#[doc(alias = "lightdm_get_language")]
73#[doc(alias = "get_language")]
74pub fn language() -> Option<Language> {
75 assert_initialized_main_thread!();
76 unsafe { from_glib_none(ffi::lightdm_get_language()) }
77}
78
79#[doc(alias = "lightdm_get_languages")]
85#[doc(alias = "get_languages")]
86pub fn languages() -> Vec<Language> {
87 assert_initialized_main_thread!();
88 unsafe { FromGlibPtrContainer::from_glib_none(ffi::lightdm_get_languages()) }
89}
90
91#[doc(alias = "lightdm_get_layout")]
97#[doc(alias = "get_layout")]
98pub fn layout() -> Option<Layout> {
99 assert_initialized_main_thread!();
100 unsafe { from_glib_none(ffi::lightdm_get_layout()) }
101}
102
103#[doc(alias = "lightdm_get_layouts")]
109#[doc(alias = "get_layouts")]
110pub fn layouts() -> Vec<Layout> {
111 assert_initialized_main_thread!();
112 unsafe { FromGlibPtrContainer::from_glib_none(ffi::lightdm_get_layouts()) }
113}
114
115#[doc(alias = "lightdm_get_motd")]
122#[doc(alias = "get_motd")]
123pub fn motd() -> Option<glib::GString> {
124 assert_initialized_main_thread!();
125 unsafe { from_glib_full(ffi::lightdm_get_motd()) }
126}
127
128#[doc(alias = "lightdm_get_os_id")]
135#[doc(alias = "get_os_id")]
136pub fn os_id() -> Option<glib::GString> {
137 assert_initialized_main_thread!();
138 unsafe { from_glib_none(ffi::lightdm_get_os_id()) }
139}
140
141#[doc(alias = "lightdm_get_os_name")]
148#[doc(alias = "get_os_name")]
149pub fn os_name() -> Option<glib::GString> {
150 assert_initialized_main_thread!();
151 unsafe { from_glib_none(ffi::lightdm_get_os_name()) }
152}
153
154#[doc(alias = "lightdm_get_os_pretty_name")]
161#[doc(alias = "get_os_pretty_name")]
162pub fn os_pretty_name() -> Option<glib::GString> {
163 assert_initialized_main_thread!();
164 unsafe { from_glib_none(ffi::lightdm_get_os_pretty_name()) }
165}
166
167#[doc(alias = "lightdm_get_os_version")]
174#[doc(alias = "get_os_version")]
175pub fn os_version() -> Option<glib::GString> {
176 assert_initialized_main_thread!();
177 unsafe { from_glib_none(ffi::lightdm_get_os_version()) }
178}
179
180#[doc(alias = "lightdm_get_os_version_id")]
187#[doc(alias = "get_os_version_id")]
188pub fn os_version_id() -> Option<glib::GString> {
189 assert_initialized_main_thread!();
190 unsafe { from_glib_none(ffi::lightdm_get_os_version_id()) }
191}
192
193#[doc(alias = "lightdm_get_remote_sessions")]
199#[doc(alias = "get_remote_sessions")]
200pub fn remote_sessions() -> Vec<Session> {
201 assert_initialized_main_thread!();
202 unsafe { FromGlibPtrContainer::from_glib_none(ffi::lightdm_get_remote_sessions()) }
203}
204
205#[doc(alias = "lightdm_get_sessions")]
211#[doc(alias = "get_sessions")]
212pub fn sessions() -> Vec<Session> {
213 assert_initialized_main_thread!();
214 unsafe { FromGlibPtrContainer::from_glib_none(ffi::lightdm_get_sessions()) }
215}
216
217#[doc(alias = "lightdm_hibernate")]
223pub fn hibernate() -> Result<(), glib::Error> {
224 assert_initialized_main_thread!();
225 unsafe {
226 let mut error = std::ptr::null_mut();
227 let is_ok = ffi::lightdm_hibernate(&mut error);
228 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
229 if error.is_null() {
230 Ok(())
231 } else {
232 Err(from_glib_full(error))
233 }
234 }
235}
236
237#[doc(alias = "lightdm_restart")]
243pub fn restart() -> Result<(), glib::Error> {
244 assert_initialized_main_thread!();
245 unsafe {
246 let mut error = std::ptr::null_mut();
247 let is_ok = ffi::lightdm_restart(&mut error);
248 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
249 if error.is_null() {
250 Ok(())
251 } else {
252 Err(from_glib_full(error))
253 }
254 }
255}
256
257#[doc(alias = "lightdm_set_layout")]
261pub fn set_layout(layout: &impl IsA<Layout>) {
262 skip_assert_initialized!();
263 unsafe {
264 ffi::lightdm_set_layout(layout.as_ref().to_glib_none().0);
265 }
266}
267
268#[doc(alias = "lightdm_shutdown")]
274pub fn shutdown() -> Result<(), glib::Error> {
275 assert_initialized_main_thread!();
276 unsafe {
277 let mut error = std::ptr::null_mut();
278 let is_ok = ffi::lightdm_shutdown(&mut error);
279 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
280 if error.is_null() {
281 Ok(())
282 } else {
283 Err(from_glib_full(error))
284 }
285 }
286}
287
288#[doc(alias = "lightdm_suspend")]
294pub fn suspend() -> Result<(), glib::Error> {
295 assert_initialized_main_thread!();
296 unsafe {
297 let mut error = std::ptr::null_mut();
298 let is_ok = ffi::lightdm_suspend(&mut error);
299 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
300 if error.is_null() {
301 Ok(())
302 } else {
303 Err(from_glib_full(error))
304 }
305 }
306}