{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

An AtkStateSet is a read-only representation of the full set of @/AtkStates/@
that apply to an object at a given time. This set is not meant to be
modified, but rather created when @/atk_object_ref_state_set/@() is called.
-}

module GI.Atk.Objects.StateSet
    ( 

-- * Exported types
    StateSet(..)                            ,
    IsStateSet                              ,
    toStateSet                              ,
    noStateSet                              ,


 -- * Methods
-- ** addState #method:addState#
    StateSetAddStateMethodInfo              ,
    stateSetAddState                        ,


-- ** addStates #method:addStates#
    StateSetAddStatesMethodInfo             ,
    stateSetAddStates                       ,


-- ** andSets #method:andSets#
    StateSetAndSetsMethodInfo               ,
    stateSetAndSets                         ,


-- ** clearStates #method:clearStates#
    StateSetClearStatesMethodInfo           ,
    stateSetClearStates                     ,


-- ** containsState #method:containsState#
    StateSetContainsStateMethodInfo         ,
    stateSetContainsState                   ,


-- ** containsStates #method:containsStates#
    StateSetContainsStatesMethodInfo        ,
    stateSetContainsStates                  ,


-- ** isEmpty #method:isEmpty#
    StateSetIsEmptyMethodInfo               ,
    stateSetIsEmpty                         ,


-- ** new #method:new#
    stateSetNew                             ,


-- ** orSets #method:orSets#
    StateSetOrSetsMethodInfo                ,
    stateSetOrSets                          ,


-- ** removeState #method:removeState#
    StateSetRemoveStateMethodInfo           ,
    stateSetRemoveState                     ,


-- ** xorSets #method:xorSets#
    StateSetXorSetsMethodInfo               ,
    stateSetXorSets                         ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import {-# SOURCE #-} qualified GI.Atk.Enums as Atk.Enums
import qualified GI.GObject.Objects.Object as GObject.Object

newtype StateSet = StateSet (ManagedPtr StateSet)
foreign import ccall "atk_state_set_get_type"
    c_atk_state_set_get_type :: IO GType

instance GObject StateSet where
    gobjectType _ = c_atk_state_set_get_type
    

class GObject o => IsStateSet o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError StateSet a) =>
    IsStateSet a
#endif
instance IsStateSet StateSet
instance GObject.Object.IsObject StateSet

toStateSet :: IsStateSet o => o -> IO StateSet
toStateSet = unsafeCastTo StateSet

noStateSet :: Maybe StateSet
noStateSet = Nothing

type family ResolveStateSetMethod (t :: Symbol) (o :: *) :: * where
    ResolveStateSetMethod "addState" o = StateSetAddStateMethodInfo
    ResolveStateSetMethod "addStates" o = StateSetAddStatesMethodInfo
    ResolveStateSetMethod "andSets" o = StateSetAndSetsMethodInfo
    ResolveStateSetMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveStateSetMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveStateSetMethod "clearStates" o = StateSetClearStatesMethodInfo
    ResolveStateSetMethod "containsState" o = StateSetContainsStateMethodInfo
    ResolveStateSetMethod "containsStates" o = StateSetContainsStatesMethodInfo
    ResolveStateSetMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveStateSetMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveStateSetMethod "isEmpty" o = StateSetIsEmptyMethodInfo
    ResolveStateSetMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveStateSetMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveStateSetMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveStateSetMethod "orSets" o = StateSetOrSetsMethodInfo
    ResolveStateSetMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveStateSetMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveStateSetMethod "removeState" o = StateSetRemoveStateMethodInfo
    ResolveStateSetMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveStateSetMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveStateSetMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveStateSetMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveStateSetMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveStateSetMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveStateSetMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveStateSetMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveStateSetMethod "xorSets" o = StateSetXorSetsMethodInfo
    ResolveStateSetMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveStateSetMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveStateSetMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveStateSetMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveStateSetMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveStateSetMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveStateSetMethod t StateSet, O.MethodInfo info StateSet p) => O.IsLabelProxy t (StateSet -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveStateSetMethod t StateSet, O.MethodInfo info StateSet p) => O.IsLabel t (StateSet -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

instance O.HasAttributeList StateSet
type instance O.AttributeList StateSet = StateSetAttributeList
type StateSetAttributeList = ('[ ] :: [(Symbol, *)])

type instance O.SignalList StateSet = StateSetSignalList
type StateSetSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method StateSet::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "StateSet"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_new" atk_state_set_new :: 
    IO (Ptr StateSet)

{- |
Creates a new empty state set.
-}
stateSetNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m StateSet
    {- ^ __Returns:__ a new 'GI.Atk.Objects.StateSet.StateSet' -}
stateSetNew  = liftIO $ do
    result <- atk_state_set_new
    checkUnexpectedReturnNULL "stateSetNew" result
    result' <- (wrapObject StateSet) result
    return result'

-- method StateSet::add_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Atk", name = "StateType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_add_state" atk_state_set_add_state :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    CUInt ->                                -- type : TInterface (Name {namespace = "Atk", name = "StateType"})
    IO CInt

{- |
Adds the state of the specified type to the state set if it is not already
present.

Note that because an 'GI.Atk.Objects.StateSet.StateSet' is a read-only object, this method should
be used to add a state to a newly-created set which will then be returned by
@/atk_object_ref_state_set/@. It should not be used to modify the existing state
of an object. See also @/atk_object_notify_state_change/@.
-}
stateSetAddState ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> Atk.Enums.StateType
    {- ^ /@type@/: an 'GI.Atk.Enums.StateType' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if  the state for /@type@/ is not already in /@set@/. -}
stateSetAddState set type_ = liftIO $ do
    set' <- unsafeManagedPtrCastPtr set
    let type_' = (fromIntegral . fromEnum) type_
    result <- atk_state_set_add_state set' type_'
    let result' = (/= 0) result
    touchManagedPtr set
    return result'

data StateSetAddStateMethodInfo
instance (signature ~ (Atk.Enums.StateType -> m Bool), MonadIO m, IsStateSet a) => O.MethodInfo StateSetAddStateMethodInfo a signature where
    overloadedMethod _ = stateSetAddState

-- method StateSet::add_states
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "types", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "Atk", name = "StateType"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an array of #AtkStateType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_types", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of elements in the array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "n_types", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of elements in the array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_add_states" atk_state_set_add_states :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    Ptr CUInt ->                            -- types : TCArray False (-1) 2 (TInterface (Name {namespace = "Atk", name = "StateType"}))
    Int32 ->                                -- n_types : TBasicType TInt
    IO ()

{- |
Adds the states of the specified types to the state set.

Note that because an 'GI.Atk.Objects.StateSet.StateSet' is a read-only object, this method should
be used to add states to a newly-created set which will then be returned by
@/atk_object_ref_state_set/@. It should not be used to modify the existing state
of an object. See also @/atk_object_notify_state_change/@.
-}
stateSetAddStates ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> [Atk.Enums.StateType]
    {- ^ /@types@/: an array of 'GI.Atk.Enums.StateType' -}
    -> m ()
stateSetAddStates set types = liftIO $ do
    let nTypes = fromIntegral $ length types
    set' <- unsafeManagedPtrCastPtr set
    let types' = map (fromIntegral . fromEnum) types
    types'' <- packStorableArray types'
    atk_state_set_add_states set' types'' nTypes
    touchManagedPtr set
    freeMem types''
    return ()

data StateSetAddStatesMethodInfo
instance (signature ~ ([Atk.Enums.StateType] -> m ()), MonadIO m, IsStateSet a) => O.MethodInfo StateSetAddStatesMethodInfo a signature where
    overloadedMethod _ = stateSetAddStates

-- method StateSet::and_sets
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "compare_set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "StateSet"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_and_sets" atk_state_set_and_sets :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    Ptr StateSet ->                         -- compare_set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    IO (Ptr StateSet)

{- |
Constructs the intersection of the two sets, returning 'Nothing' if the
intersection is empty.
-}
stateSetAndSets ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a, IsStateSet b) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> b
    {- ^ /@compareSet@/: another 'GI.Atk.Objects.StateSet.StateSet' -}
    -> m StateSet
    {- ^ __Returns:__ a new 'GI.Atk.Objects.StateSet.StateSet' which is the intersection of
the two sets. -}
stateSetAndSets set compareSet = liftIO $ do
    set' <- unsafeManagedPtrCastPtr set
    compareSet' <- unsafeManagedPtrCastPtr compareSet
    result <- atk_state_set_and_sets set' compareSet'
    checkUnexpectedReturnNULL "stateSetAndSets" result
    result' <- (wrapObject StateSet) result
    touchManagedPtr set
    touchManagedPtr compareSet
    return result'

data StateSetAndSetsMethodInfo
instance (signature ~ (b -> m StateSet), MonadIO m, IsStateSet a, IsStateSet b) => O.MethodInfo StateSetAndSetsMethodInfo a signature where
    overloadedMethod _ = stateSetAndSets

-- method StateSet::clear_states
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_clear_states" atk_state_set_clear_states :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    IO ()

{- |
Removes all states from the state set.
-}
stateSetClearStates ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> m ()
stateSetClearStates set = liftIO $ do
    set' <- unsafeManagedPtrCastPtr set
    atk_state_set_clear_states set'
    touchManagedPtr set
    return ()

data StateSetClearStatesMethodInfo
instance (signature ~ (m ()), MonadIO m, IsStateSet a) => O.MethodInfo StateSetClearStatesMethodInfo a signature where
    overloadedMethod _ = stateSetClearStates

-- method StateSet::contains_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Atk", name = "StateType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_contains_state" atk_state_set_contains_state :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    CUInt ->                                -- type : TInterface (Name {namespace = "Atk", name = "StateType"})
    IO CInt

{- |
Checks whether the state for the specified type is in the specified set.
-}
stateSetContainsState ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> Atk.Enums.StateType
    {- ^ /@type@/: an 'GI.Atk.Enums.StateType' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@type@/ is the state type is in /@set@/. -}
stateSetContainsState set type_ = liftIO $ do
    set' <- unsafeManagedPtrCastPtr set
    let type_' = (fromIntegral . fromEnum) type_
    result <- atk_state_set_contains_state set' type_'
    let result' = (/= 0) result
    touchManagedPtr set
    return result'

data StateSetContainsStateMethodInfo
instance (signature ~ (Atk.Enums.StateType -> m Bool), MonadIO m, IsStateSet a) => O.MethodInfo StateSetContainsStateMethodInfo a signature where
    overloadedMethod _ = stateSetContainsState

-- method StateSet::contains_states
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "types", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "Atk", name = "StateType"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an array of #AtkStateType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n_types", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of elements in the array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "n_types", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of elements in the array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_contains_states" atk_state_set_contains_states :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    Ptr CUInt ->                            -- types : TCArray False (-1) 2 (TInterface (Name {namespace = "Atk", name = "StateType"}))
    Int32 ->                                -- n_types : TBasicType TInt
    IO CInt

{- |
Checks whether the states for all the specified types are in the
specified set.
-}
stateSetContainsStates ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> [Atk.Enums.StateType]
    {- ^ /@types@/: an array of 'GI.Atk.Enums.StateType' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if all the states for /@type@/ are in /@set@/. -}
stateSetContainsStates set types = liftIO $ do
    let nTypes = fromIntegral $ length types
    set' <- unsafeManagedPtrCastPtr set
    let types' = map (fromIntegral . fromEnum) types
    types'' <- packStorableArray types'
    result <- atk_state_set_contains_states set' types'' nTypes
    let result' = (/= 0) result
    touchManagedPtr set
    freeMem types''
    return result'

data StateSetContainsStatesMethodInfo
instance (signature ~ ([Atk.Enums.StateType] -> m Bool), MonadIO m, IsStateSet a) => O.MethodInfo StateSetContainsStatesMethodInfo a signature where
    overloadedMethod _ = stateSetContainsStates

-- method StateSet::is_empty
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_is_empty" atk_state_set_is_empty :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    IO CInt

{- |
Checks whether the state set is empty, i.e. has no states set.
-}
stateSetIsEmpty ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Enums.StateType' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@set@/ has no states set, otherwise 'False' -}
stateSetIsEmpty set = liftIO $ do
    set' <- unsafeManagedPtrCastPtr set
    result <- atk_state_set_is_empty set'
    let result' = (/= 0) result
    touchManagedPtr set
    return result'

data StateSetIsEmptyMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsStateSet a) => O.MethodInfo StateSetIsEmptyMethodInfo a signature where
    overloadedMethod _ = stateSetIsEmpty

