module System.GIO.Async.Cancellable (
Cancellable,
cancellableNew,
cancellableIsCancelled,
cancellableThrowErrorIfCancelled,
cancellableGetCurrent,
cancellablePopCurrent,
cancellablePushCurrent,
cancellableReset,
cancellableCancel,
cancellableCancelled
) where
import Control.Monad
import System.Glib.FFI
import System.Glib.GError
import System.GIO.Signals
import System.GIO.Base
import System.GIO.Types
cancellableNew :: IO Cancellable
cancellableNew =
g_cancellable_new >>= takeGObject
cancellableIsCancelled :: Cancellable -> IO Bool
cancellableIsCancelled =
liftM toBool . (\(Cancellable arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_cancellable_is_cancelled argPtr1)
cancellableThrowErrorIfCancelled :: Cancellable -> IO ()
cancellableThrowErrorIfCancelled cancellable =
propagateGError $ \gErrorPtr -> do
(\(Cancellable arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->g_cancellable_set_error_if_cancelled argPtr1 arg2) cancellable gErrorPtr
return ()
cancellableGetCurrent :: IO (Maybe Cancellable)
cancellableGetCurrent =
g_cancellable_get_current >>= maybePeek takeGObject
cancellablePopCurrent :: Maybe Cancellable -> IO ()
cancellablePopCurrent cancellable =
maybeWith withGObject cancellable g_cancellable_pop_current
where
_ = (\(Cancellable arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_cancellable_pop_current argPtr1)
cancellablePushCurrent :: Maybe Cancellable -> IO ()
cancellablePushCurrent cancellable =
maybeWith withGObject cancellable g_cancellable_push_current
where
_ = (\(Cancellable arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_cancellable_push_current argPtr1)
cancellableReset :: Cancellable -> IO ()
cancellableReset = (\(Cancellable arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_cancellable_reset argPtr1)
cancellableCancel :: Cancellable -> IO ()
cancellableCancel = (\(Cancellable arg1) -> withForeignPtr arg1 $ \argPtr1 ->g_cancellable_cancel argPtr1)
cancellableCancelled :: Signal Cancellable (IO ())
cancellableCancelled =
Signal $ connect_NONE__NONE "cancelled"
foreign import ccall safe "g_cancellable_new"
g_cancellable_new :: (IO (Ptr Cancellable))
foreign import ccall safe "g_cancellable_is_cancelled"
g_cancellable_is_cancelled :: ((Ptr Cancellable) -> (IO CInt))
foreign import ccall safe "g_cancellable_set_error_if_cancelled"
g_cancellable_set_error_if_cancelled :: ((Ptr Cancellable) -> ((Ptr (Ptr ())) -> (IO CInt)))
foreign import ccall safe "g_cancellable_get_current"
g_cancellable_get_current :: (IO (Ptr Cancellable))
foreign import ccall safe "g_cancellable_pop_current"
g_cancellable_pop_current :: ((Ptr Cancellable) -> (IO ()))
foreign import ccall safe "g_cancellable_push_current"
g_cancellable_push_current :: ((Ptr Cancellable) -> (IO ()))
foreign import ccall safe "g_cancellable_reset"
g_cancellable_reset :: ((Ptr Cancellable) -> (IO ()))
foreign import ccall safe "g_cancellable_cancel"
g_cancellable_cancel :: ((Ptr Cancellable) -> (IO ()))