{- |
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.SimpleAsyncResult
    ( 

-- * Exported types
    SimpleAsyncResult(..)                   ,
    SimpleAsyncResultK                      ,
    toSimpleAsyncResult                     ,
    noSimpleAsyncResult                     ,


 -- * Methods
-- ** simpleAsyncResultComplete
    simpleAsyncResultComplete               ,


-- ** simpleAsyncResultCompleteInIdle
    simpleAsyncResultCompleteInIdle         ,


-- ** simpleAsyncResultGetOpResGboolean
    simpleAsyncResultGetOpResGboolean       ,


-- ** simpleAsyncResultGetOpResGssize
    simpleAsyncResultGetOpResGssize         ,


-- ** simpleAsyncResultIsValid
    simpleAsyncResultIsValid                ,


-- ** simpleAsyncResultNew
    simpleAsyncResultNew                    ,


-- ** simpleAsyncResultNewFromError
    simpleAsyncResultNewFromError           ,


-- ** simpleAsyncResultPropagateError
    simpleAsyncResultPropagateError         ,


-- ** simpleAsyncResultSetCheckCancellable
    simpleAsyncResultSetCheckCancellable    ,


-- ** simpleAsyncResultSetFromError
    simpleAsyncResultSetFromError           ,


-- ** simpleAsyncResultSetHandleCancellation
    simpleAsyncResultSetHandleCancellation  ,


-- ** simpleAsyncResultSetOpResGboolean
    simpleAsyncResultSetOpResGboolean       ,


-- ** simpleAsyncResultSetOpResGssize
    simpleAsyncResultSetOpResGssize         ,




    ) 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 SimpleAsyncResult = SimpleAsyncResult (ForeignPtr SimpleAsyncResult)
foreign import ccall "g_simple_async_result_get_type"
    c_g_simple_async_result_get_type :: IO GType

type instance ParentTypes SimpleAsyncResult = SimpleAsyncResultParentTypes
type SimpleAsyncResultParentTypes = '[GObject.Object, AsyncResult]

instance GObject SimpleAsyncResult where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_simple_async_result_get_type
    

class GObject o => SimpleAsyncResultK o
instance (GObject o, IsDescendantOf SimpleAsyncResult o) => SimpleAsyncResultK o

toSimpleAsyncResult :: SimpleAsyncResultK o => o -> IO SimpleAsyncResult
toSimpleAsyncResult = unsafeCastTo SimpleAsyncResult

noSimpleAsyncResult :: Maybe SimpleAsyncResult
noSimpleAsyncResult = Nothing

type instance AttributeList SimpleAsyncResult = SimpleAsyncResultAttributeList
type SimpleAsyncResultAttributeList = ('[ ] :: [(Symbol, *)])

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

-- method SimpleAsyncResult::new
-- method type : Constructor
-- Args : [Arg {argName = "source_object", argType = TInterface "GObject" "Object", 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 = 2, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_tag", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "source_object", argType = TInterface "GObject" "Object", 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 = 2, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_tag", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SimpleAsyncResult"
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_new" g_simple_async_result_new :: 
    Ptr GObject.Object ->                   -- source_object : TInterface "GObject" "Object"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    Ptr () ->                               -- source_tag : TBasicType TVoid
    IO (Ptr SimpleAsyncResult)


simpleAsyncResultNew ::
    (MonadIO m, GObject.ObjectK a) =>
    Maybe (a) ->                            -- source_object
    Maybe (AsyncReadyCallback) ->           -- callback
    Ptr () ->                               -- source_tag
    m SimpleAsyncResult
simpleAsyncResultNew source_object callback source_tag = liftIO $ do
    maybeSource_object <- case source_object of
        Nothing -> return nullPtr
        Just jSource_object -> do
            let jSource_object' = unsafeManagedPtrCastPtr jSource_object
            return jSource_object'
    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
    result <- g_simple_async_result_new maybeSource_object maybeCallback user_data source_tag
    checkUnexpectedReturnNULL "g_simple_async_result_new" result
    result' <- (wrapObject SimpleAsyncResult) result
    whenJust source_object touchManagedPtr
    return result'

-- method SimpleAsyncResult::new_from_error
-- method type : Constructor
-- Args : [Arg {argName = "source_object", argType = TInterface "GObject" "Object", 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 = 2, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "error", argType = TError, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "source_object", argType = TInterface "GObject" "Object", 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 = 2, argDestroy = -1, transfer = TransferNothing},Arg {argName = "error", argType = TError, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "SimpleAsyncResult"
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_new_from_error" g_simple_async_result_new_from_error :: 
    Ptr GObject.Object ->                   -- source_object : TInterface "GObject" "Object"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    Ptr GError ->                           -- error : TError
    IO (Ptr SimpleAsyncResult)


simpleAsyncResultNewFromError ::
    (MonadIO m, GObject.ObjectK a) =>
    Maybe (a) ->                            -- source_object
    Maybe (AsyncReadyCallback) ->           -- callback
    GError ->                               -- error
    m SimpleAsyncResult
simpleAsyncResultNewFromError source_object callback error_ = liftIO $ do
    maybeSource_object <- case source_object of
        Nothing -> return nullPtr
        Just jSource_object -> do
            let jSource_object' = unsafeManagedPtrCastPtr jSource_object
            return jSource_object'
    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 error_' = unsafeManagedPtrGetPtr error_
    let user_data = nullPtr
    result <- g_simple_async_result_new_from_error maybeSource_object maybeCallback user_data error_'
    checkUnexpectedReturnNULL "g_simple_async_result_new_from_error" result
    result' <- (wrapObject SimpleAsyncResult) result
    whenJust source_object touchManagedPtr
    touchManagedPtr error_
    return result'

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

foreign import ccall "g_simple_async_result_complete" g_simple_async_result_complete :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    IO ()


simpleAsyncResultComplete ::
    (MonadIO m, SimpleAsyncResultK a) =>
    a ->                                    -- _obj
    m ()
simpleAsyncResultComplete _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_simple_async_result_complete _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "g_simple_async_result_complete_in_idle" g_simple_async_result_complete_in_idle :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    IO ()


simpleAsyncResultCompleteInIdle ::
    (MonadIO m, SimpleAsyncResultK a) =>
    a ->                                    -- _obj
    m ()
simpleAsyncResultCompleteInIdle _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_simple_async_result_complete_in_idle _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "g_simple_async_result_get_op_res_gboolean" g_simple_async_result_get_op_res_gboolean :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    IO CInt


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

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

foreign import ccall "g_simple_async_result_get_op_res_gssize" g_simple_async_result_get_op_res_gssize :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    IO Int64


simpleAsyncResultGetOpResGssize ::
    (MonadIO m, SimpleAsyncResultK a) =>
    a ->                                    -- _obj
    m Int64
simpleAsyncResultGetOpResGssize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_simple_async_result_get_op_res_gssize _obj'
    touchManagedPtr _obj
    return result

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

foreign import ccall "g_simple_async_result_propagate_error" g_simple_async_result_propagate_error :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


simpleAsyncResultPropagateError ::
    (MonadIO m, SimpleAsyncResultK a) =>
    a ->                                    -- _obj
    m ()
simpleAsyncResultPropagateError _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        _ <- propagateGError $ g_simple_async_result_propagate_error _obj'
        touchManagedPtr _obj
        return ()
     ) (do
        return ()
     )

-- method SimpleAsyncResult::set_check_cancellable
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SimpleAsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "check_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" "SimpleAsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "check_cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_set_check_cancellable" g_simple_async_result_set_check_cancellable :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    Ptr Cancellable ->                      -- check_cancellable : TInterface "Gio" "Cancellable"
    IO ()


simpleAsyncResultSetCheckCancellable ::
    (MonadIO m, SimpleAsyncResultK a, CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- check_cancellable
    m ()
simpleAsyncResultSetCheckCancellable _obj check_cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCheck_cancellable <- case check_cancellable of
        Nothing -> return nullPtr
        Just jCheck_cancellable -> do
            let jCheck_cancellable' = unsafeManagedPtrCastPtr jCheck_cancellable
            return jCheck_cancellable'
    g_simple_async_result_set_check_cancellable _obj' maybeCheck_cancellable
    touchManagedPtr _obj
    whenJust check_cancellable touchManagedPtr
    return ()

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

foreign import ccall "g_simple_async_result_set_from_error" g_simple_async_result_set_from_error :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    Ptr GError ->                           -- error : TError
    IO ()


simpleAsyncResultSetFromError ::
    (MonadIO m, SimpleAsyncResultK a) =>
    a ->                                    -- _obj
    GError ->                               -- error
    m ()
simpleAsyncResultSetFromError _obj error_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let error_' = unsafeManagedPtrGetPtr error_
    g_simple_async_result_set_from_error _obj' error_'
    touchManagedPtr _obj
    touchManagedPtr error_
    return ()

-- method SimpleAsyncResult::set_handle_cancellation
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SimpleAsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "handle_cancellation", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SimpleAsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "handle_cancellation", 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_simple_async_result_set_handle_cancellation" g_simple_async_result_set_handle_cancellation :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    CInt ->                                 -- handle_cancellation : TBasicType TBoolean
    IO ()


simpleAsyncResultSetHandleCancellation ::
    (MonadIO m, SimpleAsyncResultK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- handle_cancellation
    m ()
simpleAsyncResultSetHandleCancellation _obj handle_cancellation = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let handle_cancellation' = (fromIntegral . fromEnum) handle_cancellation
    g_simple_async_result_set_handle_cancellation _obj' handle_cancellation'
    touchManagedPtr _obj
    return ()

-- method SimpleAsyncResult::set_op_res_gboolean
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SimpleAsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "op_res", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SimpleAsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "op_res", 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_simple_async_result_set_op_res_gboolean" g_simple_async_result_set_op_res_gboolean :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    CInt ->                                 -- op_res : TBasicType TBoolean
    IO ()


simpleAsyncResultSetOpResGboolean ::
    (MonadIO m, SimpleAsyncResultK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- op_res
    m ()
simpleAsyncResultSetOpResGboolean _obj op_res = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let op_res' = (fromIntegral . fromEnum) op_res
    g_simple_async_result_set_op_res_gboolean _obj' op_res'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "g_simple_async_result_set_op_res_gssize" g_simple_async_result_set_op_res_gssize :: 
    Ptr SimpleAsyncResult ->                -- _obj : TInterface "Gio" "SimpleAsyncResult"
    Int64 ->                                -- op_res : TBasicType TInt64
    IO ()


simpleAsyncResultSetOpResGssize ::
    (MonadIO m, SimpleAsyncResultK a) =>
    a ->                                    -- _obj
    Int64 ->                                -- op_res
    m ()
simpleAsyncResultSetOpResGssize _obj op_res = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    g_simple_async_result_set_op_res_gssize _obj' op_res
    touchManagedPtr _obj
    return ()

-- method SimpleAsyncResult::is_valid
-- method type : MemberFunction
-- Args : [Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_tag", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source", argType = TInterface "GObject" "Object", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_tag", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_is_valid" g_simple_async_result_is_valid :: 
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr GObject.Object ->                   -- source : TInterface "GObject" "Object"
    Ptr () ->                               -- source_tag : TBasicType TVoid
    IO CInt


simpleAsyncResultIsValid ::
    (MonadIO m, AsyncResultK a, GObject.ObjectK b) =>
    a ->                                    -- result
    Maybe (b) ->                            -- source
    Maybe (Ptr ()) ->                       -- source_tag
    m Bool
simpleAsyncResultIsValid result_ source source_tag = liftIO $ do
    let result_' = unsafeManagedPtrCastPtr result_
    maybeSource <- case source of
        Nothing -> return nullPtr
        Just jSource -> do
            let jSource' = unsafeManagedPtrCastPtr jSource
            return jSource'
    maybeSource_tag <- case source_tag of
        Nothing -> return nullPtr
        Just jSource_tag -> do
            return jSource_tag
    result <- g_simple_async_result_is_valid result_' maybeSource maybeSource_tag
    let result' = (/= 0) result
    touchManagedPtr result_
    whenJust source touchManagedPtr
    return result'