// 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 crate::translate::*;
use crate::value::FromValue;
use crate::value::ToValue;
use crate::StaticType;
use crate::Type;
use bitflags::bitflags;
use std::fmt;

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
bitflags! {
    #[doc(alias = "GFileSetContentsFlags")]
    pub struct FileSetContentsFlags: u32 {
        #[doc(alias = "G_FILE_SET_CONTENTS_NONE")]
        const NONE = ffi::G_FILE_SET_CONTENTS_NONE as u32;
        #[doc(alias = "G_FILE_SET_CONTENTS_CONSISTENT")]
        const CONSISTENT = ffi::G_FILE_SET_CONTENTS_CONSISTENT as u32;
        #[doc(alias = "G_FILE_SET_CONTENTS_DURABLE")]
        const DURABLE = ffi::G_FILE_SET_CONTENTS_DURABLE as u32;
        #[doc(alias = "G_FILE_SET_CONTENTS_ONLY_EXISTING")]
        const ONLY_EXISTING = ffi::G_FILE_SET_CONTENTS_ONLY_EXISTING as u32;
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
impl fmt::Display for FileSetContentsFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl IntoGlib for FileSetContentsFlags {
    type GlibType = ffi::GFileSetContentsFlags;

    fn into_glib(self) -> ffi::GFileSetContentsFlags {
        self.bits()
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl FromGlib<ffi::GFileSetContentsFlags> for FileSetContentsFlags {
    unsafe fn from_glib(value: ffi::GFileSetContentsFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

bitflags! {
    #[doc(alias = "GFileTest")]
    pub struct FileTest: u32 {
        #[doc(alias = "G_FILE_TEST_IS_REGULAR")]
        const IS_REGULAR = ffi::G_FILE_TEST_IS_REGULAR as u32;
        #[doc(alias = "G_FILE_TEST_IS_SYMLINK")]
        const IS_SYMLINK = ffi::G_FILE_TEST_IS_SYMLINK as u32;
        #[doc(alias = "G_FILE_TEST_IS_DIR")]
        const IS_DIR = ffi::G_FILE_TEST_IS_DIR as u32;
        #[doc(alias = "G_FILE_TEST_IS_EXECUTABLE")]
        const IS_EXECUTABLE = ffi::G_FILE_TEST_IS_EXECUTABLE as u32;
        #[doc(alias = "G_FILE_TEST_EXISTS")]
        const EXISTS = ffi::G_FILE_TEST_EXISTS as u32;
    }
}

impl fmt::Display for FileTest {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

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

    fn into_glib(self) -> ffi::GFileTest {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GFileTest> for FileTest {
    unsafe fn from_glib(value: ffi::GFileTest) -> Self {
        Self::from_bits_truncate(value)
    }
}

bitflags! {
    #[doc(alias = "GFormatSizeFlags")]
    pub struct FormatSizeFlags: u32 {
        #[doc(alias = "G_FORMAT_SIZE_DEFAULT")]
        const DEFAULT = ffi::G_FORMAT_SIZE_DEFAULT as u32;
        #[doc(alias = "G_FORMAT_SIZE_LONG_FORMAT")]
        const LONG_FORMAT = ffi::G_FORMAT_SIZE_LONG_FORMAT as u32;
        #[doc(alias = "G_FORMAT_SIZE_IEC_UNITS")]
        const IEC_UNITS = ffi::G_FORMAT_SIZE_IEC_UNITS as u32;
        #[doc(alias = "G_FORMAT_SIZE_BITS")]
        const BITS = ffi::G_FORMAT_SIZE_BITS as u32;
    }
}

impl fmt::Display for FormatSizeFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

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

    fn into_glib(self) -> ffi::GFormatSizeFlags {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GFormatSizeFlags> for FormatSizeFlags {
    unsafe fn from_glib(value: ffi::GFormatSizeFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

bitflags! {
    #[doc(alias = "GIOCondition")]
    pub struct IOCondition: u32 {
        #[doc(alias = "G_IO_IN")]
        const IN = ffi::G_IO_IN as u32;
        #[doc(alias = "G_IO_OUT")]
        const OUT = ffi::G_IO_OUT as u32;
        #[doc(alias = "G_IO_PRI")]
        const PRI = ffi::G_IO_PRI as u32;
        #[doc(alias = "G_IO_ERR")]
        const ERR = ffi::G_IO_ERR as u32;
        #[doc(alias = "G_IO_HUP")]
        const HUP = ffi::G_IO_HUP as u32;
        #[doc(alias = "G_IO_NVAL")]
        const NVAL = ffi::G_IO_NVAL as u32;
    }
}

impl fmt::Display for IOCondition {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

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

    fn into_glib(self) -> ffi::GIOCondition {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GIOCondition> for IOCondition {
    unsafe fn from_glib(value: ffi::GIOCondition) -> Self {
        Self::from_bits_truncate(value)
    }
}

impl StaticType for IOCondition {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::g_io_condition_get_type()) }
    }
}

impl crate::value::ValueType for IOCondition {
    type Type = Self;
}

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

    unsafe fn from_value(value: &'a crate::Value) -> Self {
        from_glib(crate::gobject_ffi::g_value_get_flags(
            value.to_glib_none().0,
        ))
    }
}

impl ToValue for IOCondition {
    fn to_value(&self) -> crate::Value {
        let mut value = crate::Value::for_value_type::<Self>();
        unsafe {
            crate::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> crate::Type {
        Self::static_type()
    }
}

bitflags! {
    #[doc(alias = "GKeyFileFlags")]
    pub struct KeyFileFlags: u32 {
        #[doc(alias = "G_KEY_FILE_NONE")]
        const NONE = ffi::G_KEY_FILE_NONE as u32;
        #[doc(alias = "G_KEY_FILE_KEEP_COMMENTS")]
        const KEEP_COMMENTS = ffi::G_KEY_FILE_KEEP_COMMENTS as u32;
        #[doc(alias = "G_KEY_FILE_KEEP_TRANSLATIONS")]
        const KEEP_TRANSLATIONS = ffi::G_KEY_FILE_KEEP_TRANSLATIONS as u32;
    }
}

impl fmt::Display for KeyFileFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

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

    fn into_glib(self) -> ffi::GKeyFileFlags {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GKeyFileFlags> for KeyFileFlags {
    unsafe fn from_glib(value: ffi::GKeyFileFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

bitflags! {
    #[doc(alias = "GLogLevelFlags")]
    pub struct LogLevelFlags: u32 {
        #[doc(alias = "G_LOG_FLAG_RECURSION")]
        const FLAG_RECURSION = ffi::G_LOG_FLAG_RECURSION as u32;
        #[doc(alias = "G_LOG_FLAG_FATAL")]
        const FLAG_FATAL = ffi::G_LOG_FLAG_FATAL as u32;
        #[doc(alias = "G_LOG_LEVEL_ERROR")]
        const LEVEL_ERROR = ffi::G_LOG_LEVEL_ERROR as u32;
        #[doc(alias = "G_LOG_LEVEL_CRITICAL")]
        const LEVEL_CRITICAL = ffi::G_LOG_LEVEL_CRITICAL as u32;
        #[doc(alias = "G_LOG_LEVEL_WARNING")]
        const LEVEL_WARNING = ffi::G_LOG_LEVEL_WARNING as u32;
        #[doc(alias = "G_LOG_LEVEL_MESSAGE")]
        const LEVEL_MESSAGE = ffi::G_LOG_LEVEL_MESSAGE as u32;
        #[doc(alias = "G_LOG_LEVEL_INFO")]
        const LEVEL_INFO = ffi::G_LOG_LEVEL_INFO as u32;
        #[doc(alias = "G_LOG_LEVEL_DEBUG")]
        const LEVEL_DEBUG = ffi::G_LOG_LEVEL_DEBUG as u32;
        #[doc(alias = "G_LOG_LEVEL_MASK")]
        const LEVEL_MASK = ffi::G_LOG_LEVEL_MASK as u32;
    }
}

impl fmt::Display for LogLevelFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

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

    fn into_glib(self) -> ffi::GLogLevelFlags {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GLogLevelFlags> for LogLevelFlags {
    unsafe fn from_glib(value: ffi::GLogLevelFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

bitflags! {
    #[doc(alias = "GOptionFlags")]
    pub struct OptionFlags: u32 {
        #[doc(alias = "G_OPTION_FLAG_NONE")]
        const NONE = ffi::G_OPTION_FLAG_NONE as u32;
        #[doc(alias = "G_OPTION_FLAG_HIDDEN")]
        const HIDDEN = ffi::G_OPTION_FLAG_HIDDEN as u32;
        #[doc(alias = "G_OPTION_FLAG_IN_MAIN")]
        const IN_MAIN = ffi::G_OPTION_FLAG_IN_MAIN as u32;
        #[doc(alias = "G_OPTION_FLAG_REVERSE")]
        const REVERSE = ffi::G_OPTION_FLAG_REVERSE as u32;
        #[doc(alias = "G_OPTION_FLAG_NO_ARG")]
        const NO_ARG = ffi::G_OPTION_FLAG_NO_ARG as u32;
        #[doc(alias = "G_OPTION_FLAG_FILENAME")]
        const FILENAME = ffi::G_OPTION_FLAG_FILENAME as u32;
        #[doc(alias = "G_OPTION_FLAG_OPTIONAL_ARG")]
        const OPTIONAL_ARG = ffi::G_OPTION_FLAG_OPTIONAL_ARG as u32;
        #[doc(alias = "G_OPTION_FLAG_NOALIAS")]
        const NOALIAS = ffi::G_OPTION_FLAG_NOALIAS as u32;
    }
}

impl fmt::Display for OptionFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

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

    fn into_glib(self) -> ffi::GOptionFlags {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GOptionFlags> for OptionFlags {
    unsafe fn from_glib(value: ffi::GOptionFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

bitflags! {
    #[doc(alias = "GSpawnFlags")]
    pub struct SpawnFlags: u32 {
        #[doc(alias = "G_SPAWN_DEFAULT")]
        const DEFAULT = ffi::G_SPAWN_DEFAULT as u32;
        #[doc(alias = "G_SPAWN_LEAVE_DESCRIPTORS_OPEN")]
        const LEAVE_DESCRIPTORS_OPEN = ffi::G_SPAWN_LEAVE_DESCRIPTORS_OPEN as u32;
        #[doc(alias = "G_SPAWN_DO_NOT_REAP_CHILD")]
        const DO_NOT_REAP_CHILD = ffi::G_SPAWN_DO_NOT_REAP_CHILD as u32;
        #[doc(alias = "G_SPAWN_SEARCH_PATH")]
        const SEARCH_PATH = ffi::G_SPAWN_SEARCH_PATH as u32;
        #[doc(alias = "G_SPAWN_STDOUT_TO_DEV_NULL")]
        const STDOUT_TO_DEV_NULL = ffi::G_SPAWN_STDOUT_TO_DEV_NULL as u32;
        #[doc(alias = "G_SPAWN_STDERR_TO_DEV_NULL")]
        const STDERR_TO_DEV_NULL = ffi::G_SPAWN_STDERR_TO_DEV_NULL as u32;
        #[doc(alias = "G_SPAWN_CHILD_INHERITS_STDIN")]
        const CHILD_INHERITS_STDIN = ffi::G_SPAWN_CHILD_INHERITS_STDIN as u32;
        #[doc(alias = "G_SPAWN_FILE_AND_ARGV_ZERO")]
        const FILE_AND_ARGV_ZERO = ffi::G_SPAWN_FILE_AND_ARGV_ZERO as u32;
        #[doc(alias = "G_SPAWN_SEARCH_PATH_FROM_ENVP")]
        const SEARCH_PATH_FROM_ENVP = ffi::G_SPAWN_SEARCH_PATH_FROM_ENVP as u32;
        #[doc(alias = "G_SPAWN_CLOEXEC_PIPES")]
        const CLOEXEC_PIPES = ffi::G_SPAWN_CLOEXEC_PIPES as u32;
    }
}

impl fmt::Display for SpawnFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

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

    fn into_glib(self) -> ffi::GSpawnFlags {
        self.bits()
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GSpawnFlags> for SpawnFlags {
    unsafe fn from_glib(value: ffi::GSpawnFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
bitflags! {
    #[doc(alias = "GUriFlags")]
    pub struct UriFlags: u32 {
        #[doc(alias = "G_URI_FLAGS_NONE")]
        const NONE = ffi::G_URI_FLAGS_NONE as u32;
        #[doc(alias = "G_URI_FLAGS_PARSE_RELAXED")]
        const PARSE_RELAXED = ffi::G_URI_FLAGS_PARSE_RELAXED as u32;
        #[doc(alias = "G_URI_FLAGS_HAS_PASSWORD")]
        const HAS_PASSWORD = ffi::G_URI_FLAGS_HAS_PASSWORD as u32;
        #[doc(alias = "G_URI_FLAGS_HAS_AUTH_PARAMS")]
        const HAS_AUTH_PARAMS = ffi::G_URI_FLAGS_HAS_AUTH_PARAMS as u32;
        #[doc(alias = "G_URI_FLAGS_ENCODED")]
        const ENCODED = ffi::G_URI_FLAGS_ENCODED as u32;
        #[doc(alias = "G_URI_FLAGS_NON_DNS")]
        const NON_DNS = ffi::G_URI_FLAGS_NON_DNS as u32;
        #[doc(alias = "G_URI_FLAGS_ENCODED_QUERY")]
        const ENCODED_QUERY = ffi::G_URI_FLAGS_ENCODED_QUERY as u32;
        #[doc(alias = "G_URI_FLAGS_ENCODED_PATH")]
        const ENCODED_PATH = ffi::G_URI_FLAGS_ENCODED_PATH as u32;
        #[doc(alias = "G_URI_FLAGS_ENCODED_FRAGMENT")]
        const ENCODED_FRAGMENT = ffi::G_URI_FLAGS_ENCODED_FRAGMENT as u32;
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
impl fmt::Display for UriFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl IntoGlib for UriFlags {
    type GlibType = ffi::GUriFlags;

    fn into_glib(self) -> ffi::GUriFlags {
        self.bits()
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl FromGlib<ffi::GUriFlags> for UriFlags {
    unsafe fn from_glib(value: ffi::GUriFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
bitflags! {
    #[doc(alias = "GUriHideFlags")]
    pub struct UriHideFlags: u32 {
        #[doc(alias = "G_URI_HIDE_NONE")]
        const NONE = ffi::G_URI_HIDE_NONE as u32;
        #[doc(alias = "G_URI_HIDE_USERINFO")]
        const USERINFO = ffi::G_URI_HIDE_USERINFO as u32;
        #[doc(alias = "G_URI_HIDE_PASSWORD")]
        const PASSWORD = ffi::G_URI_HIDE_PASSWORD as u32;
        #[doc(alias = "G_URI_HIDE_AUTH_PARAMS")]
        const AUTH_PARAMS = ffi::G_URI_HIDE_AUTH_PARAMS as u32;
        #[doc(alias = "G_URI_HIDE_QUERY")]
        const QUERY = ffi::G_URI_HIDE_QUERY as u32;
        #[doc(alias = "G_URI_HIDE_FRAGMENT")]
        const FRAGMENT = ffi::G_URI_HIDE_FRAGMENT as u32;
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
impl fmt::Display for UriHideFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl IntoGlib for UriHideFlags {
    type GlibType = ffi::GUriHideFlags;

    fn into_glib(self) -> ffi::GUriHideFlags {
        self.bits()
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl FromGlib<ffi::GUriHideFlags> for UriHideFlags {
    unsafe fn from_glib(value: ffi::GUriHideFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
bitflags! {
    #[doc(alias = "GUriParamsFlags")]
    pub struct UriParamsFlags: u32 {
        #[doc(alias = "G_URI_PARAMS_NONE")]
        const NONE = ffi::G_URI_PARAMS_NONE as u32;
        #[doc(alias = "G_URI_PARAMS_CASE_INSENSITIVE")]
        const CASE_INSENSITIVE = ffi::G_URI_PARAMS_CASE_INSENSITIVE as u32;
        #[doc(alias = "G_URI_PARAMS_WWW_FORM")]
        const WWW_FORM = ffi::G_URI_PARAMS_WWW_FORM as u32;
        #[doc(alias = "G_URI_PARAMS_PARSE_RELAXED")]
        const PARSE_RELAXED = ffi::G_URI_PARAMS_PARSE_RELAXED as u32;
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
impl fmt::Display for UriParamsFlags {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        <Self as fmt::Debug>::fmt(self, f)
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl IntoGlib for UriParamsFlags {
    type GlibType = ffi::GUriParamsFlags;

    fn into_glib(self) -> ffi::GUriParamsFlags {
        self.bits()
    }
}

#[cfg(any(feature = "v2_66", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl FromGlib<ffi::GUriParamsFlags> for UriParamsFlags {
    unsafe fn from_glib(value: ffi::GUriParamsFlags) -> Self {
        Self::from_bits_truncate(value)
    }
}
