{- |
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.Gio.Objects.FileEnumerator
    ( 

-- * Exported types
    FileEnumerator(..)                      ,
    FileEnumeratorK                         ,
    toFileEnumerator                        ,
    noFileEnumerator                        ,


 -- * Methods
-- ** fileEnumeratorClose
    fileEnumeratorClose                     ,


-- ** fileEnumeratorCloseAsync
    fileEnumeratorCloseAsync                ,


-- ** fileEnumeratorCloseFinish
    fileEnumeratorCloseFinish               ,


-- ** fileEnumeratorGetChild
    fileEnumeratorGetChild                  ,


-- ** fileEnumeratorGetContainer
    fileEnumeratorGetContainer              ,


-- ** fileEnumeratorHasPending
    fileEnumeratorHasPending                ,


-- ** fileEnumeratorIsClosed
    fileEnumeratorIsClosed                  ,


-- ** fileEnumeratorIterate
    fileEnumeratorIterate                   ,


-- ** fileEnumeratorNextFile
    fileEnumeratorNextFile                  ,


-- ** fileEnumeratorNextFilesAsync
    fileEnumeratorNextFilesAsync            ,


-- ** fileEnumeratorNextFilesFinish
    fileEnumeratorNextFilesFinish           ,


-- ** fileEnumeratorSetPending
    fileEnumeratorSetPending                ,




 -- * Properties
-- ** Container
    FileEnumeratorContainerPropertyInfo     ,
    constructFileEnumeratorContainer        ,




    ) 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
import qualified GI.GObject as GObject

newtype FileEnumerator = FileEnumerator (ForeignPtr FileEnumerator)
foreign import ccall "g_file_enumerator_get_type"
    c_g_file_enumerator_get_type :: IO GType

type instance ParentTypes FileEnumerator = FileEnumeratorParentTypes
type FileEnumeratorParentTypes = '[GObject.Object]

instance GObject FileEnumerator where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_file_enumerator_get_type
    

class GObject o => FileEnumeratorK o
instance (GObject o, IsDescendantOf FileEnumerator o) => FileEnumeratorK o

toFileEnumerator :: FileEnumeratorK o => o -> IO FileEnumerator
toFileEnumerator = unsafeCastTo FileEnumerator

noFileEnumerator :: Maybe FileEnumerator
noFileEnumerator = Nothing

-- VVV Prop "container"
   -- Type: TInterface "Gio" "File"
   -- Flags: [PropertyWritable,PropertyConstructOnly]

constructFileEnumeratorContainer :: (FileK a) => a -> IO ([Char], GValue)
constructFileEnumeratorContainer val = constructObjectPropertyObject "container" val

data FileEnumeratorContainerPropertyInfo
instance AttrInfo FileEnumeratorContainerPropertyInfo where
    type AttrAllowedOps FileEnumeratorContainerPropertyInfo = '[ 'AttrConstruct]
    type AttrSetTypeConstraint FileEnumeratorContainerPropertyInfo = FileK
    type AttrBaseTypeConstraint FileEnumeratorContainerPropertyInfo = FileEnumeratorK
    type AttrGetType FileEnumeratorContainerPropertyInfo = ()
    type AttrLabel FileEnumeratorContainerPropertyInfo = "FileEnumerator::container"
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructFileEnumeratorContainer

type instance AttributeList FileEnumerator = FileEnumeratorAttributeList
type FileEnumeratorAttributeList = ('[ '("container", FileEnumeratorContainerPropertyInfo)] :: [(Symbol, *)])

type instance SignalList FileEnumerator = FileEnumeratorSignalList
type FileEnumeratorSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

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

foreign import ccall "g_file_enumerator_close" g_file_enumerator_close :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


