{-# LANGUAGE ImplicitParams, RankNTypes, TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Objects.Cancellable
(
Cancellable(..) ,
IsCancellable ,
toCancellable ,
#if defined(ENABLE_OVERLOADING)
ResolveCancellableMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
CancellableCancelMethodInfo ,
#endif
cancellableCancel ,
#if defined(ENABLE_OVERLOADING)
CancellableConnectMethodInfo ,
#endif
cancellableConnect ,
#if defined(ENABLE_OVERLOADING)
CancellableDisconnectMethodInfo ,
#endif
cancellableDisconnect ,
cancellableGetCurrent ,
#if defined(ENABLE_OVERLOADING)
CancellableGetFdMethodInfo ,
#endif
cancellableGetFd ,
#if defined(ENABLE_OVERLOADING)
CancellableIsCancelledMethodInfo ,
#endif
cancellableIsCancelled ,
#if defined(ENABLE_OVERLOADING)
CancellableMakePollfdMethodInfo ,
#endif
cancellableMakePollfd ,
cancellableNew ,
#if defined(ENABLE_OVERLOADING)
CancellablePopCurrentMethodInfo ,
#endif
cancellablePopCurrent ,
#if defined(ENABLE_OVERLOADING)
CancellablePushCurrentMethodInfo ,
#endif
cancellablePushCurrent ,
#if defined(ENABLE_OVERLOADING)
CancellableReleaseFdMethodInfo ,
#endif
cancellableReleaseFd ,
#if defined(ENABLE_OVERLOADING)
CancellableResetMethodInfo ,
#endif
cancellableReset ,
#if defined(ENABLE_OVERLOADING)
CancellableSetErrorIfCancelledMethodInfo,
#endif
cancellableSetErrorIfCancelled ,
#if defined(ENABLE_OVERLOADING)
CancellableSourceNewMethodInfo ,
#endif
cancellableSourceNew ,
CancellableCancelledCallback ,
#if defined(ENABLE_OVERLOADING)
CancellableCancelledSignalInfo ,
#endif
afterCancellableCancelled ,
onCancellableCancelled ,
) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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 Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.PollFD as GLib.PollFD
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Callbacks as GObject.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
#else
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.PollFD as GLib.PollFD
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Callbacks as GObject.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
#endif
newtype Cancellable = Cancellable (SP.ManagedPtr Cancellable)
deriving (Cancellable -> Cancellable -> Bool
(Cancellable -> Cancellable -> Bool)
-> (Cancellable -> Cancellable -> Bool) -> Eq Cancellable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Cancellable -> Cancellable -> Bool
== :: Cancellable -> Cancellable -> Bool
$c/= :: Cancellable -> Cancellable -> Bool
/= :: Cancellable -> Cancellable -> Bool
Eq)
instance SP.ManagedPtrNewtype Cancellable where
toManagedPtr :: Cancellable -> ManagedPtr Cancellable
toManagedPtr (Cancellable ManagedPtr Cancellable
p) = ManagedPtr Cancellable
p
foreign import ccall "g_cancellable_get_type"
c_g_cancellable_get_type :: IO B.Types.GType
instance B.Types.TypedObject Cancellable where
glibType :: IO GType
glibType = IO GType
c_g_cancellable_get_type
instance B.Types.GObject Cancellable
class (SP.GObject o, O.IsDescendantOf Cancellable o) => IsCancellable o
instance (SP.GObject o, O.IsDescendantOf Cancellable o) => IsCancellable o
instance O.HasParentTypes Cancellable
type instance O.ParentTypes Cancellable = '[GObject.Object.Object]
toCancellable :: (MIO.MonadIO m, IsCancellable o) => o -> m Cancellable
toCancellable :: forall (m :: * -> *) o.
(MonadIO m, IsCancellable o) =>
o -> m Cancellable
toCancellable = IO Cancellable -> m Cancellable
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Cancellable -> m Cancellable)
-> (o -> IO Cancellable) -> o -> m Cancellable
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Cancellable -> Cancellable) -> o -> IO Cancellable
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr Cancellable -> Cancellable
Cancellable
instance B.GValue.IsGValue (Maybe Cancellable) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_cancellable_get_type
gvalueSet_ :: Ptr GValue -> Maybe Cancellable -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Cancellable
P.Nothing = Ptr GValue -> Ptr Cancellable -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr Cancellable
forall a. Ptr a
FP.nullPtr :: FP.Ptr Cancellable)
gvalueSet_ Ptr GValue
gv (P.Just Cancellable
obj) = Cancellable -> (Ptr Cancellable -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Cancellable
obj (Ptr GValue -> Ptr Cancellable -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Cancellable)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr Cancellable)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr Cancellable)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject Cancellable ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveCancellableMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveCancellableMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveCancellableMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveCancellableMethod "cancel" o = CancellableCancelMethodInfo
ResolveCancellableMethod "connect" o = CancellableConnectMethodInfo
ResolveCancellableMethod "disconnect" o = CancellableDisconnectMethodInfo
ResolveCancellableMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveCancellableMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveCancellableMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveCancellableMethod "isCancelled" o = CancellableIsCancelledMethodInfo
ResolveCancellableMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveCancellableMethod "makePollfd" o = CancellableMakePollfdMethodInfo
ResolveCancellableMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveCancellableMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveCancellableMethod "popCurrent" o = CancellablePopCurrentMethodInfo
ResolveCancellableMethod "pushCurrent" o = CancellablePushCurrentMethodInfo
ResolveCancellableMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveCancellableMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveCancellableMethod "releaseFd" o = CancellableReleaseFdMethodInfo
ResolveCancellableMethod "reset" o = CancellableResetMethodInfo
ResolveCancellableMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveCancellableMethod "sourceNew" o = CancellableSourceNewMethodInfo
ResolveCancellableMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveCancellableMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveCancellableMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveCancellableMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveCancellableMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveCancellableMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveCancellableMethod "getFd" o = CancellableGetFdMethodInfo
ResolveCancellableMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveCancellableMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveCancellableMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveCancellableMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveCancellableMethod "setErrorIfCancelled" o = CancellableSetErrorIfCancelledMethodInfo
ResolveCancellableMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveCancellableMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveCancellableMethod t Cancellable, O.OverloadedMethod info Cancellable p) => OL.IsLabel t (Cancellable -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveCancellableMethod t Cancellable, O.OverloadedMethod info Cancellable p, R.HasField t Cancellable p) => R.HasField t Cancellable p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveCancellableMethod t Cancellable, O.OverloadedMethodInfo info Cancellable) => OL.IsLabel t (O.MethodProxy info Cancellable) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
type CancellableCancelledCallback =
IO ()
type C_CancellableCancelledCallback =
Ptr Cancellable ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mk_CancellableCancelledCallback :: C_CancellableCancelledCallback -> IO (FunPtr C_CancellableCancelledCallback)
wrap_CancellableCancelledCallback ::
GObject a => (a -> CancellableCancelledCallback) ->
C_CancellableCancelledCallback
wrap_CancellableCancelledCallback :: forall a.
GObject a =>
(a -> IO ()) -> C_CancellableCancelledCallback
wrap_CancellableCancelledCallback a -> IO ()
gi'cb Ptr Cancellable
gi'selfPtr Ptr ()
_ = do
Ptr Cancellable -> (Cancellable -> IO ()) -> IO ()
forall o b.
(HasCallStack, GObject o) =>
Ptr o -> (o -> IO b) -> IO b
B.ManagedPtr.withNewObject Ptr Cancellable
gi'selfPtr ((Cancellable -> IO ()) -> IO ())
-> (Cancellable -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Cancellable
gi'self -> a -> IO ()
gi'cb (Cancellable -> a
forall a b. Coercible a b => a -> b
Coerce.coerce Cancellable
gi'self)
onCancellableCancelled :: (IsCancellable a, MonadIO m) => a -> ((?self :: a) => CancellableCancelledCallback) -> m SignalHandlerId
onCancellableCancelled :: forall a (m :: * -> *).
(IsCancellable a, MonadIO m) =>
a -> ((?self::a) => IO ()) -> m SignalHandlerId
onCancellableCancelled a
obj (?self::a) => IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
let wrapped :: a -> IO ()
wrapped a
self = let ?self = a
?self::a
self in IO ()
(?self::a) => IO ()
cb
let wrapped' :: C_CancellableCancelledCallback
wrapped' = (a -> IO ()) -> C_CancellableCancelledCallback
forall a.
GObject a =>
(a -> IO ()) -> C_CancellableCancelledCallback
wrap_CancellableCancelledCallback a -> IO ()
wrapped
wrapped'' <- C_CancellableCancelledCallback
-> IO (FunPtr C_CancellableCancelledCallback)
mk_CancellableCancelledCallback C_CancellableCancelledCallback
wrapped'
connectSignalFunPtr obj "cancelled" wrapped'' SignalConnectBefore Nothing
afterCancellableCancelled :: (IsCancellable a, MonadIO m) => a -> ((?self :: a) => CancellableCancelledCallback) -> m SignalHandlerId
afterCancellableCancelled :: forall a (m :: * -> *).
(IsCancellable a, MonadIO m) =>
a -> ((?self::a) => IO ()) -> m SignalHandlerId
afterCancellableCancelled a
obj (?self::a) => IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
let wrapped :: a -> IO ()
wrapped a
self = let ?self = a
?self::a
self in IO ()
(?self::a) => IO ()
cb
let wrapped' :: C_CancellableCancelledCallback
wrapped' = (a -> IO ()) -> C_CancellableCancelledCallback
forall a.
GObject a =>
(a -> IO ()) -> C_CancellableCancelledCallback
wrap_CancellableCancelledCallback a -> IO ()
wrapped
wrapped'' <- C_CancellableCancelledCallback
-> IO (FunPtr C_CancellableCancelledCallback)
mk_CancellableCancelledCallback C_CancellableCancelledCallback
wrapped'
connectSignalFunPtr obj "cancelled" wrapped'' SignalConnectAfter Nothing
#if defined(ENABLE_OVERLOADING)
data CancellableCancelledSignalInfo
instance SignalInfo CancellableCancelledSignalInfo where
type HaskellCallbackType CancellableCancelledSignalInfo = CancellableCancelledCallback
connectSignal obj cb connectMode detail = do
let cb' = wrap_CancellableCancelledCallback cb
cb'' <- mk_CancellableCancelledCallback cb'
connectSignalFunPtr obj "cancelled" cb'' connectMode detail
dbgSignalInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable::cancelled"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#g:signal:cancelled"})
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Cancellable
type instance O.AttributeList Cancellable = CancellableAttributeList
type CancellableAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Cancellable = CancellableSignalList
type CancellableSignalList = ('[ '("cancelled", CancellableCancelledSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_cancellable_new" g_cancellable_new ::
IO (Ptr Cancellable)
cancellableNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Cancellable
cancellableNew :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Cancellable
cancellableNew = IO Cancellable -> m Cancellable
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Cancellable -> m Cancellable)
-> IO Cancellable -> m Cancellable
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr Cancellable)
g_cancellable_new
checkUnexpectedReturnNULL "cancellableNew" result
result' <- (wrapObject Cancellable) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_cancellable_cancel" g_cancellable_cancel ::
Ptr Cancellable ->
IO ()
cancellableCancel ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m ()
cancellableCancel :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m ()
cancellableCancel Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
g_cancellable_cancel maybeCancellable
whenJust cancellable touchManagedPtr
return ()
#if defined(ENABLE_OVERLOADING)
data CancellableCancelMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableCancelMethodInfo a signature where
overloadedMethod i = cancellableCancel (Just i)
instance O.OverloadedMethodInfo CancellableCancelMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableCancel",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableCancel"
})
#endif
foreign import ccall "g_cancellable_connect" g_cancellable_connect ::
Ptr Cancellable ->
FunPtr GObject.Callbacks.C_Callback ->
Ptr () ->
FunPtr GLib.Callbacks.C_DestroyNotify ->
IO FCT.CULong
cancellableConnect ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> GObject.Callbacks.Callback
-> m FCT.CULong
cancellableConnect :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> IO () -> m SignalHandlerId
cancellableConnect Maybe a
cancellable IO ()
callback = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
callback' <- GObject.Callbacks.mk_Callback (GObject.Callbacks.wrap_Callback Nothing callback)
let data_ = FunPtr (IO ()) -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr (IO ())
callback'
let dataDestroyFunc = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
SP.safeFreeFunPtrPtr
result <- g_cancellable_connect maybeCancellable callback' data_ dataDestroyFunc
whenJust cancellable touchManagedPtr
return result
#if defined(ENABLE_OVERLOADING)
data CancellableConnectMethodInfo
instance (signature ~ (GObject.Callbacks.Callback -> m FCT.CULong), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableConnectMethodInfo a signature where
overloadedMethod i = cancellableConnect (Just i)
instance O.OverloadedMethodInfo CancellableConnectMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableConnect",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableConnect"
})
#endif
foreign import ccall "g_cancellable_disconnect" g_cancellable_disconnect ::
Ptr Cancellable ->
FCT.CULong ->
IO ()
cancellableDisconnect ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> FCT.CULong
-> m ()
cancellableDisconnect :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> SignalHandlerId -> m ()
cancellableDisconnect Maybe a
cancellable SignalHandlerId
handlerId = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
g_cancellable_disconnect maybeCancellable handlerId
whenJust cancellable touchManagedPtr
return ()
#if defined(ENABLE_OVERLOADING)
data CancellableDisconnectMethodInfo
instance (signature ~ (FCT.CULong -> m ()), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableDisconnectMethodInfo a signature where
overloadedMethod i = cancellableDisconnect (Just i)
instance O.OverloadedMethodInfo CancellableDisconnectMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableDisconnect",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableDisconnect"
})
#endif
foreign import ccall "g_cancellable_get_fd" g_cancellable_get_fd ::
Ptr Cancellable ->
IO Int32
cancellableGetFd ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m Int32
cancellableGetFd :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m Int32
cancellableGetFd Maybe a
cancellable = IO Int32 -> m Int32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
result <- g_cancellable_get_fd maybeCancellable
whenJust cancellable touchManagedPtr
return result
#if defined(ENABLE_OVERLOADING)
data CancellableGetFdMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableGetFdMethodInfo a signature where
overloadedMethod i = cancellableGetFd (Just i)
instance O.OverloadedMethodInfo CancellableGetFdMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableGetFd",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableGetFd"
})
#endif
foreign import ccall "g_cancellable_is_cancelled" g_cancellable_is_cancelled ::
Ptr Cancellable ->
IO CInt
cancellableIsCancelled ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m Bool
cancellableIsCancelled :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m Bool
cancellableIsCancelled Maybe a
cancellable = IO Bool -> m Bool
forall a. IO a -> m a
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
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
result <- g_cancellable_is_cancelled maybeCancellable
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
whenJust cancellable touchManagedPtr
return result'
#if defined(ENABLE_OVERLOADING)
data CancellableIsCancelledMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableIsCancelledMethodInfo a signature where
overloadedMethod i = cancellableIsCancelled (Just i)
instance O.OverloadedMethodInfo CancellableIsCancelledMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableIsCancelled",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableIsCancelled"
})
#endif
foreign import ccall "g_cancellable_make_pollfd" g_cancellable_make_pollfd ::
Ptr Cancellable ->
Ptr GLib.PollFD.PollFD ->
IO CInt
cancellableMakePollfd ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> GLib.PollFD.PollFD
-> m Bool
cancellableMakePollfd :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> PollFD -> m Bool
cancellableMakePollfd Maybe a
cancellable PollFD
pollfd = IO Bool -> m Bool
forall a. IO a -> m a
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
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
pollfd' <- unsafeManagedPtrGetPtr pollfd
result <- g_cancellable_make_pollfd maybeCancellable pollfd'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
whenJust cancellable touchManagedPtr
touchManagedPtr pollfd
return result'
#if defined(ENABLE_OVERLOADING)
data CancellableMakePollfdMethodInfo
instance (signature ~ (GLib.PollFD.PollFD -> m Bool), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableMakePollfdMethodInfo a signature where
overloadedMethod i = cancellableMakePollfd (Just i)
instance O.OverloadedMethodInfo CancellableMakePollfdMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableMakePollfd",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableMakePollfd"
})
#endif
foreign import ccall "g_cancellable_pop_current" g_cancellable_pop_current ::
Ptr Cancellable ->
IO ()
cancellablePopCurrent ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m ()
cancellablePopCurrent :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m ()
cancellablePopCurrent Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
g_cancellable_pop_current maybeCancellable
whenJust cancellable touchManagedPtr
return ()
#if defined(ENABLE_OVERLOADING)
data CancellablePopCurrentMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellablePopCurrentMethodInfo a signature where
overloadedMethod i = cancellablePopCurrent (Just i)
instance O.OverloadedMethodInfo CancellablePopCurrentMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellablePopCurrent",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellablePopCurrent"
})
#endif
foreign import ccall "g_cancellable_push_current" g_cancellable_push_current ::
Ptr Cancellable ->
IO ()
cancellablePushCurrent ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m ()
cancellablePushCurrent :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m ()
cancellablePushCurrent Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
g_cancellable_push_current maybeCancellable
whenJust cancellable touchManagedPtr
return ()
#if defined(ENABLE_OVERLOADING)
data CancellablePushCurrentMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellablePushCurrentMethodInfo a signature where
overloadedMethod i = cancellablePushCurrent (Just i)
instance O.OverloadedMethodInfo CancellablePushCurrentMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellablePushCurrent",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellablePushCurrent"
})
#endif
foreign import ccall "g_cancellable_release_fd" g_cancellable_release_fd ::
Ptr Cancellable ->
IO ()
cancellableReleaseFd ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m ()
cancellableReleaseFd :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m ()
cancellableReleaseFd Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
g_cancellable_release_fd maybeCancellable
whenJust cancellable touchManagedPtr
return ()
#if defined(ENABLE_OVERLOADING)
data CancellableReleaseFdMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableReleaseFdMethodInfo a signature where
overloadedMethod i = cancellableReleaseFd (Just i)
instance O.OverloadedMethodInfo CancellableReleaseFdMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableReleaseFd",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableReleaseFd"
})
#endif
foreign import ccall "g_cancellable_reset" g_cancellable_reset ::
Ptr Cancellable ->
IO ()
cancellableReset ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m ()
cancellableReset :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m ()
cancellableReset Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
g_cancellable_reset maybeCancellable
whenJust cancellable touchManagedPtr
return ()
#if defined(ENABLE_OVERLOADING)
data CancellableResetMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableResetMethodInfo a signature where
overloadedMethod i = cancellableReset (Just i)
instance O.OverloadedMethodInfo CancellableResetMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableReset",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableReset"
})
#endif
foreign import ccall "g_cancellable_set_error_if_cancelled" g_cancellable_set_error_if_cancelled ::
Ptr Cancellable ->
Ptr (Ptr GError) ->
IO CInt
cancellableSetErrorIfCancelled ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m ()
cancellableSetErrorIfCancelled :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m ()
cancellableSetErrorIfCancelled Maybe a
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
onException (do
_ <- propagateGError $ g_cancellable_set_error_if_cancelled maybeCancellable
whenJust cancellable touchManagedPtr
return ()
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data CancellableSetErrorIfCancelledMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableSetErrorIfCancelledMethodInfo a signature where
overloadedMethod i = cancellableSetErrorIfCancelled (Just i)
instance O.OverloadedMethodInfo CancellableSetErrorIfCancelledMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableSetErrorIfCancelled",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableSetErrorIfCancelled"
})
#endif
foreign import ccall "g_cancellable_source_new" g_cancellable_source_new ::
Ptr Cancellable ->
IO (Ptr GLib.Source.Source)
cancellableSourceNew ::
(B.CallStack.HasCallStack, MonadIO m, IsCancellable a) =>
Maybe (a)
-> m GLib.Source.Source
cancellableSourceNew :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsCancellable a) =>
Maybe a -> m Source
cancellableSourceNew Maybe a
cancellable = IO Source -> m Source
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Source -> m Source) -> IO Source -> m Source
forall a b. (a -> b) -> a -> b
$ do
maybeCancellable <- case Maybe a
cancellable of
Maybe a
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just a
jCancellable -> do
jCancellable' <- a -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jCancellable
return jCancellable'
result <- g_cancellable_source_new maybeCancellable
checkUnexpectedReturnNULL "cancellableSourceNew" result
result' <- (wrapBoxed GLib.Source.Source) result
whenJust cancellable touchManagedPtr
return result'
#if defined(ENABLE_OVERLOADING)
data CancellableSourceNewMethodInfo
instance (signature ~ (m GLib.Source.Source), MonadIO m, IsCancellable a) => O.OverloadedMethod CancellableSourceNewMethodInfo a signature where
overloadedMethod i = cancellableSourceNew (Just i)
instance O.OverloadedMethodInfo CancellableSourceNewMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Objects.Cancellable.cancellableSourceNew",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Objects-Cancellable.html#v:cancellableSourceNew"
})
#endif
foreign import ccall "g_cancellable_get_current" g_cancellable_get_current ::
IO (Ptr Cancellable)
cancellableGetCurrent ::
(B.CallStack.HasCallStack, MonadIO m) =>
m (Maybe Cancellable)
cancellableGetCurrent :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
m (Maybe Cancellable)
cancellableGetCurrent = IO (Maybe Cancellable) -> m (Maybe Cancellable)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Cancellable) -> m (Maybe Cancellable))
-> IO (Maybe Cancellable) -> m (Maybe Cancellable)
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr Cancellable)
g_cancellable_get_current
maybeResult <- convertIfNonNull result $ \Ptr Cancellable
result' -> do
result'' <- ((ManagedPtr Cancellable -> Cancellable)
-> Ptr Cancellable -> IO Cancellable
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Cancellable -> Cancellable
Cancellable) Ptr Cancellable
result'
return result''
return maybeResult
#if defined(ENABLE_OVERLOADING)
#endif