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

use crate::ffi;
use glib::{bitflags::bitflags, prelude::*, translate::*};

bitflags! {
    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
    #[doc(alias = "RsvgHandleFlags")]
    pub struct HandleFlags: u32 {
        #[doc(alias = "RSVG_HANDLE_FLAGS_NONE")]
        const FLAGS_NONE = ffi::RSVG_HANDLE_FLAGS_NONE as _;
        #[doc(alias = "RSVG_HANDLE_FLAG_UNLIMITED")]
        const FLAG_UNLIMITED = ffi::RSVG_HANDLE_FLAG_UNLIMITED as _;
        #[doc(alias = "RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA")]
        const FLAG_KEEP_IMAGE_DATA = ffi::RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA as _;
    }
}

#[doc(hidden)]
impl IntoGlib for HandleFlags {
    type GlibType = ffi::RsvgHandleFlags;

    #[inline]
    fn into_glib(self) -> ffi::RsvgHandleFlags {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::RsvgHandleFlags> for HandleFlags {
    #[inline]
    unsafe fn from_glib(value: ffi::RsvgHandleFlags) -> Self {
        skip_assert_initialized!();
        Self::from_bits_truncate(value)
    }
}

impl StaticType for HandleFlags {
    #[inline]
    #[doc(alias = "rsvg_handle_flags_get_type")]
    fn static_type() -> glib::Type {
        unsafe { from_glib(ffi::rsvg_handle_flags_get_type()) }
    }
}

impl glib::HasParamSpec for HandleFlags {
    type ParamSpec = glib::ParamSpecFlags;
    type SetValue = Self;
    type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder<Self>;

    fn param_spec_builder() -> Self::BuilderFn {
        Self::ParamSpec::builder
    }
}

impl glib::value::ValueType for HandleFlags {
    type Type = Self;
}

unsafe impl<'a> glib::value::FromValue<'a> for HandleFlags {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    #[inline]
    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        unsafe { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) }
    }
}

impl ToValue for HandleFlags {
    #[inline]
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    #[inline]
    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

impl From<HandleFlags> for glib::Value {
    #[inline]
    fn from(v: HandleFlags) -> Self {
        skip_assert_initialized!();
        ToValue::to_value(&v)
    }
}