fileEnumeratorClose ::
    (MonadIO m, FileEnumeratorK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    m ()
fileEnumeratorClose _obj cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_enumerator_close _obj' maybeCancellable
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

-- method FileEnumerator::close_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "FileEnumerator", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "io_priority", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "FileEnumerator", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "io_priority", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_file_enumerator_close_async" g_file_enumerator_close_async :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    Int32 ->                                -- io_priority : TBasicType TInt32
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


fileEnumeratorCloseAsync ::
    (MonadIO m, FileEnumeratorK a, CancellableK b) =>
    a ->                                    -- _obj
    Int32 ->                                -- io_priority
    Maybe (b) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
fileEnumeratorCloseAsync _obj io_priority cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_file_enumerator_close_async _obj' io_priority maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust cancellable touchManagedPtr
    return ()

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

foreign import ccall "g_file_enumerator_close_finish" g_file_enumerator_close_finish :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


fileEnumeratorCloseFinish ::
    (MonadIO m, FileEnumeratorK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m ()
fileEnumeratorCloseFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_file_enumerator_close_finish _obj' result_'
        touchManagedPtr _obj
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

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

foreign import ccall "g_file_enumerator_get_child" g_file_enumerator_get_child :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    Ptr FileInfo ->                         -- info : TInterface "Gio" "FileInfo"
    IO (Ptr File)


fileEnumeratorGetChild ::
    (MonadIO m, FileEnumeratorK a, FileInfoK b) =>
    a ->                                    -- _obj
    b ->                                    -- info
    m File
fileEnumeratorGetChild _obj info = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let info' = unsafeManagedPtrCastPtr info
    result <- g_file_enumerator_get_child _obj' info'
    checkUnexpectedReturnNULL "g_file_enumerator_get_child" result
    result' <- (wrapObject File) result
    touchManagedPtr _obj
    touchManagedPtr info
    return result'

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

foreign import ccall "g_file_enumerator_get_container" g_file_enumerator_get_container :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    IO (Ptr File)


fileEnumeratorGetContainer ::
    (MonadIO m, FileEnumeratorK a) =>
    a ->                                    -- _obj
    m File
fileEnumeratorGetContainer _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_file_enumerator_get_container _obj'
    checkUnexpectedReturnNULL "g_file_enumerator_get_container" result
    result' <- (newObject File) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_file_enumerator_has_pending" g_file_enumerator_has_pending :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    IO CInt


fileEnumeratorHasPending ::
    (MonadIO m, FileEnumeratorK a) =>
    a ->                                    -- _obj
    m Bool
fileEnumeratorHasPending _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_file_enumerator_has_pending _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_file_enumerator_is_closed" g_file_enumerator_is_closed :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    IO CInt


fileEnumeratorIsClosed ::
    (MonadIO m, FileEnumeratorK a) =>
    a ->                                    -- _obj
    m Bool
fileEnumeratorIsClosed _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_file_enumerator_is_closed _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method FileEnumerator::iterate
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "FileEnumerator", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "out_info", argType = TInterface "Gio" "FileInfo", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "out_child", argType = TInterface "Gio" "File", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "FileEnumerator", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "g_file_enumerator_iterate" g_file_enumerator_iterate :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    Ptr (Ptr FileInfo) ->                   -- out_info : TInterface "Gio" "FileInfo"
    Ptr (Ptr File) ->                       -- out_child : TInterface "Gio" "File"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


fileEnumeratorIterate ::
    (MonadIO m, FileEnumeratorK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    m (FileInfo,File)
fileEnumeratorIterate _obj cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    out_info <- allocMem :: IO (Ptr (Ptr FileInfo))
    out_child <- allocMem :: IO (Ptr (Ptr File))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_file_enumerator_iterate _obj' out_info out_child maybeCancellable
        out_info' <- peek out_info
        out_info'' <- (newObject FileInfo) out_info'
        out_child' <- peek out_child
        out_child'' <- (newObject File) out_child'
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        freeMem out_info
        freeMem out_child
        return (out_info'', out_child'')
     ) (do
        freeMem out_info
        freeMem out_child
     )

-- method FileEnumerator::next_file
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "FileEnumerator", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "FileEnumerator", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "FileInfo"
-- throws : True
-- Skip return : False

foreign import ccall "g_file_enumerator_next_file" g_file_enumerator_next_file :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr FileInfo)


fileEnumeratorNextFile ::
    (MonadIO m, FileEnumeratorK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    m FileInfo
fileEnumeratorNextFile _obj cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_file_enumerator_next_file _obj' maybeCancellable
        checkUnexpectedReturnNULL "g_file_enumerator_next_file" result
        result' <- (wrapObject FileInfo) result
        touchManagedPtr _obj
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method FileEnumerator::next_files_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "FileEnumerator", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_files", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "io_priority", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "FileEnumerator", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "num_files", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "io_priority", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_file_enumerator_next_files_async" g_file_enumerator_next_files_async :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    Int32 ->                                -- num_files : TBasicType TInt32
    Int32 ->                                -- io_priority : TBasicType TInt32
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


fileEnumeratorNextFilesAsync ::
    (MonadIO m, FileEnumeratorK a, CancellableK b) =>
    a ->                                    -- _obj
    Int32 ->                                -- num_files
    Int32 ->                                -- io_priority
    Maybe (b) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
fileEnumeratorNextFilesAsync _obj num_files io_priority cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_file_enumerator_next_files_async _obj' num_files io_priority maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust cancellable touchManagedPtr
    return ()

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

foreign import ccall "g_file_enumerator_next_files_finish" g_file_enumerator_next_files_finish :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr FileInfo)))


fileEnumeratorNextFilesFinish ::
    (MonadIO m, FileEnumeratorK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m [FileInfo]
fileEnumeratorNextFilesFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_file_enumerator_next_files_finish _obj' result_'
        checkUnexpectedReturnNULL "g_file_enumerator_next_files_finish" result
        result' <- unpackGList result
        result'' <- mapM (wrapObject FileInfo) result'
        g_list_free result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result''
     ) (do
        return ()
     )

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

foreign import ccall "g_file_enumerator_set_pending" g_file_enumerator_set_pending :: 
    Ptr FileEnumerator ->                   -- _obj : TInterface "Gio" "FileEnumerator"
    CInt ->                                 -- pending : TBasicType TBoolean
    IO ()


fileEnumeratorSetPending ::
    (MonadIO m, FileEnumeratorK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- pending
    m ()
fileEnumeratorSetPending _obj pending = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let pending' = (fromIntegral . fromEnum) pending
    g_file_enumerator_set_pending _obj' pending'
    touchManagedPtr _obj
    return ()