{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} module GI.Atk.Objects.Relation ( -- * Exported types Relation(..) , RelationK , toRelation , noRelation , -- * Methods -- ** relationAddTarget relationAddTarget , -- ** relationGetRelationType relationGetRelationType , -- ** relationGetTarget relationGetTarget , -- ** relationNew relationNew , -- ** relationRemoveTarget relationRemoveTarget , -- * Properties -- ** RelationType RelationRelationTypePropertyInfo , constructRelationRelationType , getRelationRelationType , setRelationRelationType , -- ** Target RelationTargetPropertyInfo , constructRelationTarget , getRelationTarget , setRelationTarget , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.Atk.Types import GI.Atk.Callbacks import qualified GI.GObject as GObject newtype Relation = Relation (ForeignPtr Relation) foreign import ccall "atk_relation_get_type" c_atk_relation_get_type :: IO GType type instance ParentTypes Relation = RelationParentTypes type RelationParentTypes = '[GObject.Object] instance GObject Relation where gobjectIsInitiallyUnowned _ = False gobjectType _ = c_atk_relation_get_type class GObject o => RelationK o instance (GObject o, IsDescendantOf Relation o) => RelationK o toRelation :: RelationK o => o -> IO Relation toRelation = unsafeCastTo Relation noRelation :: Maybe Relation noRelation = Nothing -- VVV Prop "relation-type" -- Type: TInterface "Atk" "RelationType" -- Flags: [PropertyReadable,PropertyWritable] getRelationRelationType :: (MonadIO m, RelationK o) => o -> m RelationType getRelationRelationType obj = liftIO $ getObjectPropertyEnum obj "relation-type" setRelationRelationType :: (MonadIO m, RelationK o) => o -> RelationType -> m () setRelationRelationType obj val = liftIO $ setObjectPropertyEnum obj "relation-type" val constructRelationRelationType :: RelationType -> IO ([Char], GValue) constructRelationRelationType val = constructObjectPropertyEnum "relation-type" val data RelationRelationTypePropertyInfo instance AttrInfo RelationRelationTypePropertyInfo where type AttrAllowedOps RelationRelationTypePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet] type AttrSetTypeConstraint RelationRelationTypePropertyInfo = (~) RelationType type AttrBaseTypeConstraint RelationRelationTypePropertyInfo = RelationK type AttrGetType RelationRelationTypePropertyInfo = RelationType type AttrLabel RelationRelationTypePropertyInfo = "Relation::relation-type" attrGet _ = getRelationRelationType attrSet _ = setRelationRelationType attrConstruct _ = constructRelationRelationType -- VVV Prop "target" -- Type: TInterface "GObject" "ValueArray" -- Flags: [PropertyReadable,PropertyWritable] getRelationTarget :: (MonadIO m, RelationK o) => o -> m GObject.ValueArray getRelationTarget obj = liftIO $ getObjectPropertyBoxed obj "target" GObject.ValueArray setRelationTarget :: (MonadIO m, RelationK o) => o -> GObject.ValueArray -> m () setRelationTarget obj val = liftIO $ setObjectPropertyBoxed obj "target" val constructRelationTarget :: GObject.ValueArray -> IO ([Char], GValue) constructRelationTarget val = constructObjectPropertyBoxed "target" val data RelationTargetPropertyInfo instance AttrInfo RelationTargetPropertyInfo where type AttrAllowedOps RelationTargetPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet] type AttrSetTypeConstraint RelationTargetPropertyInfo = (~) GObject.ValueArray type AttrBaseTypeConstraint RelationTargetPropertyInfo = RelationK type AttrGetType RelationTargetPropertyInfo = GObject.ValueArray type AttrLabel RelationTargetPropertyInfo = "Relation::target" attrGet _ = getRelationTarget attrSet _ = setRelationTarget attrConstruct _ = constructRelationTarget type instance AttributeList Relation = RelationAttributeList type RelationAttributeList = ('[ '("relation-type", RelationRelationTypePropertyInfo), '("target", RelationTargetPropertyInfo)] :: [(Symbol, *)]) type instance SignalList Relation = RelationSignalList type RelationSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)]) -- method Relation::new -- method type : Constructor -- Args : [Arg {argName = "targets", argType = TCArray False (-1) 1 (TInterface "Atk" "Object"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "n_targets", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "relationship", argType = TInterface "Atk" "RelationType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [Arg {argName = "n_targets", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- hInArgs : [Arg {argName = "targets", argType = TCArray False (-1) 1 (TInterface "Atk" "Object"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "relationship", argType = TInterface "Atk" "RelationType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Atk" "Relation" -- throws : False -- Skip return : False foreign import ccall "atk_relation_new" atk_relation_new :: Ptr (Ptr Object) -> -- targets : TCArray False (-1) 1 (TInterface "Atk" "Object") Int32 -> -- n_targets : TBasicType TInt32 CUInt -> -- relationship : TInterface "Atk" "RelationType" IO (Ptr Relation) relationNew :: (MonadIO m) => [Object] -> -- targets RelationType -> -- relationship m Relation relationNew targets relationship = liftIO $ do let n_targets = fromIntegral $ length targets let targets' = map unsafeManagedPtrCastPtr targets targets'' <- packPtrArray targets' let relationship' = (fromIntegral . fromEnum) relationship result <- atk_relation_new targets'' n_targets relationship' checkUnexpectedReturnNULL "atk_relation_new" result result' <- (wrapObject Relation) result mapM_ touchManagedPtr targets freeMem targets'' return result' -- method Relation::add_target -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Relation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "target", argType = TInterface "Atk" "Object", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Relation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "target", argType = TInterface "Atk" "Object", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "atk_relation_add_target" atk_relation_add_target :: Ptr Relation -> -- _obj : TInterface "Atk" "Relation" Ptr Object -> -- target : TInterface "Atk" "Object" IO () relationAddTarget :: (MonadIO m, RelationK a, ObjectK b) => a -> -- _obj b -> -- target m () relationAddTarget _obj target = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let target' = unsafeManagedPtrCastPtr target atk_relation_add_target _obj' target' touchManagedPtr _obj touchManagedPtr target return () -- method Relation::get_relation_type -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Relation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Relation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Atk" "RelationType" -- throws : False -- Skip return : False foreign import ccall "atk_relation_get_relation_type" atk_relation_get_relation_type :: Ptr Relation -> -- _obj : TInterface "Atk" "Relation" IO CUInt relationGetRelationType :: (MonadIO m, RelationK a) => a -> -- _obj m RelationType relationGetRelationType _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- atk_relation_get_relation_type _obj' let result' = (toEnum . fromIntegral) result touchManagedPtr _obj return result' -- method Relation::get_target -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Relation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Relation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TPtrArray (TInterface "Atk" "Object") -- throws : False -- Skip return : False foreign import ccall "atk_relation_get_target" atk_relation_get_target :: Ptr Relation -> -- _obj : TInterface "Atk" "Relation" IO (Ptr (GPtrArray (Ptr Object))) relationGetTarget :: (MonadIO m, RelationK a) => a -> -- _obj m [Object] relationGetTarget _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- atk_relation_get_target _obj' checkUnexpectedReturnNULL "atk_relation_get_target" result result' <- unpackGPtrArray result result'' <- mapM (newObject Object) result' touchManagedPtr _obj return result'' -- method Relation::remove_target -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Atk" "Relation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "target", argType = TInterface "Atk" "Object", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Atk" "Relation", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "target", argType = TInterface "Atk" "Object", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "atk_relation_remove_target" atk_relation_remove_target :: Ptr Relation -> -- _obj : TInterface "Atk" "Relation" Ptr Object -> -- target : TInterface "Atk" "Object" IO CInt relationRemoveTarget :: (MonadIO m, RelationK a, ObjectK b) => a -> -- _obj b -> -- target m Bool relationRemoveTarget _obj target = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let target' = unsafeManagedPtrCastPtr target result <- atk_relation_remove_target _obj' target' let result' = (/= 0) result touchManagedPtr _obj touchManagedPtr target return result'