Skip to main content

lightdm/auto/
user.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    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// #LightDMUser is an opaque data structure and can only be accessed
16    /// using the provided functions.
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `background`
22    ///  Readable
23    ///
24    ///
25    /// #### `display-name`
26    ///  Readable
27    ///
28    ///
29    /// #### `has-messages`
30    ///  Readable
31    ///
32    ///
33    /// #### `home-directory`
34    ///  Readable
35    ///
36    ///
37    /// #### `image`
38    ///  Readable
39    ///
40    ///
41    /// #### `is-locked`
42    ///  Readable
43    ///
44    ///
45    /// #### `language`
46    ///  Readable
47    ///
48    ///
49    /// #### `layout`
50    ///  Readable
51    ///
52    ///
53    /// #### `layouts`
54    ///  Readable
55    ///
56    ///
57    /// #### `logged-in`
58    ///  Readable
59    ///
60    ///
61    /// #### `name`
62    ///  Readable
63    ///
64    ///
65    /// #### `real-name`
66    ///  Readable
67    ///
68    ///
69    /// #### `session`
70    ///  Readable
71    ///
72    ///
73    /// #### `uid`
74    ///  Readable
75    ///
76    /// ## Signals
77    ///
78    ///
79    /// #### `changed`
80    ///  The ::changed signal gets emitted this user account is modified.
81    ///
82    ///
83    ///
84    /// # Implements
85    ///
86    /// [`UserExt`][trait@crate::prelude::UserExt]
87    #[doc(alias = "LightDMUser")]
88    pub struct User(Object<ffi::LightDMUser, ffi::LightDMUserClass>);
89
90    match fn {
91        type_ => || ffi::lightdm_user_get_type(),
92    }
93}
94
95impl User {
96    pub const NONE: Option<&'static User> = None;
97}
98
99/// Trait containing all [`struct@User`] methods.
100///
101/// # Implementors
102///
103/// [`User`][struct@crate::User]
104pub trait UserExt: IsA<User> + 'static {
105    /// Get the background file path for a user.
106    ///
107    /// # Returns
108    ///
109    /// The background file path for the given user or #NULL if no path
110    #[doc(alias = "lightdm_user_get_background")]
111    #[doc(alias = "get_background")]
112    fn background(&self) -> Option<glib::GString> {
113        unsafe {
114            from_glib_none(ffi::lightdm_user_get_background(
115                self.as_ref().to_glib_none().0,
116            ))
117        }
118    }
119
120    /// Get the display name of a user.
121    ///
122    /// # Returns
123    ///
124    /// The display name of the given user
125    #[doc(alias = "lightdm_user_get_display_name")]
126    #[doc(alias = "get_display_name")]
127    #[doc(alias = "display-name")]
128    fn display_name(&self) -> Option<glib::GString> {
129        unsafe {
130            from_glib_none(ffi::lightdm_user_get_display_name(
131                self.as_ref().to_glib_none().0,
132            ))
133        }
134    }
135
136    /// Check if a user has waiting messages.
137    ///
138    /// # Returns
139    ///
140    /// #TRUE if the user has waiting messages.
141    #[doc(alias = "lightdm_user_get_has_messages")]
142    #[doc(alias = "get_has_messages")]
143    #[doc(alias = "has-messages")]
144    fn has_messages(&self) -> bool {
145        unsafe {
146            from_glib(ffi::lightdm_user_get_has_messages(
147                self.as_ref().to_glib_none().0,
148            ))
149        }
150    }
151
152    /// Get the home directory for a user.
153    ///
154    /// # Returns
155    ///
156    /// The users home directory
157    #[doc(alias = "lightdm_user_get_home_directory")]
158    #[doc(alias = "get_home_directory")]
159    #[doc(alias = "home-directory")]
160    fn home_directory(&self) -> Option<glib::GString> {
161        unsafe {
162            from_glib_none(ffi::lightdm_user_get_home_directory(
163                self.as_ref().to_glib_none().0,
164            ))
165        }
166    }
167
168    /// Get the image URI for a user.
169    ///
170    /// # Returns
171    ///
172    /// The image URI for the given user or #NULL if no URI
173    #[doc(alias = "lightdm_user_get_image")]
174    #[doc(alias = "get_image")]
175    fn image(&self) -> Option<glib::GString> {
176        unsafe { from_glib_none(ffi::lightdm_user_get_image(self.as_ref().to_glib_none().0)) }
177    }
178
179    /// Get if the user is locked.
180    ///
181    /// # Returns
182    ///
183    /// [`true`] if the user is locked
184    #[doc(alias = "lightdm_user_get_is_locked")]
185    #[doc(alias = "get_is_locked")]
186    #[doc(alias = "is-locked")]
187    fn is_locked(&self) -> bool {
188        unsafe {
189            from_glib(ffi::lightdm_user_get_is_locked(
190                self.as_ref().to_glib_none().0,
191            ))
192        }
193    }
194
195    /// Get the language for a user.
196    ///
197    /// # Returns
198    ///
199    /// The language in the form of a local specification (e.g. "de_DE.UTF-8") for the given user or #NULL if using the system default locale.
200    #[doc(alias = "lightdm_user_get_language")]
201    #[doc(alias = "get_language")]
202    fn language(&self) -> Option<glib::GString> {
203        unsafe {
204            from_glib_none(ffi::lightdm_user_get_language(
205                self.as_ref().to_glib_none().0,
206            ))
207        }
208    }
209
210    /// Get the keyboard layout for a user.
211    ///
212    /// # Returns
213    ///
214    /// The keyboard layout for the given user or #NULL if using system defaults.  Copy the value if you want to use it long term.
215    #[doc(alias = "lightdm_user_get_layout")]
216    #[doc(alias = "get_layout")]
217    fn layout(&self) -> Option<glib::GString> {
218        unsafe { from_glib_none(ffi::lightdm_user_get_layout(self.as_ref().to_glib_none().0)) }
219    }
220
221    /// Get the configured keyboard layouts for a user.
222    ///
223    /// # Returns
224    ///
225    /// A NULL-terminated array of keyboard layouts for the given user.  Copy the values if you want to use them long term.
226    #[doc(alias = "lightdm_user_get_layouts")]
227    #[doc(alias = "get_layouts")]
228    fn layouts(&self) -> Vec<glib::GString> {
229        unsafe {
230            FromGlibPtrContainer::from_glib_none(ffi::lightdm_user_get_layouts(
231                self.as_ref().to_glib_none().0,
232            ))
233        }
234    }
235
236    /// Check if a user is logged in.
237    ///
238    /// # Returns
239    ///
240    /// #TRUE if the user is currently logged in.
241    #[doc(alias = "lightdm_user_get_logged_in")]
242    #[doc(alias = "get_logged_in")]
243    #[doc(alias = "logged-in")]
244    fn is_logged_in(&self) -> bool {
245        unsafe {
246            from_glib(ffi::lightdm_user_get_logged_in(
247                self.as_ref().to_glib_none().0,
248            ))
249        }
250    }
251
252    /// Get the name of a user.
253    ///
254    /// # Returns
255    ///
256    /// The name of the given user
257    #[doc(alias = "lightdm_user_get_name")]
258    #[doc(alias = "get_name")]
259    fn name(&self) -> Option<glib::GString> {
260        unsafe { from_glib_none(ffi::lightdm_user_get_name(self.as_ref().to_glib_none().0)) }
261    }
262
263    /// Get the real name of a user.
264    ///
265    /// # Returns
266    ///
267    /// The real name of the given user
268    #[doc(alias = "lightdm_user_get_real_name")]
269    #[doc(alias = "get_real_name")]
270    #[doc(alias = "real-name")]
271    fn real_name(&self) -> Option<glib::GString> {
272        unsafe {
273            from_glib_none(ffi::lightdm_user_get_real_name(
274                self.as_ref().to_glib_none().0,
275            ))
276        }
277    }
278
279    /// Get the session for a user.
280    ///
281    /// # Returns
282    ///
283    /// The session for the given user or #NULL if using system defaults.
284    #[doc(alias = "lightdm_user_get_session")]
285    #[doc(alias = "get_session")]
286    fn session(&self) -> Option<glib::GString> {
287        unsafe {
288            from_glib_none(ffi::lightdm_user_get_session(
289                self.as_ref().to_glib_none().0,
290            ))
291        }
292    }
293
294    /// Get the uid of a user.
295    ///
296    /// # Returns
297    ///
298    /// The uid of the given user
299    #[doc(alias = "lightdm_user_get_uid")]
300    #[doc(alias = "get_uid")]
301    fn uid(&self) -> u32 {
302        unsafe { ffi::lightdm_user_get_uid(self.as_ref().to_glib_none().0) }
303    }
304
305    /// The ::changed signal gets emitted this user account is modified.
306    #[doc(alias = "changed")]
307    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
308        unsafe extern "C" fn changed_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
309            this: *mut ffi::LightDMUser,
310            f: glib::ffi::gpointer,
311        ) {
312            unsafe {
313                let f: &F = &*(f as *const F);
314                f(User::from_glib_borrow(this).unsafe_cast_ref())
315            }
316        }
317        unsafe {
318            let f: Box_<F> = Box_::new(f);
319            connect_raw(
320                self.as_ptr() as *mut _,
321                c"changed".as_ptr(),
322                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
323                    changed_trampoline::<Self, F> as *const (),
324                )),
325                Box_::into_raw(f),
326            )
327        }
328    }
329
330    #[doc(alias = "background")]
331    fn connect_background_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
332        unsafe extern "C" fn notify_background_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
333            this: *mut ffi::LightDMUser,
334            _param_spec: glib::ffi::gpointer,
335            f: glib::ffi::gpointer,
336        ) {
337            unsafe {
338                let f: &F = &*(f as *const F);
339                f(User::from_glib_borrow(this).unsafe_cast_ref())
340            }
341        }
342        unsafe {
343            let f: Box_<F> = Box_::new(f);
344            connect_raw(
345                self.as_ptr() as *mut _,
346                c"notify::background".as_ptr(),
347                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
348                    notify_background_trampoline::<Self, F> as *const (),
349                )),
350                Box_::into_raw(f),
351            )
352        }
353    }
354
355    #[doc(alias = "display-name")]
356    fn connect_display_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
357        unsafe extern "C" fn notify_display_name_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
358            this: *mut ffi::LightDMUser,
359            _param_spec: glib::ffi::gpointer,
360            f: glib::ffi::gpointer,
361        ) {
362            unsafe {
363                let f: &F = &*(f as *const F);
364                f(User::from_glib_borrow(this).unsafe_cast_ref())
365            }
366        }
367        unsafe {
368            let f: Box_<F> = Box_::new(f);
369            connect_raw(
370                self.as_ptr() as *mut _,
371                c"notify::display-name".as_ptr(),
372                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
373                    notify_display_name_trampoline::<Self, F> as *const (),
374                )),
375                Box_::into_raw(f),
376            )
377        }
378    }
379
380    #[doc(alias = "has-messages")]
381    fn connect_has_messages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
382        unsafe extern "C" fn notify_has_messages_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
383            this: *mut ffi::LightDMUser,
384            _param_spec: glib::ffi::gpointer,
385            f: glib::ffi::gpointer,
386        ) {
387            unsafe {
388                let f: &F = &*(f as *const F);
389                f(User::from_glib_borrow(this).unsafe_cast_ref())
390            }
391        }
392        unsafe {
393            let f: Box_<F> = Box_::new(f);
394            connect_raw(
395                self.as_ptr() as *mut _,
396                c"notify::has-messages".as_ptr(),
397                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
398                    notify_has_messages_trampoline::<Self, F> as *const (),
399                )),
400                Box_::into_raw(f),
401            )
402        }
403    }
404
405    #[doc(alias = "home-directory")]
406    fn connect_home_directory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
407        unsafe extern "C" fn notify_home_directory_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
408            this: *mut ffi::LightDMUser,
409            _param_spec: glib::ffi::gpointer,
410            f: glib::ffi::gpointer,
411        ) {
412            unsafe {
413                let f: &F = &*(f as *const F);
414                f(User::from_glib_borrow(this).unsafe_cast_ref())
415            }
416        }
417        unsafe {
418            let f: Box_<F> = Box_::new(f);
419            connect_raw(
420                self.as_ptr() as *mut _,
421                c"notify::home-directory".as_ptr(),
422                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
423                    notify_home_directory_trampoline::<Self, F> as *const (),
424                )),
425                Box_::into_raw(f),
426            )
427        }
428    }
429
430    #[doc(alias = "image")]
431    fn connect_image_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
432        unsafe extern "C" fn notify_image_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
433            this: *mut ffi::LightDMUser,
434            _param_spec: glib::ffi::gpointer,
435            f: glib::ffi::gpointer,
436        ) {
437            unsafe {
438                let f: &F = &*(f as *const F);
439                f(User::from_glib_borrow(this).unsafe_cast_ref())
440            }
441        }
442        unsafe {
443            let f: Box_<F> = Box_::new(f);
444            connect_raw(
445                self.as_ptr() as *mut _,
446                c"notify::image".as_ptr(),
447                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
448                    notify_image_trampoline::<Self, F> as *const (),
449                )),
450                Box_::into_raw(f),
451            )
452        }
453    }
454
455    #[doc(alias = "is-locked")]
456    fn connect_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
457        unsafe extern "C" fn notify_is_locked_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
458            this: *mut ffi::LightDMUser,
459            _param_spec: glib::ffi::gpointer,
460            f: glib::ffi::gpointer,
461        ) {
462            unsafe {
463                let f: &F = &*(f as *const F);
464                f(User::from_glib_borrow(this).unsafe_cast_ref())
465            }
466        }
467        unsafe {
468            let f: Box_<F> = Box_::new(f);
469            connect_raw(
470                self.as_ptr() as *mut _,
471                c"notify::is-locked".as_ptr(),
472                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
473                    notify_is_locked_trampoline::<Self, F> as *const (),
474                )),
475                Box_::into_raw(f),
476            )
477        }
478    }
479
480    #[doc(alias = "language")]
481    fn connect_language_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
482        unsafe extern "C" fn notify_language_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
483            this: *mut ffi::LightDMUser,
484            _param_spec: glib::ffi::gpointer,
485            f: glib::ffi::gpointer,
486        ) {
487            unsafe {
488                let f: &F = &*(f as *const F);
489                f(User::from_glib_borrow(this).unsafe_cast_ref())
490            }
491        }
492        unsafe {
493            let f: Box_<F> = Box_::new(f);
494            connect_raw(
495                self.as_ptr() as *mut _,
496                c"notify::language".as_ptr(),
497                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
498                    notify_language_trampoline::<Self, F> as *const (),
499                )),
500                Box_::into_raw(f),
501            )
502        }
503    }
504
505    #[doc(alias = "layout")]
506    fn connect_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
507        unsafe extern "C" fn notify_layout_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
508            this: *mut ffi::LightDMUser,
509            _param_spec: glib::ffi::gpointer,
510            f: glib::ffi::gpointer,
511        ) {
512            unsafe {
513                let f: &F = &*(f as *const F);
514                f(User::from_glib_borrow(this).unsafe_cast_ref())
515            }
516        }
517        unsafe {
518            let f: Box_<F> = Box_::new(f);
519            connect_raw(
520                self.as_ptr() as *mut _,
521                c"notify::layout".as_ptr(),
522                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
523                    notify_layout_trampoline::<Self, F> as *const (),
524                )),
525                Box_::into_raw(f),
526            )
527        }
528    }
529
530    #[doc(alias = "layouts")]
531    fn connect_layouts_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
532        unsafe extern "C" fn notify_layouts_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
533            this: *mut ffi::LightDMUser,
534            _param_spec: glib::ffi::gpointer,
535            f: glib::ffi::gpointer,
536        ) {
537            unsafe {
538                let f: &F = &*(f as *const F);
539                f(User::from_glib_borrow(this).unsafe_cast_ref())
540            }
541        }
542        unsafe {
543            let f: Box_<F> = Box_::new(f);
544            connect_raw(
545                self.as_ptr() as *mut _,
546                c"notify::layouts".as_ptr(),
547                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
548                    notify_layouts_trampoline::<Self, F> as *const (),
549                )),
550                Box_::into_raw(f),
551            )
552        }
553    }
554
555    #[doc(alias = "logged-in")]
556    fn connect_logged_in_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
557        unsafe extern "C" fn notify_logged_in_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
558            this: *mut ffi::LightDMUser,
559            _param_spec: glib::ffi::gpointer,
560            f: glib::ffi::gpointer,
561        ) {
562            unsafe {
563                let f: &F = &*(f as *const F);
564                f(User::from_glib_borrow(this).unsafe_cast_ref())
565            }
566        }
567        unsafe {
568            let f: Box_<F> = Box_::new(f);
569            connect_raw(
570                self.as_ptr() as *mut _,
571                c"notify::logged-in".as_ptr(),
572                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
573                    notify_logged_in_trampoline::<Self, F> as *const (),
574                )),
575                Box_::into_raw(f),
576            )
577        }
578    }
579
580    #[doc(alias = "name")]
581    fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
582        unsafe extern "C" fn notify_name_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
583            this: *mut ffi::LightDMUser,
584            _param_spec: glib::ffi::gpointer,
585            f: glib::ffi::gpointer,
586        ) {
587            unsafe {
588                let f: &F = &*(f as *const F);
589                f(User::from_glib_borrow(this).unsafe_cast_ref())
590            }
591        }
592        unsafe {
593            let f: Box_<F> = Box_::new(f);
594            connect_raw(
595                self.as_ptr() as *mut _,
596                c"notify::name".as_ptr(),
597                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
598                    notify_name_trampoline::<Self, F> as *const (),
599                )),
600                Box_::into_raw(f),
601            )
602        }
603    }
604
605    #[doc(alias = "real-name")]
606    fn connect_real_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
607        unsafe extern "C" fn notify_real_name_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
608            this: *mut ffi::LightDMUser,
609            _param_spec: glib::ffi::gpointer,
610            f: glib::ffi::gpointer,
611        ) {
612            unsafe {
613                let f: &F = &*(f as *const F);
614                f(User::from_glib_borrow(this).unsafe_cast_ref())
615            }
616        }
617        unsafe {
618            let f: Box_<F> = Box_::new(f);
619            connect_raw(
620                self.as_ptr() as *mut _,
621                c"notify::real-name".as_ptr(),
622                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
623                    notify_real_name_trampoline::<Self, F> as *const (),
624                )),
625                Box_::into_raw(f),
626            )
627        }
628    }
629
630    #[doc(alias = "session")]
631    fn connect_session_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
632        unsafe extern "C" fn notify_session_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
633            this: *mut ffi::LightDMUser,
634            _param_spec: glib::ffi::gpointer,
635            f: glib::ffi::gpointer,
636        ) {
637            unsafe {
638                let f: &F = &*(f as *const F);
639                f(User::from_glib_borrow(this).unsafe_cast_ref())
640            }
641        }
642        unsafe {
643            let f: Box_<F> = Box_::new(f);
644            connect_raw(
645                self.as_ptr() as *mut _,
646                c"notify::session".as_ptr(),
647                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
648                    notify_session_trampoline::<Self, F> as *const (),
649                )),
650                Box_::into_raw(f),
651            )
652        }
653    }
654
655    #[doc(alias = "uid")]
656    fn connect_uid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
657        unsafe extern "C" fn notify_uid_trampoline<P: IsA<User>, F: Fn(&P) + 'static>(
658            this: *mut ffi::LightDMUser,
659            _param_spec: glib::ffi::gpointer,
660            f: glib::ffi::gpointer,
661        ) {
662            unsafe {
663                let f: &F = &*(f as *const F);
664                f(User::from_glib_borrow(this).unsafe_cast_ref())
665            }
666        }
667        unsafe {
668            let f: Box_<F> = Box_::new(f);
669            connect_raw(
670                self.as_ptr() as *mut _,
671                c"notify::uid".as_ptr(),
672                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
673                    notify_uid_trampoline::<Self, F> as *const (),
674                )),
675                Box_::into_raw(f),
676            )
677        }
678    }
679}
680
681impl<O: IsA<User>> UserExt for O {}