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

The AtkRelationSet held by an object establishes its relationships
with objects beyond the normal \"parent\/child\" hierarchical
relationships that all user interface objects have.
AtkRelationSets establish whether objects are labelled or
controlled by other components, share group membership with other
components (for instance within a radio-button group), or share
content which \"flows\" between them, among other types of possible
relationships.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Atk.Objects.RelationSet
    ( 

-- * Exported types
    RelationSet(..)                         ,
    IsRelationSet                           ,
    toRelationSet                           ,
    noRelationSet                           ,


 -- * Methods
-- ** add #method:add#

#if ENABLE_OVERLOADING
    RelationSetAddMethodInfo                ,
#endif
    relationSetAdd                          ,


-- ** addRelationByType #method:addRelationByType#

#if ENABLE_OVERLOADING
    RelationSetAddRelationByTypeMethodInfo  ,
#endif
    relationSetAddRelationByType            ,


-- ** contains #method:contains#

#if ENABLE_OVERLOADING
    RelationSetContainsMethodInfo           ,
#endif
    relationSetContains                     ,


-- ** containsTarget #method:containsTarget#

#if ENABLE_OVERLOADING
    RelationSetContainsTargetMethodInfo     ,
#endif
    relationSetContainsTarget               ,


-- ** getNRelations #method:getNRelations#

#if ENABLE_OVERLOADING
    RelationSetGetNRelationsMethodInfo      ,
#endif
    relationSetGetNRelations                ,


-- ** getRelation #method:getRelation#

#if ENABLE_OVERLOADING
    RelationSetGetRelationMethodInfo        ,
#endif
    relationSetGetRelation                  ,


-- ** getRelationByType #method:getRelationByType#

#if ENABLE_OVERLOADING
    RelationSetGetRelationByTypeMethodInfo  ,
#endif
    relationSetGetRelationByType            ,


-- ** new #method:new#

    relationSetNew                          ,


-- ** remove #method:remove#

#if ENABLE_OVERLOADING
    RelationSetRemoveMethodInfo             ,
#endif
    relationSetRemove                       ,




    ) 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.GValue as B.GValue
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 {-# SOURCE #-} qualified GI.Atk.Objects.Object as Atk.Object
import {-# SOURCE #-} qualified GI.Atk.Objects.Relation as Atk.Relation
import qualified GI.GObject.Objects.Object as GObject.Object

-- | Memory-managed wrapper type.
newtype RelationSet = RelationSet (ManagedPtr RelationSet)
foreign import ccall "atk_relation_set_get_type"
    c_atk_relation_set_get_type :: IO GType

instance GObject RelationSet where
    gobjectType :: RelationSet -> IO GType
gobjectType _ = IO GType
c_atk_relation_set_get_type
    

-- | Type class for types which can be safely cast to `RelationSet`, for instance with `toRelationSet`.
class GObject o => IsRelationSet o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError RelationSet a) =>
    IsRelationSet a
#endif
instance IsRelationSet RelationSet
instance GObject.Object.IsObject RelationSet

-- | Cast to `RelationSet`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toRelationSet :: (MonadIO m, IsRelationSet o) => o -> m RelationSet
toRelationSet :: o -> m RelationSet
toRelationSet = IO RelationSet -> m RelationSet
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RelationSet -> m RelationSet)
-> (o -> IO RelationSet) -> o -> m RelationSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr RelationSet -> RelationSet) -> o -> IO RelationSet
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr RelationSet -> RelationSet
RelationSet

-- | A convenience alias for `Nothing` :: `Maybe` `RelationSet`.
noRelationSet :: Maybe RelationSet
noRelationSet :: Maybe RelationSet
noRelationSet = Maybe RelationSet
forall a. Maybe a
Nothing

