{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) A #GParamSpecPool maintains a collection of #GParamSpecs which can be quickly accessed by owner and name. The implementation of the #GObject property system uses such a pool to store the #GParamSpecs of the properties all object types. -} module GI.GObject.Structs.ParamSpecPool ( -- * Exported types ParamSpecPool(..) , noParamSpecPool , -- * Methods -- ** paramSpecPoolInsert paramSpecPoolInsert , -- ** paramSpecPoolListOwned paramSpecPoolListOwned , -- ** paramSpecPoolLookup paramSpecPoolLookup , -- ** paramSpecPoolRemove paramSpecPoolRemove , ) 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.GObject.Types import GI.GObject.Callbacks newtype ParamSpecPool = ParamSpecPool (ForeignPtr ParamSpecPool) noParamSpecPool :: Maybe ParamSpecPool noParamSpecPool = Nothing -- method ParamSpecPool::insert -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GObject" "ParamSpecPool", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pspec", argType = TParamSpec, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GObject" "ParamSpecPool", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pspec", argType = TParamSpec, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_param_spec_pool_insert" g_param_spec_pool_insert :: Ptr ParamSpecPool -> -- _obj : TInterface "GObject" "ParamSpecPool" Ptr GParamSpec -> -- pspec : TParamSpec CGType -> -- owner_type : TBasicType TGType IO () paramSpecPoolInsert :: (MonadIO m) => ParamSpecPool -> -- _obj GParamSpec -> -- pspec GType -> -- owner_type m () paramSpecPoolInsert _obj pspec owner_type = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj let pspec' = unsafeManagedPtrGetPtr pspec let owner_type' = gtypeToCGType owner_type g_param_spec_pool_insert _obj' pspec' owner_type' touchManagedPtr _obj return () -- XXX Could not generate method ParamSpecPool::list -- Error was : Not implemented: "unpackCArray : Don't know how to unpack C Array of type TParamSpec" -- method ParamSpecPool::list_owned -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GObject" "ParamSpecPool", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GObject" "ParamSpecPool", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TGList TParamSpec -- throws : False -- Skip return : False foreign import ccall "g_param_spec_pool_list_owned" g_param_spec_pool_list_owned :: Ptr ParamSpecPool -> -- _obj : TInterface "GObject" "ParamSpecPool" CGType -> -- owner_type : TBasicType TGType IO (Ptr (GList (Ptr GParamSpec))) paramSpecPoolListOwned :: (MonadIO m) => ParamSpecPool -> -- _obj GType -> -- owner_type m [GParamSpec] paramSpecPoolListOwned _obj owner_type = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj let owner_type' = gtypeToCGType owner_type result <- g_param_spec_pool_list_owned _obj' owner_type' checkUnexpectedReturnNULL "g_param_spec_pool_list_owned" result result' <- unpackGList result result'' <- mapM newGParamSpecFromPtr result' g_list_free result touchManagedPtr _obj return result'' -- method ParamSpecPool::lookup -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GObject" "ParamSpecPool", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "param_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "walk_ancestors", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GObject" "ParamSpecPool", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "param_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "owner_type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "walk_ancestors", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TParamSpec -- throws : False -- Skip return : False foreign import ccall "g_param_spec_pool_lookup" g_param_spec_pool_lookup :: Ptr ParamSpecPool -> -- _obj : TInterface "GObject" "ParamSpecPool" CString -> -- param_name : TBasicType TUTF8 CGType -> -- owner_type : TBasicType TGType CInt -> -- walk_ancestors : TBasicType TBoolean IO (Ptr GParamSpec) paramSpecPoolLookup :: (MonadIO m) => ParamSpecPool -> -- _obj T.Text -> -- param_name GType -> -- owner_type Bool -> -- walk_ancestors m GParamSpec paramSpecPoolLookup _obj param_name owner_type walk_ancestors = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj param_name' <- textToCString param_name let owner_type' = gtypeToCGType owner_type let walk_ancestors' = (fromIntegral . fromEnum) walk_ancestors result <- g_param_spec_pool_lookup _obj' param_name' owner_type' walk_ancestors' checkUnexpectedReturnNULL "g_param_spec_pool_lookup" result result' <- newGParamSpecFromPtr result touchManagedPtr _obj freeMem param_name' return result' -- method ParamSpecPool::remove -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "GObject" "ParamSpecPool", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pspec", argType = TParamSpec, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "GObject" "ParamSpecPool", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pspec", argType = TParamSpec, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_param_spec_pool_remove" g_param_spec_pool_remove :: Ptr ParamSpecPool -> -- _obj : TInterface "GObject" "ParamSpecPool" Ptr GParamSpec -> -- pspec : TParamSpec IO () paramSpecPoolRemove :: (MonadIO m) => ParamSpecPool -> -- _obj GParamSpec -> -- pspec m () paramSpecPoolRemove _obj pspec = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj let pspec' = unsafeManagedPtrGetPtr pspec g_param_spec_pool_remove _obj' pspec' touchManagedPtr _obj return ()