// 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 gdk_pixbuf_sys;
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 std::fmt;

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
pub enum Colorspace {
    Rgb,
    #[doc(hidden)]
    __Unknown(i32),
}

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

#[doc(hidden)]
impl ToGlib for Colorspace {
    type GlibType = gdk_pixbuf_sys::GdkColorspace;

    fn to_glib(&self) -> gdk_pixbuf_sys::GdkColorspace {
        match *self {
            Colorspace::Rgb => gdk_pixbuf_sys::GDK_COLORSPACE_RGB,
            Colorspace::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gdk_pixbuf_sys::GdkColorspace> for Colorspace {
    fn from_glib(value: gdk_pixbuf_sys::GdkColorspace) -> Self {
        match value {
            0 => Colorspace::Rgb,
            value => Colorspace::__Unknown(value),
        }
    }
}

impl StaticType for Colorspace {
    fn static_type() -> Type {
        unsafe { from_glib(gdk_pixbuf_sys::gdk_colorspace_get_type()) }
    }
}

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

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

impl SetValue for Colorspace {
    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)]
pub enum InterpType {
    Nearest,
    Tiles,
    Bilinear,
    Hyper,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for InterpType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "InterpType::{}",
            match *self {
                InterpType::Nearest => "Nearest",
                InterpType::Tiles => "Tiles",
                InterpType::Bilinear => "Bilinear",
                InterpType::Hyper => "Hyper",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for InterpType {
    type GlibType = gdk_pixbuf_sys::GdkInterpType;

    fn to_glib(&self) -> gdk_pixbuf_sys::GdkInterpType {
        match *self {
            InterpType::Nearest => gdk_pixbuf_sys::GDK_INTERP_NEAREST,
            InterpType::Tiles => gdk_pixbuf_sys::GDK_INTERP_TILES,
            InterpType::Bilinear => gdk_pixbuf_sys::GDK_INTERP_BILINEAR,
            InterpType::Hyper => gdk_pixbuf_sys::GDK_INTERP_HYPER,
            InterpType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gdk_pixbuf_sys::GdkInterpType> for InterpType {
    fn from_glib(value: gdk_pixbuf_sys::GdkInterpType) -> Self {
        match value {
            0 => InterpType::Nearest,
            1 => InterpType::Tiles,
            2 => InterpType::Bilinear,
            3 => InterpType::Hyper,
            value => InterpType::__Unknown(value),
        }
    }
}

impl StaticType for InterpType {
    fn static_type() -> Type {
        unsafe { from_glib(gdk_pixbuf_sys::gdk_interp_type_get_type()) }
    }
}

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

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

impl SetValue for InterpType {
    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)]
pub enum PixbufAlphaMode {
    Bilevel,
    Full,
    #[doc(hidden)]
    __Unknown(i32),
}

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

#[doc(hidden)]
impl ToGlib for PixbufAlphaMode {
    type GlibType = gdk_pixbuf_sys::GdkPixbufAlphaMode;

    fn to_glib(&self) -> gdk_pixbuf_sys::GdkPixbufAlphaMode {
        match *self {
            PixbufAlphaMode::Bilevel => gdk_pixbuf_sys::GDK_PIXBUF_ALPHA_BILEVEL,
            PixbufAlphaMode::Full => gdk_pixbuf_sys::GDK_PIXBUF_ALPHA_FULL,
            PixbufAlphaMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gdk_pixbuf_sys::GdkPixbufAlphaMode> for PixbufAlphaMode {
    fn from_glib(value: gdk_pixbuf_sys::GdkPixbufAlphaMode) -> Self {
        match value {
            0 => PixbufAlphaMode::Bilevel,
            1 => PixbufAlphaMode::Full,
            value => PixbufAlphaMode::__Unknown(value),
        }
    }
}

impl StaticType for PixbufAlphaMode {
    fn static_type() -> Type {
        unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_alpha_mode_get_type()) }
    }
}

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

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

impl SetValue for PixbufAlphaMode {
    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)]
pub enum PixbufError {
    CorruptImage,
    InsufficientMemory,
    BadOption,
    UnknownType,
    UnsupportedOperation,
    Failed,
    IncompleteAnimation,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PixbufError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PixbufError::{}",
            match *self {
                PixbufError::CorruptImage => "CorruptImage",
                PixbufError::InsufficientMemory => "InsufficientMemory",
                PixbufError::BadOption => "BadOption",
                PixbufError::UnknownType => "UnknownType",
                PixbufError::UnsupportedOperation => "UnsupportedOperation",
                PixbufError::Failed => "Failed",
                PixbufError::IncompleteAnimation => "IncompleteAnimation",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PixbufError {
    type GlibType = gdk_pixbuf_sys::GdkPixbufError;

    fn to_glib(&self) -> gdk_pixbuf_sys::GdkPixbufError {
        match *self {
            PixbufError::CorruptImage => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
            PixbufError::InsufficientMemory => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
            PixbufError::BadOption => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_BAD_OPTION,
            PixbufError::UnknownType => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
            PixbufError::UnsupportedOperation => {
                gdk_pixbuf_sys::GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION
            }
            PixbufError::Failed => gdk_pixbuf_sys::GDK_PIXBUF_ERROR_FAILED,
            PixbufError::IncompleteAnimation => {
                gdk_pixbuf_sys::GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION
            }
            PixbufError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gdk_pixbuf_sys::GdkPixbufError> for PixbufError {
    fn from_glib(value: gdk_pixbuf_sys::GdkPixbufError) -> Self {
        match value {
            0 => PixbufError::CorruptImage,
            1 => PixbufError::InsufficientMemory,
            2 => PixbufError::BadOption,
            3 => PixbufError::UnknownType,
            4 => PixbufError::UnsupportedOperation,
            5 => PixbufError::Failed,
            6 => PixbufError::IncompleteAnimation,
            value => PixbufError::__Unknown(value),
        }
    }
}

impl ErrorDomain for PixbufError {
    fn domain() -> Quark {
        unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_error_quark()) }
    }

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

    fn from(code: i32) -> Option<Self> {
        match code {
            0 => Some(PixbufError::CorruptImage),
            1 => Some(PixbufError::InsufficientMemory),
            2 => Some(PixbufError::BadOption),
            3 => Some(PixbufError::UnknownType),
            4 => Some(PixbufError::UnsupportedOperation),
            5 => Some(PixbufError::Failed),
            6 => Some(PixbufError::IncompleteAnimation),
            _ => Some(PixbufError::Failed),
        }
    }
}

impl StaticType for PixbufError {
    fn static_type() -> Type {
        unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_error_get_type()) }
    }
}

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

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

impl SetValue for PixbufError {
    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)]
pub enum PixbufRotation {
    None,
    Counterclockwise,
    Upsidedown,
    Clockwise,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PixbufRotation {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PixbufRotation::{}",
            match *self {
                PixbufRotation::None => "None",
                PixbufRotation::Counterclockwise => "Counterclockwise",
                PixbufRotation::Upsidedown => "Upsidedown",
                PixbufRotation::Clockwise => "Clockwise",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PixbufRotation {
    type GlibType = gdk_pixbuf_sys::GdkPixbufRotation;

    fn to_glib(&self) -> gdk_pixbuf_sys::GdkPixbufRotation {
        match *self {
            PixbufRotation::None => gdk_pixbuf_sys::GDK_PIXBUF_ROTATE_NONE,
            PixbufRotation::Counterclockwise => gdk_pixbuf_sys::GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE,
            PixbufRotation::Upsidedown => gdk_pixbuf_sys::GDK_PIXBUF_ROTATE_UPSIDEDOWN,
            PixbufRotation::Clockwise => gdk_pixbuf_sys::GDK_PIXBUF_ROTATE_CLOCKWISE,
            PixbufRotation::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gdk_pixbuf_sys::GdkPixbufRotation> for PixbufRotation {
    fn from_glib(value: gdk_pixbuf_sys::GdkPixbufRotation) -> Self {
        match value {
            0 => PixbufRotation::None,
            90 => PixbufRotation::Counterclockwise,
            180 => PixbufRotation::Upsidedown,
            270 => PixbufRotation::Clockwise,
            value => PixbufRotation::__Unknown(value),
        }
    }
}

impl StaticType for PixbufRotation {
    fn static_type() -> Type {
        unsafe { from_glib(gdk_pixbuf_sys::gdk_pixbuf_rotation_get_type()) }
    }
}

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

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

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