#if ENABLE_OVERLOADING
type family ResolveRelationSetMethod (t :: Symbol) (o :: *) :: * where
    ResolveRelationSetMethod "add" o = RelationSetAddMethodInfo
    ResolveRelationSetMethod "addRelationByType" o = RelationSetAddRelationByTypeMethodInfo
    ResolveRelationSetMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveRelationSetMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveRelationSetMethod "contains" o = RelationSetContainsMethodInfo
    ResolveRelationSetMethod "containsTarget" o = RelationSetContainsTargetMethodInfo
    ResolveRelationSetMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveRelationSetMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveRelationSetMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveRelationSetMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveRelationSetMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveRelationSetMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveRelationSetMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveRelationSetMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveRelationSetMethod "remove" o = RelationSetRemoveMethodInfo
    ResolveRelationSetMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveRelationSetMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveRelationSetMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveRelationSetMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveRelationSetMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveRelationSetMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveRelationSetMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveRelationSetMethod "getNRelations" o = RelationSetGetNRelationsMethodInfo
    ResolveRelationSetMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveRelationSetMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveRelationSetMethod "getRelation" o = RelationSetGetRelationMethodInfo
    ResolveRelationSetMethod "getRelationByType" o = RelationSetGetRelationByTypeMethodInfo
    ResolveRelationSetMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveRelationSetMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveRelationSetMethod l o = O.MethodResolutionFailed l o

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

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

#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList RelationSet
type instance O.AttributeList RelationSet = RelationSetAttributeList
type RelationSetAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList RelationSet = RelationSetSignalList
type RelationSetSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "atk_relation_set_new" atk_relation_set_new :: 
    IO (Ptr RelationSet)

{- |
Creates a new empty relation set.
-}
relationSetNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m RelationSet
    {- ^ __Returns:__ a new 'GI.Atk.Objects.RelationSet.RelationSet' -}
relationSetNew :: m RelationSet
relationSetNew  = IO RelationSet -> m RelationSet
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RelationSet -> m RelationSet)
-> IO RelationSet -> m RelationSet
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
result <- IO (Ptr RelationSet)
atk_relation_set_new
    Text -> Ptr RelationSet -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "relationSetNew" Ptr RelationSet
result
    RelationSet
result' <- ((ManagedPtr RelationSet -> RelationSet)
-> Ptr RelationSet -> IO RelationSet
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr RelationSet -> RelationSet
RelationSet) Ptr RelationSet
result
    RelationSet -> IO RelationSet
forall (m :: * -> *) a. Monad m => a -> m a
return RelationSet
result'

#if ENABLE_OVERLOADING
#endif

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

foreign import ccall "atk_relation_set_add" atk_relation_set_add :: 
    Ptr RelationSet ->                      -- set : TInterface (Name {namespace = "Atk", name = "RelationSet"})
    Ptr Atk.Relation.Relation ->            -- relation : TInterface (Name {namespace = "Atk", name = "Relation"})
    IO ()

{- |
Add a new relation to the current relation set if it is not already
present.
This function ref\'s the AtkRelation so the caller of this function
should unref it to ensure that it will be destroyed when the AtkRelationSet
is destroyed.
-}
relationSetAdd ::
    (B.CallStack.HasCallStack, MonadIO m, IsRelationSet a, Atk.Relation.IsRelation b) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.RelationSet.RelationSet' -}
    -> b
    {- ^ /@relation@/: an 'GI.Atk.Objects.Relation.Relation' -}
    -> m ()
relationSetAdd :: a -> b -> m ()
relationSetAdd set :: a
set relation :: b
relation = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
set' <- a -> IO (Ptr RelationSet)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
set
    Ptr Relation
relation' <- b -> IO (Ptr Relation)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
relation
    Ptr RelationSet -> Ptr Relation -> IO ()
atk_relation_set_add Ptr RelationSet
set' Ptr Relation
relation'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
set
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
relation
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data RelationSetAddMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsRelationSet a, Atk.Relation.IsRelation b) => O.MethodInfo RelationSetAddMethodInfo a signature where
    overloadedMethod _ = relationSetAdd

#endif

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

foreign import ccall "atk_relation_set_add_relation_by_type" atk_relation_set_add_relation_by_type :: 
    Ptr RelationSet ->                      -- set : TInterface (Name {namespace = "Atk", name = "RelationSet"})
    CUInt ->                                -- relationship : TInterface (Name {namespace = "Atk", name = "RelationType"})
    Ptr Atk.Object.Object ->                -- target : TInterface (Name {namespace = "Atk", name = "Object"})
    IO ()

