{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- As of GLib 2.46, t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' is deprecated in favor of
-- t'GI.Gio.Objects.Task.Task', which provides a simpler API.
-- 
-- t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' implements t'GI.Gio.Interfaces.AsyncResult.AsyncResult'.
-- 
-- GSimpleAsyncResult handles @/GAsyncReadyCallbacks/@, error
-- reporting, operation cancellation and the final state of an operation,
-- completely transparent to the application. Results can be returned
-- as a pointer e.g. for functions that return data that is collected
-- asynchronously, a boolean value for checking the success or failure
-- of an operation, or a @/gssize/@ for operations which return the number
-- of bytes modified by the operation; all of the simple return cases
-- are covered.
-- 
-- Most of the time, an application will not need to know of the details
-- of this API; it is handled transparently, and any necessary operations
-- are handled by t'GI.Gio.Interfaces.AsyncResult.AsyncResult'\'s interface. However, if implementing a
-- new GIO module, for writing language bindings, or for complex
-- applications that need better control of how asynchronous operations
-- are completed, it is important to understand this functionality.
-- 
-- GSimpleAsyncResults are tagged with the calling function to ensure
-- that asynchronous functions and their finishing functions are used
-- together correctly.
-- 
-- To create a new t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult', call 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultNew'.
-- If the result needs to be created for a t'GError', use
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultNewFromError' or
-- @/g_simple_async_result_new_take_error()/@. If a t'GError' is not available
-- (e.g. the asynchronous operation\'s doesn\'t take a t'GError' argument),
-- but the result still needs to be created for an error condition, use
-- @/g_simple_async_result_new_error()/@ (or @/g_simple_async_result_set_error_va()/@
-- if your application or binding requires passing a variable argument list
-- directly), and the error can then be propagated through the use of
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultPropagateError'.
-- 
-- An asynchronous operation can be made to ignore a cancellation event by
-- calling 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultSetHandleCancellation' with a
-- t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' for the operation and 'P.False'. This is useful for
-- operations that are dangerous to cancel, such as close (which would
-- cause a leak if cancelled before being run).
-- 
-- GSimpleAsyncResult can integrate into GLib\'s event loop, t'GI.GLib.Structs.MainLoop.MainLoop',
-- or it can use @/GThreads/@.
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultComplete' will finish an I\/O task directly
-- from the point where it is called. 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultCompleteInIdle'
-- will finish it from an idle handler in the
-- [thread-default main context][g-main-context-push-thread-default]
-- where the t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' was created.
-- @/g_simple_async_result_run_in_thread()/@ will run the job in a
-- separate thread and then use
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultCompleteInIdle' to deliver the result.
-- 
-- To set the results of an asynchronous function,
-- @/g_simple_async_result_set_op_res_gpointer()/@,
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultSetOpResGboolean', and
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultSetOpResGssize'
-- are provided, setting the operation\'s result to a gpointer, gboolean, or
-- gssize, respectively.
-- 
-- Likewise, to get the result of an asynchronous function,
-- @/g_simple_async_result_get_op_res_gpointer()/@,
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultGetOpResGboolean', and
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultGetOpResGssize' are
-- provided, getting the operation\'s result as a gpointer, gboolean, and
-- gssize, respectively.
-- 
-- For the details of the requirements implementations must respect, see
-- t'GI.Gio.Interfaces.AsyncResult.AsyncResult'.  A typical implementation of an asynchronous operation
-- using GSimpleAsyncResult looks something like this:
-- 
-- 
-- === /C code/
-- >
-- >static void
-- >baked_cb (Cake    *cake,
-- >          gpointer user_data)
-- >{
-- >  // In this example, this callback is not given a reference to the cake,
-- >  // so the GSimpleAsyncResult has to take a reference to it.
-- >  GSimpleAsyncResult *result = user_data;
-- >
-- >  if (cake == NULL)
-- >    g_simple_async_result_set_error (result,
-- >                                     BAKER_ERRORS,
-- >                                     BAKER_ERROR_NO_FLOUR,
-- >                                     "Go to the supermarket");
-- >  else
-- >    g_simple_async_result_set_op_res_gpointer (result,
-- >                                               g_object_ref (cake),
-- >                                               g_object_unref);
-- >
-- >
-- >  // In this example, we assume that baked_cb is called as a callback from
-- >  // the mainloop, so it's safe to complete the operation synchronously here.
-- >  // If, however, _baker_prepare_cake () might call its callback without
-- >  // first returning to the mainloop — inadvisable, but some APIs do so —
-- >  // we would need to use g_simple_async_result_complete_in_idle().
-- >  g_simple_async_result_complete (result);
-- >  g_object_unref (result);
-- >}
-- >
-- >void
-- >baker_bake_cake_async (Baker              *self,
-- >                       guint               radius,
-- >                       GAsyncReadyCallback callback,
-- >                       gpointer            user_data)
-- >{
-- >  GSimpleAsyncResult *simple;
-- >  Cake               *cake;
-- >
-- >  if (radius < 3)
-- >    {
-- >      g_simple_async_report_error_in_idle (G_OBJECT (self),
-- >                                           callback,
-- >                                           user_data,
-- >                                           BAKER_ERRORS,
-- >                                           BAKER_ERROR_TOO_SMALL,
-- >                                           "%ucm radius cakes are silly",
-- >                                           radius);
-- >      return;
-- >    }
-- >
-- >  simple = g_simple_async_result_new (G_OBJECT (self),
-- >                                      callback,
-- >                                      user_data,
-- >                                      baker_bake_cake_async);
-- >  cake = _baker_get_cached_cake (self, radius);
-- >
-- >  if (cake != NULL)
-- >    {
-- >      g_simple_async_result_set_op_res_gpointer (simple,
-- >                                                 g_object_ref (cake),
-- >                                                 g_object_unref);
-- >      g_simple_async_result_complete_in_idle (simple);
-- >      g_object_unref (simple);
-- >      // Drop the reference returned by _baker_get_cached_cake();
-- >      // the GSimpleAsyncResult has taken its own reference.
-- >      g_object_unref (cake);
-- >      return;
-- >    }
-- >
-- >  _baker_prepare_cake (self, radius, baked_cb, simple);
-- >}
-- >
-- >Cake *
-- >baker_bake_cake_finish (Baker        *self,
-- >                        GAsyncResult *result,
-- >                        GError      **error)
-- >{
-- >  GSimpleAsyncResult *simple;
-- >  Cake               *cake;
-- >
-- >  g_return_val_if_fail (g_simple_async_result_is_valid (result,
-- >                                                        G_OBJECT (self),
-- >                                                        baker_bake_cake_async),
-- >                        NULL);
-- >
-- >  simple = (GSimpleAsyncResult *) result;
-- >
-- >  if (g_simple_async_result_propagate_error (simple, error))
-- >    return NULL;
-- >
-- >  cake = CAKE (g_simple_async_result_get_op_res_gpointer (simple));
-- >  return g_object_ref (cake);
-- >}
-- 

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gio.Objects.SimpleAsyncResult
    ( 

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


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveSimpleAsyncResultMethod          ,
#endif


-- ** complete #method:complete#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultCompleteMethodInfo     ,
#endif
    simpleAsyncResultComplete               ,


-- ** completeInIdle #method:completeInIdle#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultCompleteInIdleMethodInfo,
#endif
    simpleAsyncResultCompleteInIdle         ,


-- ** getOpResGboolean #method:getOpResGboolean#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultGetOpResGbooleanMethodInfo,
#endif
    simpleAsyncResultGetOpResGboolean       ,


-- ** getOpResGssize #method:getOpResGssize#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultGetOpResGssizeMethodInfo,
#endif
    simpleAsyncResultGetOpResGssize         ,


-- ** isValid #method:isValid#

    simpleAsyncResultIsValid                ,


-- ** new #method:new#

    simpleAsyncResultNew                    ,


-- ** newFromError #method:newFromError#

    simpleAsyncResultNewFromError           ,


-- ** propagateError #method:propagateError#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultPropagateErrorMethodInfo,
#endif
    simpleAsyncResultPropagateError         ,


-- ** setCheckCancellable #method:setCheckCancellable#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultSetCheckCancellableMethodInfo,
#endif
    simpleAsyncResultSetCheckCancellable    ,


-- ** setFromError #method:setFromError#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultSetFromErrorMethodInfo ,
#endif
    simpleAsyncResultSetFromError           ,


-- ** setHandleCancellation #method:setHandleCancellation#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultSetHandleCancellationMethodInfo,
#endif
    simpleAsyncResultSetHandleCancellation  ,


-- ** setOpResGboolean #method:setOpResGboolean#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultSetOpResGbooleanMethodInfo,
#endif
    simpleAsyncResultSetOpResGboolean       ,


-- ** setOpResGssize #method:setOpResGssize#

#if defined(ENABLE_OVERLOADING)
    SimpleAsyncResultSetOpResGssizeMethodInfo,
#endif
    simpleAsyncResultSetOpResGssize         ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable

-- | Memory-managed wrapper type.
newtype SimpleAsyncResult = SimpleAsyncResult (ManagedPtr SimpleAsyncResult)
    deriving (SimpleAsyncResult -> SimpleAsyncResult -> Bool
(SimpleAsyncResult -> SimpleAsyncResult -> Bool)
-> (SimpleAsyncResult -> SimpleAsyncResult -> Bool)
-> Eq SimpleAsyncResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimpleAsyncResult -> SimpleAsyncResult -> Bool
$c/= :: SimpleAsyncResult -> SimpleAsyncResult -> Bool
== :: SimpleAsyncResult -> SimpleAsyncResult -> Bool
$c== :: SimpleAsyncResult -> SimpleAsyncResult -> Bool
Eq)
foreign import ccall "g_simple_async_result_get_type"
    c_g_simple_async_result_get_type :: IO GType

instance GObject SimpleAsyncResult where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_simple_async_result_get_type
    

-- | Convert 'SimpleAsyncResult' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue SimpleAsyncResult where
    toGValue :: SimpleAsyncResult -> IO GValue
toGValue o :: SimpleAsyncResult
o = do
        GType
gtype <- IO GType
c_g_simple_async_result_get_type
        SimpleAsyncResult
-> (Ptr SimpleAsyncResult -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr SimpleAsyncResult
o (GType
-> (GValue -> Ptr SimpleAsyncResult -> IO ())
-> Ptr SimpleAsyncResult
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr SimpleAsyncResult -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO SimpleAsyncResult
fromGValue gv :: GValue
gv = do
        Ptr SimpleAsyncResult
ptr <- GValue -> IO (Ptr SimpleAsyncResult)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr SimpleAsyncResult)
        (ManagedPtr SimpleAsyncResult -> SimpleAsyncResult)
-> Ptr SimpleAsyncResult -> IO SimpleAsyncResult
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr SimpleAsyncResult -> SimpleAsyncResult
SimpleAsyncResult Ptr SimpleAsyncResult
ptr
        
    

-- | Type class for types which can be safely cast to `SimpleAsyncResult`, for instance with `toSimpleAsyncResult`.
class (GObject o, O.IsDescendantOf SimpleAsyncResult o) => IsSimpleAsyncResult o
instance (GObject o, O.IsDescendantOf SimpleAsyncResult o) => IsSimpleAsyncResult o

instance O.HasParentTypes SimpleAsyncResult
type instance O.ParentTypes SimpleAsyncResult = '[GObject.Object.Object, Gio.AsyncResult.AsyncResult]

-- | Cast to `SimpleAsyncResult`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toSimpleAsyncResult :: (MonadIO m, IsSimpleAsyncResult o) => o -> m SimpleAsyncResult
toSimpleAsyncResult :: o -> m SimpleAsyncResult
toSimpleAsyncResult = IO SimpleAsyncResult -> m SimpleAsyncResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SimpleAsyncResult -> m SimpleAsyncResult)
-> (o -> IO SimpleAsyncResult) -> o -> m SimpleAsyncResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr SimpleAsyncResult -> SimpleAsyncResult)
-> o -> IO SimpleAsyncResult
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr SimpleAsyncResult -> SimpleAsyncResult
SimpleAsyncResult

-- | A convenience alias for `Nothing` :: `Maybe` `SimpleAsyncResult`.
noSimpleAsyncResult :: Maybe SimpleAsyncResult
noSimpleAsyncResult :: Maybe SimpleAsyncResult
noSimpleAsyncResult = Maybe SimpleAsyncResult
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveSimpleAsyncResultMethod (t :: Symbol) (o :: *) :: * where
    ResolveSimpleAsyncResultMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSimpleAsyncResultMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSimpleAsyncResultMethod "complete" o = SimpleAsyncResultCompleteMethodInfo
    ResolveSimpleAsyncResultMethod "completeInIdle" o = SimpleAsyncResultCompleteInIdleMethodInfo
    ResolveSimpleAsyncResultMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSimpleAsyncResultMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSimpleAsyncResultMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveSimpleAsyncResultMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSimpleAsyncResultMethod "isTagged" o = Gio.AsyncResult.AsyncResultIsTaggedMethodInfo
    ResolveSimpleAsyncResultMethod "legacyPropagateError" o = Gio.AsyncResult.AsyncResultLegacyPropagateErrorMethodInfo
    ResolveSimpleAsyncResultMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSimpleAsyncResultMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSimpleAsyncResultMethod "propagateError" o = SimpleAsyncResultPropagateErrorMethodInfo
    ResolveSimpleAsyncResultMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSimpleAsyncResultMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSimpleAsyncResultMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSimpleAsyncResultMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSimpleAsyncResultMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSimpleAsyncResultMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSimpleAsyncResultMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSimpleAsyncResultMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSimpleAsyncResultMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSimpleAsyncResultMethod "getOpResGboolean" o = SimpleAsyncResultGetOpResGbooleanMethodInfo
    ResolveSimpleAsyncResultMethod "getOpResGssize" o = SimpleAsyncResultGetOpResGssizeMethodInfo
    ResolveSimpleAsyncResultMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSimpleAsyncResultMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSimpleAsyncResultMethod "getSourceObject" o = Gio.AsyncResult.AsyncResultGetSourceObjectMethodInfo
    ResolveSimpleAsyncResultMethod "getUserData" o = Gio.AsyncResult.AsyncResultGetUserDataMethodInfo
    ResolveSimpleAsyncResultMethod "setCheckCancellable" o = SimpleAsyncResultSetCheckCancellableMethodInfo
    ResolveSimpleAsyncResultMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSimpleAsyncResultMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveSimpleAsyncResultMethod "setFromError" o = SimpleAsyncResultSetFromErrorMethodInfo
    ResolveSimpleAsyncResultMethod "setHandleCancellation" o = SimpleAsyncResultSetHandleCancellationMethodInfo
    ResolveSimpleAsyncResultMethod "setOpResGboolean" o = SimpleAsyncResultSetOpResGbooleanMethodInfo
    ResolveSimpleAsyncResultMethod "setOpResGssize" o = SimpleAsyncResultSetOpResGssizeMethodInfo
    ResolveSimpleAsyncResultMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSimpleAsyncResultMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSimpleAsyncResultMethod t SimpleAsyncResult, O.MethodInfo info SimpleAsyncResult p) => OL.IsLabel t (SimpleAsyncResult -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList SimpleAsyncResult
type instance O.AttributeList SimpleAsyncResult = SimpleAsyncResultAttributeList
type SimpleAsyncResultAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList SimpleAsyncResult = SimpleAsyncResultSignalList
type SimpleAsyncResultSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method SimpleAsyncResult::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "source_object"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject, or %NULL."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncReadyCallback" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GAsyncReadyCallback."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 2
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data passed to @callback."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "source_tag"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the asynchronous function."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "SimpleAsyncResult" })
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_new" g_simple_async_result_new :: 
    Ptr GObject.Object.Object ->            -- source_object : TInterface (Name {namespace = "GObject", name = "Object"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    Ptr () ->                               -- source_tag : TBasicType TPtr
    IO (Ptr SimpleAsyncResult)

{-# DEPRECATED simpleAsyncResultNew ["(Since version 2.46)","Use 'GI.Gio.Objects.Task.taskNew' instead."] #-}
-- | Creates a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
-- 
-- The common convention is to create the t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' in the
-- function that starts the asynchronous operation and use that same
-- function as the /@sourceTag@/.
-- 
-- If your operation supports cancellation with t'GI.Gio.Objects.Cancellable.Cancellable' (which it
-- probably should) then you should provide the user\'s cancellable to
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultSetCheckCancellable' immediately after
-- this function returns.
simpleAsyncResultNew ::
    (B.CallStack.HasCallStack, MonadIO m, GObject.Object.IsObject a) =>
    Maybe (a)
    -- ^ /@sourceObject@/: a t'GI.GObject.Objects.Object.Object', or 'P.Nothing'.
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: a t'GI.Gio.Callbacks.AsyncReadyCallback'.
    -> Ptr ()
    -- ^ /@sourceTag@/: the asynchronous function.
    -> m SimpleAsyncResult
    -- ^ __Returns:__ a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
simpleAsyncResultNew :: Maybe a
-> Maybe AsyncReadyCallback -> Ptr () -> m SimpleAsyncResult
simpleAsyncResultNew sourceObject :: Maybe a
sourceObject callback :: Maybe AsyncReadyCallback
callback sourceTag :: Ptr ()
sourceTag = IO SimpleAsyncResult -> m SimpleAsyncResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SimpleAsyncResult -> m SimpleAsyncResult)
-> IO SimpleAsyncResult -> m SimpleAsyncResult
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
maybeSourceObject <- case Maybe a
sourceObject of
        Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just jSourceObject :: a
jSourceObject -> do
            Ptr Object
jSourceObject' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jSourceObject
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jSourceObject'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr SimpleAsyncResult
result <- Ptr Object
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> Ptr ()
-> IO (Ptr SimpleAsyncResult)
g_simple_async_result_new Ptr Object
maybeSourceObject FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData Ptr ()
sourceTag
    Text -> Ptr SimpleAsyncResult -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "simpleAsyncResultNew" Ptr SimpleAsyncResult
result
    SimpleAsyncResult
result' <- ((ManagedPtr SimpleAsyncResult -> SimpleAsyncResult)
-> Ptr SimpleAsyncResult -> IO SimpleAsyncResult
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr SimpleAsyncResult -> SimpleAsyncResult
SimpleAsyncResult) Ptr SimpleAsyncResult
result
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
sourceObject a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    SimpleAsyncResult -> IO SimpleAsyncResult
forall (m :: * -> *) a. Monad m => a -> m a
return SimpleAsyncResult
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method SimpleAsyncResult::new_from_error
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "source_object"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject, or %NULL."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncReadyCallback" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GAsyncReadyCallback."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 2
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data passed to @callback."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "error"
--           , argType = TError
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GError" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "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.Object ->            -- source_object : TInterface (Name {namespace = "GObject", name = "Object"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    Ptr GError ->                           -- error : TError
    IO (Ptr SimpleAsyncResult)

{-# DEPRECATED simpleAsyncResultNewFromError ["(Since version 2.46)","Use 'GI.Gio.Objects.Task.taskNew' and 'GI.Gio.Objects.Task.taskReturnError' instead."] #-}
-- | Creates a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' from an error condition.
simpleAsyncResultNewFromError ::
    (B.CallStack.HasCallStack, MonadIO m, GObject.Object.IsObject a) =>
    Maybe (a)
    -- ^ /@sourceObject@/: a t'GI.GObject.Objects.Object.Object', or 'P.Nothing'.
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: a t'GI.Gio.Callbacks.AsyncReadyCallback'.
    -> GError
    -- ^ /@error@/: a t'GError'
    -> m SimpleAsyncResult
    -- ^ __Returns:__ a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
simpleAsyncResultNewFromError :: Maybe a
-> Maybe AsyncReadyCallback -> GError -> m SimpleAsyncResult
simpleAsyncResultNewFromError sourceObject :: Maybe a
sourceObject callback :: Maybe AsyncReadyCallback
callback error_ :: GError
error_ = IO SimpleAsyncResult -> m SimpleAsyncResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SimpleAsyncResult -> m SimpleAsyncResult)
-> IO SimpleAsyncResult -> m SimpleAsyncResult
forall a b. (a -> b) -> a -> b
$ do
    Ptr Object
maybeSourceObject <- case Maybe a
sourceObject of
        Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just jSourceObject :: a
jSourceObject -> do
            Ptr Object
jSourceObject' <- a -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jSourceObject
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jSourceObject'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    Ptr GError
error_' <- GError -> IO (Ptr GError)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GError
error_
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr SimpleAsyncResult
result <- Ptr Object
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> Ptr GError
-> IO (Ptr SimpleAsyncResult)
g_simple_async_result_new_from_error Ptr Object
maybeSourceObject FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData Ptr GError
error_'
    Text -> Ptr SimpleAsyncResult -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "simpleAsyncResultNewFromError" Ptr SimpleAsyncResult
result
    SimpleAsyncResult
result' <- ((ManagedPtr SimpleAsyncResult -> SimpleAsyncResult)
-> Ptr SimpleAsyncResult -> IO SimpleAsyncResult
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr SimpleAsyncResult -> SimpleAsyncResult
SimpleAsyncResult) Ptr SimpleAsyncResult
result
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
sourceObject a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    GError -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GError
error_
    SimpleAsyncResult -> IO SimpleAsyncResult
forall (m :: * -> *) a. Monad m => a -> m a
return SimpleAsyncResult
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method SimpleAsyncResult::complete
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_complete" g_simple_async_result_complete :: 
    Ptr SimpleAsyncResult ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    IO ()

{-# DEPRECATED simpleAsyncResultComplete ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' instead."] #-}
-- | Completes an asynchronous I\/O job immediately. Must be called in
-- the thread where the asynchronous result was to be delivered, as it
-- invokes the callback directly. If you are in a different thread use
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultCompleteInIdle'.
-- 
-- Calling this function takes a reference to /@simple@/ for as long as
-- is needed to complete the call.
simpleAsyncResultComplete ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> m ()
simpleAsyncResultComplete :: a -> m ()
simpleAsyncResultComplete simple :: a
simple = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    Ptr SimpleAsyncResult -> IO ()
g_simple_async_result_complete Ptr SimpleAsyncResult
simple'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultCompleteMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultCompleteMethodInfo a signature where
    overloadedMethod = simpleAsyncResultComplete

#endif

-- method SimpleAsyncResult::complete_in_idle
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_complete_in_idle" g_simple_async_result_complete_in_idle :: 
    Ptr SimpleAsyncResult ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    IO ()

{-# DEPRECATED simpleAsyncResultCompleteInIdle ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' instead."] #-}
-- | Completes an asynchronous function in an idle handler in the
-- [thread-default main context][g-main-context-push-thread-default]
-- of the thread that /@simple@/ was initially created in
-- (and re-pushes that context around the invocation of the callback).
-- 
-- Calling this function takes a reference to /@simple@/ for as long as
-- is needed to complete the call.
simpleAsyncResultCompleteInIdle ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> m ()
simpleAsyncResultCompleteInIdle :: a -> m ()
simpleAsyncResultCompleteInIdle simple :: a
simple = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    Ptr SimpleAsyncResult -> IO ()
g_simple_async_result_complete_in_idle Ptr SimpleAsyncResult
simple'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultCompleteInIdleMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultCompleteInIdleMethodInfo a signature where
    overloadedMethod = simpleAsyncResultCompleteInIdle

#endif

-- method SimpleAsyncResult::get_op_res_gboolean
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (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 ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    IO CInt

{-# DEPRECATED simpleAsyncResultGetOpResGboolean ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' and 'GI.Gio.Objects.Task.taskPropagateBoolean' instead."] #-}
-- | Gets the operation result boolean from within the asynchronous result.
simpleAsyncResultGetOpResGboolean ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the operation\'s result was 'P.True', 'P.False'
    --     if the operation\'s result was 'P.False'.
simpleAsyncResultGetOpResGboolean :: a -> m Bool
simpleAsyncResultGetOpResGboolean simple :: a
simple = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    CInt
result <- Ptr SimpleAsyncResult -> IO CInt
g_simple_async_result_get_op_res_gboolean Ptr SimpleAsyncResult
simple'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultGetOpResGbooleanMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultGetOpResGbooleanMethodInfo a signature where
    overloadedMethod = simpleAsyncResultGetOpResGboolean

#endif

-- method SimpleAsyncResult::get_op_res_gssize
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (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 ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    IO Int64

{-# DEPRECATED simpleAsyncResultGetOpResGssize ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' and 'GI.Gio.Objects.Task.taskPropagateInt' instead."] #-}
-- | Gets a gssize from the asynchronous result.
simpleAsyncResultGetOpResGssize ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> m Int64
    -- ^ __Returns:__ a gssize returned from the asynchronous function.
simpleAsyncResultGetOpResGssize :: a -> m Int64
simpleAsyncResultGetOpResGssize simple :: a
simple = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    Int64
result <- Ptr SimpleAsyncResult -> IO Int64
g_simple_async_result_get_op_res_gssize Ptr SimpleAsyncResult
simple'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultGetOpResGssizeMethodInfo
instance (signature ~ (m Int64), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultGetOpResGssizeMethodInfo a signature where
    overloadedMethod = simpleAsyncResultGetOpResGssize

#endif

-- method SimpleAsyncResult::propagate_error
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_simple_async_result_propagate_error" g_simple_async_result_propagate_error :: 
    Ptr SimpleAsyncResult ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED simpleAsyncResultPropagateError ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' instead."] #-}
-- | Propagates an error from within the simple asynchronous result to
-- a given destination.
-- 
-- If the t'GI.Gio.Objects.Cancellable.Cancellable' given to a prior call to
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultSetCheckCancellable' is cancelled then this
-- function will return 'P.True' with /@dest@/ set appropriately.
simpleAsyncResultPropagateError ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
simpleAsyncResultPropagateError :: a -> m ()
simpleAsyncResultPropagateError simple :: a
simple = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr SimpleAsyncResult -> Ptr (Ptr GError) -> IO CInt
g_simple_async_result_propagate_error Ptr SimpleAsyncResult
simple'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultPropagateErrorMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultPropagateErrorMethodInfo a signature where
    overloadedMethod = simpleAsyncResultPropagateError

#endif

-- method SimpleAsyncResult::set_check_cancellable
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "check_cancellable"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "Cancellable" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GCancellable to check, or %NULL to unset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_set_check_cancellable" g_simple_async_result_set_check_cancellable :: 
    Ptr SimpleAsyncResult ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    Ptr Gio.Cancellable.Cancellable ->      -- check_cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    IO ()

{-# DEPRECATED simpleAsyncResultSetCheckCancellable ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' instead."] #-}
-- | Sets a t'GI.Gio.Objects.Cancellable.Cancellable' to check before dispatching results.
-- 
-- This function has one very specific purpose: the provided cancellable
-- is checked at the time of 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultPropagateError' If
-- it is cancelled, these functions will return an \"Operation was
-- cancelled\" error ('GI.Gio.Enums.IOErrorEnumCancelled').
-- 
-- Implementors of cancellable asynchronous functions should use this in
-- order to provide a guarantee to their callers that cancelling an
-- async operation will reliably result in an error being returned for
-- that operation (even if a positive result for the operation has
-- already been sent as an idle to the main context to be dispatched).
-- 
-- The checking described above is done regardless of any call to the
-- unrelated 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultSetHandleCancellation' function.
-- 
-- /Since: 2.32/
simpleAsyncResultSetCheckCancellable ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'
    -> Maybe (b)
    -- ^ /@checkCancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable' to check, or 'P.Nothing' to unset
    -> m ()
simpleAsyncResultSetCheckCancellable :: a -> Maybe b -> m ()
simpleAsyncResultSetCheckCancellable simple :: a
simple checkCancellable :: Maybe b
checkCancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    Ptr Cancellable
maybeCheckCancellable <- case Maybe b
checkCancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCheckCancellable :: b
jCheckCancellable -> do
            Ptr Cancellable
jCheckCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCheckCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCheckCancellable'
    Ptr SimpleAsyncResult -> Ptr Cancellable -> IO ()
g_simple_async_result_set_check_cancellable Ptr SimpleAsyncResult
simple' Ptr Cancellable
maybeCheckCancellable
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
checkCancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultSetCheckCancellableMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSimpleAsyncResult a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SimpleAsyncResultSetCheckCancellableMethodInfo a signature where
    overloadedMethod = simpleAsyncResultSetCheckCancellable

#endif

-- method SimpleAsyncResult::set_from_error
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "error"
--           , argType = TError
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GError." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_set_from_error" g_simple_async_result_set_from_error :: 
    Ptr SimpleAsyncResult ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    Ptr GError ->                           -- error : TError
    IO ()

{-# DEPRECATED simpleAsyncResultSetFromError ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' and 'GI.Gio.Objects.Task.taskReturnError' instead."] #-}
-- | Sets the result from a t'GError'.
simpleAsyncResultSetFromError ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> GError
    -- ^ /@error@/: t'GError'.
    -> m ()
simpleAsyncResultSetFromError :: a -> GError -> m ()
simpleAsyncResultSetFromError simple :: a
simple error_ :: GError
error_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    Ptr GError
error_' <- GError -> IO (Ptr GError)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GError
error_
    Ptr SimpleAsyncResult -> Ptr GError -> IO ()
g_simple_async_result_set_from_error Ptr SimpleAsyncResult
simple' Ptr GError
error_'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    GError -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GError
error_
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultSetFromErrorMethodInfo
instance (signature ~ (GError -> m ()), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultSetFromErrorMethodInfo a signature where
    overloadedMethod = simpleAsyncResultSetFromError

#endif

-- method SimpleAsyncResult::set_handle_cancellation
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "handle_cancellation"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #gboolean." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_set_handle_cancellation" g_simple_async_result_set_handle_cancellation :: 
    Ptr SimpleAsyncResult ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    CInt ->                                 -- handle_cancellation : TBasicType TBoolean
    IO ()

{-# DEPRECATED simpleAsyncResultSetHandleCancellation ["(Since version 2.46)"] #-}
-- | Sets whether to handle cancellation within the asynchronous operation.
-- 
-- This function has nothing to do with
-- 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultSetCheckCancellable'.  It only refers to the
-- t'GI.Gio.Objects.Cancellable.Cancellable' passed to @/g_simple_async_result_run_in_thread()/@.
simpleAsyncResultSetHandleCancellation ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> Bool
    -- ^ /@handleCancellation@/: a t'P.Bool'.
    -> m ()
simpleAsyncResultSetHandleCancellation :: a -> Bool -> m ()
simpleAsyncResultSetHandleCancellation simple :: a
simple handleCancellation :: Bool
handleCancellation = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    let handleCancellation' :: CInt
handleCancellation' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
handleCancellation
    Ptr SimpleAsyncResult -> CInt -> IO ()
g_simple_async_result_set_handle_cancellation Ptr SimpleAsyncResult
simple' CInt
handleCancellation'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultSetHandleCancellationMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultSetHandleCancellationMethodInfo a signature where
    overloadedMethod = simpleAsyncResultSetHandleCancellation

#endif

-- method SimpleAsyncResult::set_op_res_gboolean
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "op_res"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #gboolean." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- 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 ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    CInt ->                                 -- op_res : TBasicType TBoolean
    IO ()

{-# DEPRECATED simpleAsyncResultSetOpResGboolean ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' and 'GI.Gio.Objects.Task.taskReturnBoolean' instead."] #-}
-- | Sets the operation result to a boolean within the asynchronous result.
simpleAsyncResultSetOpResGboolean ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> Bool
    -- ^ /@opRes@/: a t'P.Bool'.
    -> m ()
simpleAsyncResultSetOpResGboolean :: a -> Bool -> m ()
simpleAsyncResultSetOpResGboolean simple :: a
simple opRes :: Bool
opRes = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    let opRes' :: CInt
opRes' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
opRes
    Ptr SimpleAsyncResult -> CInt -> IO ()
g_simple_async_result_set_op_res_gboolean Ptr SimpleAsyncResult
simple' CInt
opRes'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultSetOpResGbooleanMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultSetOpResGbooleanMethodInfo a signature where
    overloadedMethod = simpleAsyncResultSetOpResGboolean

#endif

-- method SimpleAsyncResult::set_op_res_gssize
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "simple"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "SimpleAsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSimpleAsyncResult."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "op_res"
--           , argType = TBasicType TInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #gssize." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- 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 ->                -- simple : TInterface (Name {namespace = "Gio", name = "SimpleAsyncResult"})
    Int64 ->                                -- op_res : TBasicType TInt64
    IO ()

{-# DEPRECATED simpleAsyncResultSetOpResGssize ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' and 'GI.Gio.Objects.Task.taskReturnInt' instead."] #-}
-- | Sets the operation result within the asynchronous result to
-- the given /@opRes@/.
simpleAsyncResultSetOpResGssize ::
    (B.CallStack.HasCallStack, MonadIO m, IsSimpleAsyncResult a) =>
    a
    -- ^ /@simple@/: a t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
    -> Int64
    -- ^ /@opRes@/: a @/gssize/@.
    -> m ()
simpleAsyncResultSetOpResGssize :: a -> Int64 -> m ()
simpleAsyncResultSetOpResGssize simple :: a
simple opRes :: Int64
opRes = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr SimpleAsyncResult
simple' <- a -> IO (Ptr SimpleAsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
simple
    Ptr SimpleAsyncResult -> Int64 -> IO ()
g_simple_async_result_set_op_res_gssize Ptr SimpleAsyncResult
simple' Int64
opRes
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
simple
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data SimpleAsyncResultSetOpResGssizeMethodInfo
instance (signature ~ (Int64 -> m ()), MonadIO m, IsSimpleAsyncResult a) => O.MethodInfo SimpleAsyncResultSetOpResGssizeMethodInfo a signature where
    overloadedMethod = simpleAsyncResultSetOpResGssize

#endif

-- method SimpleAsyncResult::is_valid
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "result"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncResult" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the #GAsyncResult passed to the _finish function."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "source"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "Object" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #GObject passed to the _finish function."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "source_tag"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the asynchronous function."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_simple_async_result_is_valid" g_simple_async_result_is_valid :: 
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr GObject.Object.Object ->            -- source : TInterface (Name {namespace = "GObject", name = "Object"})
    Ptr () ->                               -- source_tag : TBasicType TPtr
    IO CInt

{-# DEPRECATED simpleAsyncResultIsValid ["(Since version 2.46)","Use t'GI.Gio.Objects.Task.Task' and 'GI.Gio.Objects.Task.taskIsValid' instead."] #-}
-- | Ensures that the data passed to the _finish function of an async
-- operation is consistent.  Three checks are performed.
-- 
-- First, /@result@/ is checked to ensure that it is really a
-- t'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.  Second, /@source@/ is checked to ensure that it
-- matches the source object of /@result@/.  Third, /@sourceTag@/ is
-- checked to ensure that it is equal to the /@sourceTag@/ argument given
-- to 'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultNew' (which, by convention, is a pointer
-- to the _async function corresponding to the _finish function from
-- which this function is called).  (Alternatively, if either
-- /@sourceTag@/ or /@result@/\'s source tag is 'P.Nothing', then the source tag
-- check is skipped.)
-- 
-- /Since: 2.20/
simpleAsyncResultIsValid ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a, GObject.Object.IsObject b) =>
    a
    -- ^ /@result@/: the t'GI.Gio.Interfaces.AsyncResult.AsyncResult' passed to the _finish function.
    -> Maybe (b)
    -- ^ /@source@/: the t'GI.GObject.Objects.Object.Object' passed to the _finish function.
    -> Ptr ()
    -- ^ /@sourceTag@/: the asynchronous function.
    -> m Bool
    -- ^ __Returns:__ @/TRUE/@ if all checks passed or @/FALSE/@ if any failed.
simpleAsyncResultIsValid :: a -> Maybe b -> Ptr () -> m Bool
simpleAsyncResultIsValid result_ :: a
result_ source :: Maybe b
source sourceTag :: Ptr ()
sourceTag = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr AsyncResult
result_' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
result_
    Ptr Object
maybeSource <- case Maybe b
source of
        Nothing -> Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
forall a. Ptr a
nullPtr
        Just jSource :: b
jSource -> do
            Ptr Object
jSource' <- b -> IO (Ptr Object)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jSource
            Ptr Object -> IO (Ptr Object)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Object
jSource'
    CInt
result <- Ptr AsyncResult -> Ptr Object -> Ptr () -> IO CInt
g_simple_async_result_is_valid Ptr AsyncResult
result_' Ptr Object
maybeSource Ptr ()
sourceTag
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
result_
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
source b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
#endif