Skip to main content

lightdm/auto/
session.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from lightdm-gir-files
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::{
7    prelude::*,
8    signal::{SignalHandlerId, connect_raw},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// #LightDMSession is an opaque data structure and can only be accessed
15    /// using the provided functions.
16    ///
17    /// ## Properties
18    ///
19    ///
20    /// #### `comment`
21    ///  Readable
22    ///
23    ///
24    /// #### `key`
25    ///  Readable
26    ///
27    ///
28    /// #### `name`
29    ///  Readable
30    ///
31    /// # Implements
32    ///
33    /// [`SessionExt`][trait@crate::prelude::SessionExt]
34    #[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
46/// Trait containing all [`struct@Session`] methods.
47///
48/// # Implementors
49///
50/// [`Session`][struct@crate::Session]
51pub trait SessionExt: IsA<Session> + 'static {
52    /// Get the comment for a session
53    ///
54    /// # Returns
55    ///
56    /// The session comment
57    #[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    /// Get the key for a session
68    ///
69    /// # Returns
70    ///
71    /// The session key
72    #[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    /// Get the name for a session
79    ///
80    /// # Returns
81    ///
82    /// The session name
83    #[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    /// Get the type a session
94    ///
95    /// # Returns
96    ///
97    /// The session type, e.g. x or mir
98    #[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 {}