{- |
Add a new relation of the specified type with the specified target to
the current relation set if the relation set does not contain a relation
of that type. If it is does contain a relation of that typea the target
is added to the relation.

/Since: 1.9/
-}
relationSetAddRelationByType ::
    (B.CallStack.HasCallStack, MonadIO m, IsRelationSet a, Atk.Object.IsObject b) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.RelationSet.RelationSet' -}
    -> Atk.Enums.RelationType
    {- ^ /@relationship@/: an 'GI.Atk.Enums.RelationType' -}
    -> b
    {- ^ /@target@/: an 'GI.Atk.Objects.Object.Object' -}
    -> m ()
relationSetAddRelationByType :: a -> RelationType -> b -> m ()
relationSetAddRelationByType set :: a
set relationship :: RelationType
relationship target :: b
target = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
set' <- a -> IO (Ptr RelationSet)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
set
    let relationship' :: CUInt
relationship' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (RelationType -> Int) -> RelationType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelationType -> Int
forall a. Enum a => a -> Int
fromEnum) RelationType
relationship
    Ptr Object
target' <- b -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
target
    Ptr RelationSet -> CUInt -> Ptr Object -> IO ()
atk_relation_set_add_relation_by_type Ptr RelationSet
set' CUInt
relationship' Ptr Object
target'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
set
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
target
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data RelationSetAddRelationByTypeMethodInfo
instance (signature ~ (Atk.Enums.RelationType -> b -> m ()), MonadIO m, IsRelationSet a, Atk.Object.IsObject b) => O.MethodInfo RelationSetAddRelationByTypeMethodInfo a signature where
    overloadedMethod _ = relationSetAddRelationByType

#endif

-- method RelationSet::contains
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "RelationSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkRelationSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "relationship", argType = TInterface (Name {namespace = "Atk", name = "RelationType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkRelationType", 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_relation_set_contains" atk_relation_set_contains :: 
    Ptr RelationSet ->                      -- set : TInterface (Name {namespace = "Atk", name = "RelationSet"})
    CUInt ->                                -- relationship : TInterface (Name {namespace = "Atk", name = "RelationType"})
    IO CInt

{- |
Determines whether the relation set contains a relation that matches the
specified type.
-}
relationSetContains ::
    (B.CallStack.HasCallStack, MonadIO m, IsRelationSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.RelationSet.RelationSet' -}
    -> Atk.Enums.RelationType
    {- ^ /@relationship@/: an 'GI.Atk.Enums.RelationType' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@relationship@/ is the relationship type of a relation
in /@set@/, 'False' otherwise -}
relationSetContains :: a -> RelationType -> m Bool
relationSetContains set :: a
set relationship :: RelationType
relationship = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
set' <- a -> IO (Ptr RelationSet)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
set
    let relationship' :: CUInt
relationship' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (RelationType -> Int) -> RelationType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelationType -> Int
forall a. Enum a => a -> Int
fromEnum) RelationType
relationship
    CInt
result <- Ptr RelationSet -> CUInt -> IO CInt
atk_relation_set_contains Ptr RelationSet
set' CUInt
relationship'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
set
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data RelationSetContainsMethodInfo
instance (signature ~ (Atk.Enums.RelationType -> m Bool), MonadIO m, IsRelationSet a) => O.MethodInfo RelationSetContainsMethodInfo a signature where
    overloadedMethod _ = relationSetContains

#endif

-- method RelationSet::contains_target
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "RelationSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkRelationSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "relationship", argType = TInterface (Name {namespace = "Atk", name = "RelationType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkRelationType", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "Atk", name = "Object"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkObject", 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_relation_set_contains_target" atk_relation_set_contains_target :: 
    Ptr RelationSet ->                      -- set : TInterface (Name {namespace = "Atk", name = "RelationSet"})
    CUInt ->                                -- relationship : TInterface (Name {namespace = "Atk", name = "RelationType"})
    Ptr Atk.Object.Object ->                -- target : TInterface (Name {namespace = "Atk", name = "Object"})
    IO CInt

