1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files.gtk (https://github.com/gtk-rs/gir-files)
// from gir-files.xfce
// DO NOT EDIT
use crate::ffi;
use glib::translate::*;
glib::wrapper! {
///
///
/// # Implements
///
/// [`trait@glib::ObjectExt`]
#[doc(alias = "XfceConsolekit")]
pub struct Consolekit(Object<ffi::XfceConsolekit, ffi::XfceConsolekitClass>);
match fn {
type_ => || ffi::xfce_consolekit_get_type(),
}
}
impl Consolekit {
/// Ask ConsoleKit to trigger Hibernate.
/// ## `polkit_interactive`
/// whether PolicyKit should ask the user to authenticate if needed
///
/// # Returns
///
/// [`true`] if the D-Bus request was successful, [`false`] otherwise and `error` is set.
#[doc(alias = "xfce_consolekit_hibernate")]
pub fn hibernate(&self, polkit_interactive: bool) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::xfce_consolekit_hibernate(
self.to_glib_none().0,
polkit_interactive.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Ask ConsoleKit to trigger HybridSleep.
/// ## `polkit_interactive`
/// whether PolicyKit should ask the user to authenticate if needed
///
/// # Returns
///
/// [`true`] if the D-Bus request was successful, [`false`] otherwise and `error` is set.
#[doc(alias = "xfce_consolekit_hybrid_sleep")]
pub fn hybrid_sleep(&self, polkit_interactive: bool) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::xfce_consolekit_hybrid_sleep(
self.to_glib_none().0,
polkit_interactive.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Ask ConsoleKit to trigger PowerOff.
/// ## `polkit_interactive`
/// whether PolicyKit should ask the user to authenticate if needed
///
/// # Returns
///
/// [`true`] if the D-Bus request was successful, [`false`] otherwise and `error` is set.
#[doc(alias = "xfce_consolekit_power_off")]
pub fn power_off(&self, polkit_interactive: bool) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::xfce_consolekit_power_off(
self.to_glib_none().0,
polkit_interactive.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Ask ConsoleKit to trigger Reboot.
/// ## `polkit_interactive`
/// whether PolicyKit should ask the user to authenticate if needed
///
/// # Returns
///
/// [`true`] if the D-Bus request was successful, [`false`] otherwise and `error` is set.
#[doc(alias = "xfce_consolekit_reboot")]
pub fn reboot(&self, polkit_interactive: bool) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::xfce_consolekit_reboot(
self.to_glib_none().0,
polkit_interactive.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Ask ConsoleKit to trigger Suspend.
/// ## `polkit_interactive`
/// whether PolicyKit should ask the user to authenticate if needed
///
/// # Returns
///
/// [`true`] if the D-Bus request was successful, [`false`] otherwise and `error` is set.
#[doc(alias = "xfce_consolekit_suspend")]
pub fn suspend(&self, polkit_interactive: bool) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::xfce_consolekit_suspend(
self.to_glib_none().0,
polkit_interactive.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Create a new [`Consolekit`][crate::Consolekit] instance or increase reference count.
///
/// # Returns
///
/// A reference to the singleton object, to be released with `g_object_unref()`.
#[doc(alias = "xfce_consolekit_get")]
pub fn get() -> Consolekit {
unsafe { from_glib_full(ffi::xfce_consolekit_get()) }
}
}