-- method StateSet::or_sets
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "compare_set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "StateSet"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_or_sets" atk_state_set_or_sets :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    Ptr StateSet ->                         -- compare_set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    IO (Ptr StateSet)

{- |
Constructs the union of the two sets.
-}
stateSetOrSets ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a, IsStateSet b) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> b
    {- ^ /@compareSet@/: another 'GI.Atk.Objects.StateSet.StateSet' -}
    -> m (Maybe StateSet)
    {- ^ __Returns:__ a new 'GI.Atk.Objects.StateSet.StateSet' which is
the union of the two sets, returning 'Nothing' is empty. -}
stateSetOrSets set compareSet = liftIO $ do
    set' <- unsafeManagedPtrCastPtr set
    compareSet' <- unsafeManagedPtrCastPtr compareSet
    result <- atk_state_set_or_sets set' compareSet'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject StateSet) result'
        return result''
    touchManagedPtr set
    touchManagedPtr compareSet
    return maybeResult

data StateSetOrSetsMethodInfo
instance (signature ~ (b -> m (Maybe StateSet)), MonadIO m, IsStateSet a, IsStateSet b) => O.MethodInfo StateSetOrSetsMethodInfo a signature where
    overloadedMethod _ = stateSetOrSets

-- method StateSet::remove_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Atk", name = "StateType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_remove_state" atk_state_set_remove_state :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    CUInt ->                                -- type : TInterface (Name {namespace = "Atk", name = "StateType"})
    IO CInt