{- |
Determines whether the relation set contains a relation that
matches the specified pair formed by type /@relationship@/ and object
/@target@/.
-}
relationSetContainsTarget ::
    (B.CallStack.HasCallStack, MonadIO m, IsRelationSet a, Atk.Object.IsObject b) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.RelationSet.RelationSet' -}
    -> Atk.Enums.RelationType
    {- ^ /@relationship@/: an 'GI.Atk.Enums.RelationType' -}
    -> b
    {- ^ /@target@/: an 'GI.Atk.Objects.Object.Object' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@set@/ contains a relation with the relationship
type /@relationship@/ with an object /@target@/, 'False' otherwise -}
relationSetContainsTarget :: a -> RelationType -> b -> m Bool
relationSetContainsTarget set :: a
set relationship :: RelationType
relationship target :: b
target = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
set' <- a -> IO (Ptr RelationSet)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
set
    let relationship' :: CUInt
relationship' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (RelationType -> Int) -> RelationType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelationType -> Int
forall a. Enum a => a -> Int
fromEnum) RelationType
relationship
    Ptr Object
target' <- b -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
target
    CInt
result <- Ptr RelationSet -> CUInt -> Ptr Object -> IO CInt
atk_relation_set_contains_target Ptr RelationSet
set' CUInt
relationship' Ptr Object
target'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
set
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
target
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data RelationSetContainsTargetMethodInfo
instance (signature ~ (Atk.Enums.RelationType -> b -> m Bool), MonadIO m, IsRelationSet a, Atk.Object.IsObject b) => O.MethodInfo RelationSetContainsTargetMethodInfo a signature where
    overloadedMethod _ = relationSetContainsTarget

#endif

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

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

{- |
Determines the number of relations in a relation set.
-}
relationSetGetNRelations ::
    (B.CallStack.HasCallStack, MonadIO m, IsRelationSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.RelationSet.RelationSet' -}
    -> m Int32
    {- ^ __Returns:__ an integer representing the number of relations in the set. -}
relationSetGetNRelations :: a -> m Int32
relationSetGetNRelations set :: a
set = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
set' <- a -> IO (Ptr RelationSet)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
set
    Int32
result <- Ptr RelationSet -> IO Int32
atk_relation_set_get_n_relations Ptr RelationSet
set'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
set
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if ENABLE_OVERLOADING
data RelationSetGetNRelationsMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsRelationSet a) => O.MethodInfo RelationSetGetNRelationsMethodInfo a signature where
    overloadedMethod _ = relationSetGetNRelations

#endif

-- method RelationSet::get_relation
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "set", argType = TInterface (Name {namespace = "Atk", name = "RelationSet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an #AtkRelationSet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "i", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a gint representing a position in the set, starting from 0.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Atk", name = "Relation"}))
-- throws : False
-- Skip return : False

foreign import ccall "atk_relation_set_get_relation" atk_relation_set_get_relation :: 
    Ptr RelationSet ->                      -- set : TInterface (Name {namespace = "Atk", name = "RelationSet"})
    Int32 ->                                -- i : TBasicType TInt
    IO (Ptr Atk.Relation.Relation)

{- |
Determines the relation at the specified position in the relation set.
-}
relationSetGetRelation ::
    (B.CallStack.HasCallStack, MonadIO m, IsRelationSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.RelationSet.RelationSet' -}
    -> Int32
    {- ^ /@i@/: a gint representing a position in the set, starting from 0. -}
    -> m Atk.Relation.Relation
    {- ^ __Returns:__ a 'GI.Atk.Objects.Relation.Relation', which is the relation at
position i in the set. -}
relationSetGetRelation :: a -> Int32 -> m Relation
relationSetGetRelation set :: a
set i :: Int32
i = IO Relation -> m Relation
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Relation -> m Relation) -> IO Relation -> m Relation
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
set' <- a -> IO (Ptr RelationSet)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
set
    Ptr Relation
result <- Ptr RelationSet -> Int32 -> IO (Ptr Relation)
atk_relation_set_get_relation Ptr RelationSet
set' Int32
i
    Text -> Ptr Relation -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "relationSetGetRelation" Ptr Relation
result
    Relation
result' <- ((ManagedPtr Relation -> Relation) -> Ptr Relation -> IO Relation
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Relation -> Relation
Atk.Relation.Relation) Ptr Relation
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
set
    Relation -> IO Relation
forall (m :: * -> *) a. Monad m => a -> m a
return Relation
result'

