// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::GString;
use glib_sys;
use light_dm_sys;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;

glib_wrapper! {
    pub struct User(Object<light_dm_sys::LightDMUser, light_dm_sys::LightDMUserClass, UserClass>);

    match fn {
        get_type => || light_dm_sys::lightdm_user_get_type(),
    }
}

pub const NONE_USER: Option<&User> = None;

pub trait UserExt: 'static {
    fn get_background(&self) -> Option<GString>;

    fn get_display_name(&self) -> Option<GString>;

    fn get_has_messages(&self) -> bool;

    fn get_home_directory(&self) -> Option<GString>;

    fn get_image(&self) -> Option<GString>;

    fn get_is_locked(&self) -> bool;

    fn get_language(&self) -> Option<GString>;

    fn get_layout(&self) -> Option<GString>;

    fn get_layouts(&self) -> Vec<GString>;

    fn get_logged_in(&self) -> bool;

    fn get_name(&self) -> Option<GString>;

    fn get_real_name(&self) -> Option<GString>;

    fn get_session(&self) -> Option<GString>;

    fn get_uid(&self) -> u32;

    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_background_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_display_name_notify<F: Fn(&Self) + 'static>(&self, f: F)
        -> SignalHandlerId;

    fn connect_property_has_messages_notify<F: Fn(&Self) + 'static>(&self, f: F)
        -> SignalHandlerId;

    fn connect_property_home_directory_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;

    fn connect_property_image_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_language_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_layouts_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_logged_in_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_real_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_session_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_uid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<User>> UserExt for O {
    fn get_background(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_background(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_display_name(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_display_name(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_has_messages(&self) -> bool {
        unsafe {
            from_glib(light_dm_sys::lightdm_user_get_has_messages(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_home_directory(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_home_directory(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_image(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_image(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_is_locked(&self) -> bool {
        unsafe {
            from_glib(light_dm_sys::lightdm_user_get_is_locked(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_language(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_language(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_layout(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_layout(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_layouts(&self) -> Vec<GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(light_dm_sys::lightdm_user_get_layouts(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_logged_in(&self) -> bool {
        unsafe {
            from_glib(light_dm_sys::lightdm_user_get_logged_in(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_name(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_name(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_real_name(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_real_name(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_session(&self) -> Option<GString> {
        unsafe {
            from_glib_none(light_dm_sys::lightdm_user_get_session(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_uid(&self) -> u32 {
        unsafe { light_dm_sys::lightdm_user_get_uid(self.as_ref().to_glib_none().0) }
    }

    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn changed_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"changed\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    changed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_background_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_background_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::background\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_background_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_display_name_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_display_name_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::display-name\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_display_name_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_has_messages_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_has_messages_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::has-messages\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_has_messages_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_home_directory_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_home_directory_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::home-directory\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_home_directory_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_image_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_image_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::image\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_image_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_is_locked_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_is_locked_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::is-locked\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_is_locked_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_language_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_language_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::language\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_language_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_layout_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::layout\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_layout_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_layouts_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_layouts_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::layouts\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_layouts_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_logged_in_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_logged_in_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::logged-in\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_logged_in_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_name_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::name\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_name_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_real_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_real_name_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::real-name\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_real_name_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_session_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_session_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::session\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_session_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_uid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_uid_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut light_dm_sys::LightDMUser,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<User>,
        {
            let f: &F = &*(f as *const F);
            f(&User::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::uid\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_uid_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl fmt::Display for User {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "User")
    }
}