{- |
Removes the state for the specified type from the state set.

Note that because an 'GI.Atk.Objects.StateSet.StateSet' is a read-only object, this method should
be used to remove a state to a newly-created set which will then be returned
by @/atk_object_ref_state_set/@. It should not be used to modify the existing
state of an object. See also @/atk_object_notify_state_change/@.
-}
stateSetRemoveState ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> Atk.Enums.StateType
    {- ^ /@type@/: an @/AtkType/@ -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@type@/ was the state type is in /@set@/. -}
stateSetRemoveState set type_ = liftIO $ do
    set' <- unsafeManagedPtrCastPtr set
    let type_' = (fromIntegral . fromEnum) type_
    result <- atk_state_set_remove_state set' type_'
    let result' = (/= 0) result
    touchManagedPtr set
    return result'

data StateSetRemoveStateMethodInfo
instance (signature ~ (Atk.Enums.StateType -> m Bool), MonadIO m, IsStateSet a) => O.MethodInfo StateSetRemoveStateMethodInfo a signature where
    overloadedMethod _ = stateSetRemoveState

-- method StateSet::xor_sets
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "compare_set", argType = TInterface (Name {namespace = "Atk", name = "StateSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #AtkStateSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "StateSet"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_state_set_xor_sets" atk_state_set_xor_sets :: 
    Ptr StateSet ->                         -- set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    Ptr StateSet ->                         -- compare_set : TInterface (Name {namespace = "Atk", name = "StateSet"})
    IO (Ptr StateSet)

{- |
Constructs the exclusive-or of the two sets, returning 'Nothing' is empty.
The set returned by this operation contains the states in exactly
one of the two sets.
-}
stateSetXorSets ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateSet a, IsStateSet b) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.StateSet.StateSet' -}
    -> b
    {- ^ /@compareSet@/: another 'GI.Atk.Objects.StateSet.StateSet' -}
    -> m StateSet
    {- ^ __Returns:__ a new 'GI.Atk.Objects.StateSet.StateSet' which contains the states
which are in exactly one of the two sets. -}
stateSetXorSets set compareSet = liftIO $ do
    set' <- unsafeManagedPtrCastPtr set
    compareSet' <- unsafeManagedPtrCastPtr compareSet
    result <- atk_state_set_xor_sets set' compareSet'
    checkUnexpectedReturnNULL "stateSetXorSets" result
    result' <- (wrapObject StateSet) result
    touchManagedPtr set
    touchManagedPtr compareSet
    return result'

data StateSetXorSetsMethodInfo
instance (signature ~ (b -> m StateSet), MonadIO m, IsStateSet a, IsStateSet b) => O.MethodInfo StateSetXorSetsMethodInfo a signature where
    overloadedMethod _ = stateSetXorSets