#if ENABLE_OVERLOADING
data RelationSetGetRelationMethodInfo
instance (signature ~ (Int32 -> m Atk.Relation.Relation), MonadIO m, IsRelationSet a) => O.MethodInfo RelationSetGetRelationMethodInfo a signature where
    overloadedMethod _ = relationSetGetRelation

#endif

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

foreign import ccall "atk_relation_set_get_relation_by_type" atk_relation_set_get_relation_by_type :: 
    Ptr RelationSet ->                      -- set : TInterface (Name {namespace = "Atk", name = "RelationSet"})
    CUInt ->                                -- relationship : TInterface (Name {namespace = "Atk", name = "RelationType"})
    IO (Ptr Atk.Relation.Relation)

{- |
Finds a relation that matches the specified type.
-}
relationSetGetRelationByType ::
    (B.CallStack.HasCallStack, MonadIO m, IsRelationSet a) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.RelationSet.RelationSet' -}
    -> Atk.Enums.RelationType
    {- ^ /@relationship@/: an 'GI.Atk.Enums.RelationType' -}
    -> m Atk.Relation.Relation
    {- ^ __Returns:__ an 'GI.Atk.Objects.Relation.Relation', which is a relation matching the
specified type. -}
relationSetGetRelationByType :: a -> RelationType -> m Relation
relationSetGetRelationByType set :: a
set relationship :: RelationType
relationship = IO Relation -> m Relation
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Relation -> m Relation) -> IO Relation -> m Relation
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
set' <- a -> IO (Ptr RelationSet)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
set
    let relationship' :: CUInt
relationship' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (RelationType -> Int) -> RelationType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelationType -> Int
forall a. Enum a => a -> Int
fromEnum) RelationType
relationship
    Ptr Relation
result <- Ptr RelationSet -> CUInt -> IO (Ptr Relation)
atk_relation_set_get_relation_by_type Ptr RelationSet
set' CUInt
relationship'
    Text -> Ptr Relation -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "relationSetGetRelationByType" Ptr Relation
result
    Relation
result' <- ((ManagedPtr Relation -> Relation) -> Ptr Relation -> IO Relation
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Relation -> Relation
Atk.Relation.Relation) Ptr Relation
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
set
    Relation -> IO Relation
forall (m :: * -> *) a. Monad m => a -> m a
return Relation
result'

#if ENABLE_OVERLOADING
data RelationSetGetRelationByTypeMethodInfo
instance (signature ~ (Atk.Enums.RelationType -> m Atk.Relation.Relation), MonadIO m, IsRelationSet a) => O.MethodInfo RelationSetGetRelationByTypeMethodInfo a signature where
    overloadedMethod _ = relationSetGetRelationByType

#endif

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

foreign import ccall "atk_relation_set_remove" atk_relation_set_remove :: 
    Ptr RelationSet ->                      -- set : TInterface (Name {namespace = "Atk", name = "RelationSet"})
    Ptr Atk.Relation.Relation ->            -- relation : TInterface (Name {namespace = "Atk", name = "Relation"})
    IO ()

{- |
Removes a relation from the relation set.
This function unref\'s the 'GI.Atk.Objects.Relation.Relation' so it will be deleted unless there
is another reference to it.
-}
relationSetRemove ::
    (B.CallStack.HasCallStack, MonadIO m, IsRelationSet a, Atk.Relation.IsRelation b) =>
    a
    {- ^ /@set@/: an 'GI.Atk.Objects.RelationSet.RelationSet' -}
    -> b
    {- ^ /@relation@/: an 'GI.Atk.Objects.Relation.Relation' -}
    -> m ()
relationSetRemove :: a -> b -> m ()
relationSetRemove set :: a
set relation :: b
relation = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr RelationSet
set' <- a -> IO (Ptr RelationSet)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
set
    Ptr Relation
relation' <- b -> IO (Ptr Relation)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
relation
    Ptr RelationSet -> Ptr Relation -> IO ()
atk_relation_set_remove Ptr RelationSet
set' Ptr Relation
relation'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
set
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
relation
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data RelationSetRemoveMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsRelationSet a, Atk.Relation.IsRelation b) => O.MethodInfo RelationSetRemoveMethodInfo a signature where
    overloadedMethod _ = relationSetRemove

#endif