module GI.Atk.Objects.Relation
(
Relation(..) ,
RelationK ,
toRelation ,
noRelation ,
relationAddTarget ,
relationGetRelationType ,
relationGetTarget ,
relationNew ,
relationRemoveTarget ,
RelationRelationTypePropertyInfo ,
constructRelationRelationType ,
getRelationRelationType ,
setRelationRelationType ,
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
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
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, *)])
foreign import ccall "atk_relation_new" atk_relation_new ::
Ptr (Ptr Object) ->
Int32 ->
CUInt ->
IO (Ptr Relation)
relationNew ::
(MonadIO m) =>
[Object] ->
RelationType ->
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'
foreign import ccall "atk_relation_add_target" atk_relation_add_target ::
Ptr Relation ->
Ptr Object ->
IO ()
relationAddTarget ::
(MonadIO m, RelationK a, ObjectK b) =>
a ->
b ->
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 ()
foreign import ccall "atk_relation_get_relation_type" atk_relation_get_relation_type ::
Ptr Relation ->
IO CUInt
relationGetRelationType ::
(MonadIO m, RelationK a) =>
a ->
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'
foreign import ccall "atk_relation_get_target" atk_relation_get_target ::
Ptr Relation ->
IO (Ptr (GPtrArray (Ptr Object)))
relationGetTarget ::
(MonadIO m, RelationK a) =>
a ->
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''
foreign import ccall "atk_relation_remove_target" atk_relation_remove_target ::
Ptr Relation ->
Ptr Object ->
IO CInt
relationRemoveTarget ::
(MonadIO m, RelationK a, ObjectK b) =>
a ->
b ->
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'