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

#GIOExtensionPoint is an opaque data structure and can only be accessed
using the following functions.
-}

module GI.Gio.Structs.IOExtensionPoint
    ( 

-- * Exported types
    IOExtensionPoint(..)                    ,
    noIOExtensionPoint                      ,


 -- * Methods
-- ** iOExtensionPointGetExtensionByName
    iOExtensionPointGetExtensionByName      ,


-- ** iOExtensionPointGetExtensions
    iOExtensionPointGetExtensions           ,


-- ** iOExtensionPointGetRequiredType
    iOExtensionPointGetRequiredType         ,


-- ** iOExtensionPointSetRequiredType
    iOExtensionPointSetRequiredType         ,




    ) 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.Gio.Types
import GI.Gio.Callbacks

newtype IOExtensionPoint = IOExtensionPoint (ForeignPtr IOExtensionPoint)
noIOExtensionPoint :: Maybe IOExtensionPoint
noIOExtensionPoint = Nothing

-- method IOExtensionPoint::get_extension_by_name
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "IOExtensionPoint", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "IOExtensionPoint", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "IOExtension"
-- throws : False
-- Skip return : False

foreign import ccall "g_io_extension_point_get_extension_by_name" g_io_extension_point_get_extension_by_name :: 
    Ptr IOExtensionPoint ->                 -- _obj : TInterface "Gio" "IOExtensionPoint"
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr IOExtension)


iOExtensionPointGetExtensionByName ::
    (MonadIO m) =>
    IOExtensionPoint ->                     -- _obj
    T.Text ->                               -- name
    m IOExtension
iOExtensionPointGetExtensionByName _obj name = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    name' <- textToCString name
    result <- g_io_extension_point_get_extension_by_name _obj' name'
    checkUnexpectedReturnNULL "g_io_extension_point_get_extension_by_name" result
    -- XXX Wrapping a foreign struct/union with no known destructor, leak?
    result' <- (\x -> IOExtension <$> newForeignPtr_ x) result
    touchManagedPtr _obj
    freeMem name'
    return result'

-- method IOExtensionPoint::get_extensions
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "IOExtensionPoint", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "IOExtensionPoint", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGList (TInterface "Gio" "IOExtension")
-- throws : False
-- Skip return : False

foreign import ccall "g_io_extension_point_get_extensions" g_io_extension_point_get_extensions :: 
    Ptr IOExtensionPoint ->                 -- _obj : TInterface "Gio" "IOExtensionPoint"
    IO (Ptr (GList (Ptr IOExtension)))


iOExtensionPointGetExtensions ::
    (MonadIO m) =>
    IOExtensionPoint ->                     -- _obj
    m [IOExtension]
iOExtensionPointGetExtensions _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_io_extension_point_get_extensions _obj'
    checkUnexpectedReturnNULL "g_io_extension_point_get_extensions" result
    -- XXX Wrapping a foreign struct/union with no known destructor, leak?
    result' <- unpackGList result
    result'' <- mapM (\x -> IOExtension <$> newForeignPtr_ x) result'
    touchManagedPtr _obj
    return result''

-- method IOExtensionPoint::get_required_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "IOExtensionPoint", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "IOExtensionPoint", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TGType
-- throws : False
-- Skip return : False

foreign import ccall "g_io_extension_point_get_required_type" g_io_extension_point_get_required_type :: 
    Ptr IOExtensionPoint ->                 -- _obj : TInterface "Gio" "IOExtensionPoint"
    IO CGType


iOExtensionPointGetRequiredType ::
    (MonadIO m) =>
    IOExtensionPoint ->                     -- _obj
    m GType
iOExtensionPointGetRequiredType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_io_extension_point_get_required_type _obj'
    let result' = GType result
    touchManagedPtr _obj
    return result'

-- method IOExtensionPoint::set_required_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "IOExtensionPoint", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "IOExtensionPoint", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "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_io_extension_point_set_required_type" g_io_extension_point_set_required_type :: 
    Ptr IOExtensionPoint ->                 -- _obj : TInterface "Gio" "IOExtensionPoint"
    CGType ->                               -- type : TBasicType TGType
    IO ()


iOExtensionPointSetRequiredType ::
    (MonadIO m) =>
    IOExtensionPoint ->                     -- _obj
    GType ->                                -- type
    m ()
iOExtensionPointSetRequiredType _obj type_ = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let type_' = gtypeToCGType type_
    g_io_extension_point_set_required_type _obj' type_'
    touchManagedPtr _obj
    return ()