// 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::error::ErrorDomain;
use glib::translate::*;
use glib::value::FromValue;
use glib::value::FromValueOptional;
use glib::value::SetValue;
use glib::value::Value;
use glib::Quark;
use glib::StaticType;
use glib::Type;
use gobject_sys;
use light_dm_sys;
use std::fmt;

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum GreeterError {
    CommunicationError,
    ConnectionFailed,
    SessionFailed,
    NoAutologin,
    InvalidUser,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for GreeterError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "GreeterError::{}",
            match *self {
                GreeterError::CommunicationError => "CommunicationError",
                GreeterError::ConnectionFailed => "ConnectionFailed",
                GreeterError::SessionFailed => "SessionFailed",
                GreeterError::NoAutologin => "NoAutologin",
                GreeterError::InvalidUser => "InvalidUser",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for GreeterError {
    type GlibType = light_dm_sys::LightDMGreeterError;

    fn to_glib(&self) -> light_dm_sys::LightDMGreeterError {
        match *self {
            GreeterError::CommunicationError => {
                light_dm_sys::LIGHTDM_GREETER_ERROR_COMMUNICATION_ERROR
            }
            GreeterError::ConnectionFailed => light_dm_sys::LIGHTDM_GREETER_ERROR_CONNECTION_FAILED,
            GreeterError::SessionFailed => light_dm_sys::LIGHTDM_GREETER_ERROR_SESSION_FAILED,
            GreeterError::NoAutologin => light_dm_sys::LIGHTDM_GREETER_ERROR_NO_AUTOLOGIN,
            GreeterError::InvalidUser => light_dm_sys::LIGHTDM_GREETER_ERROR_INVALID_USER,
            GreeterError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<light_dm_sys::LightDMGreeterError> for GreeterError {
    fn from_glib(value: light_dm_sys::LightDMGreeterError) -> Self {
        match value {
            0 => GreeterError::CommunicationError,
            1 => GreeterError::ConnectionFailed,
            2 => GreeterError::SessionFailed,
            3 => GreeterError::NoAutologin,
            4 => GreeterError::InvalidUser,
            value => GreeterError::__Unknown(value),
        }
    }
}

impl ErrorDomain for GreeterError {
    fn domain() -> Quark {
        unsafe { from_glib(light_dm_sys::lightdm_greeter_error_quark()) }
    }

    fn code(self) -> i32 {
        self.to_glib()
    }

    fn from(code: i32) -> Option<Self> {
        match code {
            0 => Some(GreeterError::CommunicationError),
            1 => Some(GreeterError::ConnectionFailed),
            2 => Some(GreeterError::SessionFailed),
            3 => Some(GreeterError::NoAutologin),
            4 => Some(GreeterError::InvalidUser),
            value => Some(GreeterError::__Unknown(value)),
        }
    }
}

impl StaticType for GreeterError {
    fn static_type() -> Type {
        unsafe { from_glib(light_dm_sys::lightdm_greeter_error_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for GreeterError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for GreeterError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for GreeterError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum MessageType {
    Info,
    Error,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for MessageType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "MessageType::{}",
            match *self {
                MessageType::Info => "Info",
                MessageType::Error => "Error",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for MessageType {
    type GlibType = light_dm_sys::LightDMMessageType;

    fn to_glib(&self) -> light_dm_sys::LightDMMessageType {
        match *self {
            MessageType::Info => light_dm_sys::LIGHTDM_MESSAGE_TYPE_INFO,
            MessageType::Error => light_dm_sys::LIGHTDM_MESSAGE_TYPE_ERROR,
            MessageType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<light_dm_sys::LightDMMessageType> for MessageType {
    fn from_glib(value: light_dm_sys::LightDMMessageType) -> Self {
        match value {
            0 => MessageType::Info,
            1 => MessageType::Error,
            value => MessageType::__Unknown(value),
        }
    }
}

impl StaticType for MessageType {
    fn static_type() -> Type {
        unsafe { from_glib(light_dm_sys::lightdm_message_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for MessageType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for MessageType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for MessageType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PromptType {
    Question,
    Secret,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PromptType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PromptType::{}",
            match *self {
                PromptType::Question => "Question",
                PromptType::Secret => "Secret",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PromptType {
    type GlibType = light_dm_sys::LightDMPromptType;

    fn to_glib(&self) -> light_dm_sys::LightDMPromptType {
        match *self {
            PromptType::Question => light_dm_sys::LIGHTDM_PROMPT_TYPE_QUESTION,
            PromptType::Secret => light_dm_sys::LIGHTDM_PROMPT_TYPE_SECRET,
            PromptType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<light_dm_sys::LightDMPromptType> for PromptType {
    fn from_glib(value: light_dm_sys::LightDMPromptType) -> Self {
        match value {
            0 => PromptType::Question,
            1 => PromptType::Secret,
            value => PromptType::__Unknown(value),
        }
    }
}

impl StaticType for PromptType {
    fn static_type() -> Type {
        unsafe { from_glib(light_dm_sys::lightdm_prompt_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for PromptType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for PromptType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for PromptType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}
