1use crate::ffi;
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "LightDMSession")]
35 pub struct Session(Object<ffi::LightDMSession, ffi::LightDMSessionClass>);
36
37 match fn {
38 type_ => || ffi::lightdm_session_get_type(),
39 }
40}
41
42impl Session {
43 pub const NONE: Option<&'static Session> = None;
44}
45
46pub trait SessionExt: IsA<Session> + 'static {
52 #[doc(alias = "lightdm_session_get_comment")]
58 #[doc(alias = "get_comment")]
59 fn comment(&self) -> Option<glib::GString> {
60 unsafe {
61 from_glib_none(ffi::lightdm_session_get_comment(
62 self.as_ref().to_glib_none().0,
63 ))
64 }
65 }
66
67 #[doc(alias = "lightdm_session_get_key")]
73 #[doc(alias = "get_key")]
74 fn key(&self) -> Option<glib::GString> {
75 unsafe { from_glib_none(ffi::lightdm_session_get_key(self.as_ref().to_glib_none().0)) }
76 }
77
78 #[doc(alias = "lightdm_session_get_name")]
84 #[doc(alias = "get_name")]
85 fn name(&self) -> Option<glib::GString> {
86 unsafe {
87 from_glib_none(ffi::lightdm_session_get_name(
88 self.as_ref().to_glib_none().0,
89 ))
90 }
91 }
92
93 #[doc(alias = "lightdm_session_get_session_type")]
99 #[doc(alias = "get_session_type")]
100 fn session_type(&self) -> Option<glib::GString> {
101 unsafe {
102 from_glib_none(ffi::lightdm_session_get_session_type(
103 self.as_ref().to_glib_none().0,
104 ))
105 }
106 }
107
108 #[doc(alias = "comment")]
109 fn connect_comment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
110 unsafe extern "C" fn notify_comment_trampoline<P: IsA<Session>, F: Fn(&P) + 'static>(
111 this: *mut ffi::LightDMSession,
112 _param_spec: glib::ffi::gpointer,
113 f: glib::ffi::gpointer,
114 ) {
115 unsafe {
116 let f: &F = &*(f as *const F);
117 f(Session::from_glib_borrow(this).unsafe_cast_ref())
118 }
119 }
120 unsafe {
121 let f: Box_<F> = Box_::new(f);
122 connect_raw(
123 self.as_ptr() as *mut _,
124 c"notify::comment".as_ptr(),
125 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
126 notify_comment_trampoline::<Self, F> as *const (),
127 )),
128 Box_::into_raw(f),
129 )
130 }
131 }
132
133 #[doc(alias = "key")]
134 fn connect_key_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
135 unsafe extern "C" fn notify_key_trampoline<P: IsA<Session>, F: Fn(&P) + 'static>(
136 this: *mut ffi::LightDMSession,
137 _param_spec: glib::ffi::gpointer,
138 f: glib::ffi::gpointer,
139 ) {
140 unsafe {
141 let f: &F = &*(f as *const F);
142 f(Session::from_glib_borrow(this).unsafe_cast_ref())
143 }
144 }
145 unsafe {
146 let f: Box_<F> = Box_::new(f);
147 connect_raw(
148 self.as_ptr() as *mut _,
149 c"notify::key".as_ptr(),
150 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
151 notify_key_trampoline::<Self, F> as *const (),
152 )),
153 Box_::into_raw(f),
154 )
155 }
156 }
157
158 #[doc(alias = "name")]
159 fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
160 unsafe extern "C" fn notify_name_trampoline<P: IsA<Session>, F: Fn(&P) + 'static>(
161 this: *mut ffi::LightDMSession,
162 _param_spec: glib::ffi::gpointer,
163 f: glib::ffi::gpointer,
164 ) {
165 unsafe {
166 let f: &F = &*(f as *const F);
167 f(Session::from_glib_borrow(this).unsafe_cast_ref())
168 }
169 }
170 unsafe {
171 let f: Box_<F> = Box_::new(f);
172 connect_raw(
173 self.as_ptr() as *mut _,
174 c"notify::name".as_ptr(),
175 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
176 notify_name_trampoline::<Self, F> as *const (),
177 )),
178 Box_::into_raw(f),
179 )
180 }
181 }
182}
183
184impl<O: IsA<Session>> SessionExt for O {}