{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) The @GSource@ struct is an opaque data type representing an event source. -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.GLib.Structs.Source ( -- * Exported types Source(..) , newZeroSource , noSource , -- * Methods -- ** addChildSource #method:addChildSource# #if ENABLE_OVERLOADING SourceAddChildSourceMethodInfo , #endif sourceAddChildSource , -- ** addPoll #method:addPoll# #if ENABLE_OVERLOADING SourceAddPollMethodInfo , #endif sourceAddPoll , -- ** addUnixFd #method:addUnixFd# #if ENABLE_OVERLOADING SourceAddUnixFdMethodInfo , #endif sourceAddUnixFd , -- ** attach #method:attach# #if ENABLE_OVERLOADING SourceAttachMethodInfo , #endif sourceAttach , -- ** destroy #method:destroy# #if ENABLE_OVERLOADING SourceDestroyMethodInfo , #endif sourceDestroy , -- ** getCanRecurse #method:getCanRecurse# #if ENABLE_OVERLOADING SourceGetCanRecurseMethodInfo , #endif sourceGetCanRecurse , -- ** getContext #method:getContext# #if ENABLE_OVERLOADING SourceGetContextMethodInfo , #endif sourceGetContext , -- ** getCurrentTime #method:getCurrentTime# #if ENABLE_OVERLOADING SourceGetCurrentTimeMethodInfo , #endif sourceGetCurrentTime , -- ** getId #method:getId# #if ENABLE_OVERLOADING SourceGetIdMethodInfo , #endif sourceGetId , -- ** getName #method:getName# #if ENABLE_OVERLOADING SourceGetNameMethodInfo , #endif sourceGetName , -- ** getPriority #method:getPriority# #if ENABLE_OVERLOADING SourceGetPriorityMethodInfo , #endif sourceGetPriority , -- ** getReadyTime #method:getReadyTime# #if ENABLE_OVERLOADING SourceGetReadyTimeMethodInfo , #endif sourceGetReadyTime , -- ** getTime #method:getTime# #if ENABLE_OVERLOADING SourceGetTimeMethodInfo , #endif sourceGetTime , -- ** isDestroyed #method:isDestroyed# #if ENABLE_OVERLOADING SourceIsDestroyedMethodInfo , #endif sourceIsDestroyed , -- ** modifyUnixFd #method:modifyUnixFd# #if ENABLE_OVERLOADING SourceModifyUnixFdMethodInfo , #endif sourceModifyUnixFd , -- ** new #method:new# sourceNew , -- ** queryUnixFd #method:queryUnixFd# #if ENABLE_OVERLOADING SourceQueryUnixFdMethodInfo , #endif sourceQueryUnixFd , -- ** ref #method:ref# #if ENABLE_OVERLOADING SourceRefMethodInfo , #endif sourceRef , -- ** remove #method:remove# sourceRemove , -- ** removeByFuncsUserData #method:removeByFuncsUserData# sourceRemoveByFuncsUserData , -- ** removeByUserData #method:removeByUserData# sourceRemoveByUserData , -- ** removeChildSource #method:removeChildSource# #if ENABLE_OVERLOADING SourceRemoveChildSourceMethodInfo , #endif sourceRemoveChildSource , -- ** removePoll #method:removePoll# #if ENABLE_OVERLOADING SourceRemovePollMethodInfo , #endif sourceRemovePoll , -- ** removeUnixFd #method:removeUnixFd# #if ENABLE_OVERLOADING SourceRemoveUnixFdMethodInfo , #endif sourceRemoveUnixFd , -- ** setCallback #method:setCallback# #if ENABLE_OVERLOADING SourceSetCallbackMethodInfo , #endif sourceSetCallback , -- ** setCallbackIndirect #method:setCallbackIndirect# #if ENABLE_OVERLOADING SourceSetCallbackIndirectMethodInfo , #endif sourceSetCallbackIndirect , -- ** setCanRecurse #method:setCanRecurse# #if ENABLE_OVERLOADING SourceSetCanRecurseMethodInfo , #endif sourceSetCanRecurse , -- ** setFuncs #method:setFuncs# #if ENABLE_OVERLOADING SourceSetFuncsMethodInfo , #endif sourceSetFuncs , -- ** setName #method:setName# #if ENABLE_OVERLOADING SourceSetNameMethodInfo , #endif sourceSetName , -- ** setNameById #method:setNameById# sourceSetNameById , -- ** setPriority #method:setPriority# #if ENABLE_OVERLOADING SourceSetPriorityMethodInfo , #endif sourceSetPriority , -- ** setReadyTime #method:setReadyTime# #if ENABLE_OVERLOADING SourceSetReadyTimeMethodInfo , #endif sourceSetReadyTime , -- ** unref #method:unref# #if ENABLE_OVERLOADING SourceUnrefMethodInfo , #endif sourceUnref , ) 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.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.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GI.GLib.Callbacks as GLib.Callbacks import {-# SOURCE #-} qualified GI.GLib.Flags as GLib.Flags import {-# SOURCE #-} qualified GI.GLib.Structs.MainContext as GLib.MainContext import {-# SOURCE #-} qualified GI.GLib.Structs.PollFD as GLib.PollFD import {-# SOURCE #-} qualified GI.GLib.Structs.SourceCallbackFuncs as GLib.SourceCallbackFuncs import {-# SOURCE #-} qualified GI.GLib.Structs.SourceFuncs as GLib.SourceFuncs import {-# SOURCE #-} qualified GI.GLib.Structs.TimeVal as GLib.TimeVal -- | Memory-managed wrapper type. newtype Source = Source (ManagedPtr Source) foreign import ccall "g_source_get_type" c_g_source_get_type :: IO GType instance BoxedObject Source where boxedType _ = c_g_source_get_type -- | Construct a `Source` struct initialized to zero. newZeroSource :: MonadIO m => m Source newZeroSource = liftIO $ callocBoxedBytes 96 >>= wrapBoxed Source instance tag ~ 'AttrSet => Constructible Source tag where new _ attrs = do o <- newZeroSource GI.Attributes.set o attrs return o -- | A convenience alias for `Nothing` :: `Maybe` `Source`. noSource :: Maybe Source noSource = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList Source type instance O.AttributeList Source = SourceAttributeList type SourceAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method Source::new -- method type : Constructor -- Args : [Arg {argCName = "source_funcs", argType = TInterface (Name {namespace = "GLib", name = "SourceFuncs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "structure containing functions that implement\n the sources behavior.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "struct_size", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of the #GSource structure to create.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_source_new" g_source_new :: Ptr GLib.SourceFuncs.SourceFuncs -> -- source_funcs : TInterface (Name {namespace = "GLib", name = "SourceFuncs"}) Word32 -> -- struct_size : TBasicType TUInt IO (Ptr Source) {- | Creates a new 'GI.GLib.Structs.Source.Source' structure. The size is specified to allow creating structures derived from 'GI.GLib.Structs.Source.Source' that contain additional data. The size passed in must be at least @sizeof (GSource)@. The source will not initially be associated with any 'GI.GLib.Structs.MainContext.MainContext' and must be added to one with 'GI.GLib.Structs.Source.sourceAttach' before it will be executed. -} sourceNew :: (B.CallStack.HasCallStack, MonadIO m) => GLib.SourceFuncs.SourceFuncs {- ^ /@sourceFuncs@/: structure containing functions that implement the sources behavior. -} -> Word32 {- ^ /@structSize@/: size of the 'GI.GLib.Structs.Source.Source' structure to create. -} -> m Source {- ^ __Returns:__ the newly-created 'GI.GLib.Structs.Source.Source'. -} sourceNew sourceFuncs structSize = liftIO $ do sourceFuncs' <- unsafeManagedPtrGetPtr sourceFuncs result <- g_source_new sourceFuncs' structSize checkUnexpectedReturnNULL "sourceNew" result result' <- (wrapBoxed Source) result touchManagedPtr sourceFuncs return result' #if ENABLE_OVERLOADING #endif -- method Source::add_child_source -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a second #GSource that @source should \"poll\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_add_child_source" g_source_add_child_source :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr Source -> -- child_source : TInterface (Name {namespace = "GLib", name = "Source"}) IO () {- | Adds /@childSource@/ to /@source@/ as a \"polled\" source; when /@source@/ is added to a 'GI.GLib.Structs.MainContext.MainContext', /@childSource@/ will be automatically added with the same priority, when /@childSource@/ is triggered, it will cause /@source@/ to dispatch (in addition to calling its own callback), and when /@source@/ is destroyed, it will destroy /@childSource@/ as well. (/@source@/ will also still be dispatched if its own prepare\/check functions indicate that it is ready.) If you don\'t need /@childSource@/ to do anything on its own when it triggers, you can call @/g_source_set_dummy_callback()/@ on it to set a callback that does nothing (except return 'True' if appropriate). /@source@/ will hold a reference on /@childSource@/ while /@childSource@/ is attached to it. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. /Since: 2.28/ -} sourceAddChildSource :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Source {- ^ /@childSource@/: a second 'GI.GLib.Structs.Source.Source' that /@source@/ should \"poll\" -} -> m () sourceAddChildSource source childSource = liftIO $ do source' <- unsafeManagedPtrGetPtr source childSource' <- unsafeManagedPtrGetPtr childSource g_source_add_child_source source' childSource' touchManagedPtr source touchManagedPtr childSource return () #if ENABLE_OVERLOADING data SourceAddChildSourceMethodInfo instance (signature ~ (Source -> m ()), MonadIO m) => O.MethodInfo SourceAddChildSourceMethodInfo Source signature where overloadedMethod _ = sourceAddChildSource #endif -- method Source::add_poll -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "GLib", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GPollFD structure holding information about a file\n descriptor to watch.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_add_poll" g_source_add_poll :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr GLib.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "GLib", name = "PollFD"}) IO () {- | Adds a file descriptor to the set of file descriptors polled for this source. This is usually combined with 'GI.GLib.Structs.Source.sourceNew' to add an event source. The event source\'s check function will typically test the /@revents@/ field in the 'GI.GLib.Structs.PollFD.PollFD' struct and return 'True' if events need to be processed. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. Using this API forces the linear scanning of event sources on each main loop iteration. Newly-written event sources should try to use 'GI.GLib.Structs.Source.sourceAddUnixFd' instead of this API. -} sourceAddPoll :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> GLib.PollFD.PollFD {- ^ /@fd@/: a 'GI.GLib.Structs.PollFD.PollFD' structure holding information about a file descriptor to watch. -} -> m () sourceAddPoll source fd = liftIO $ do source' <- unsafeManagedPtrGetPtr source fd' <- unsafeManagedPtrGetPtr fd g_source_add_poll source' fd' touchManagedPtr source touchManagedPtr fd return () #if ENABLE_OVERLOADING data SourceAddPollMethodInfo instance (signature ~ (GLib.PollFD.PollFD -> m ()), MonadIO m) => O.MethodInfo SourceAddPollMethodInfo Source signature where overloadedMethod _ = sourceAddPoll #endif -- method Source::add_unix_fd -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the fd to monitor", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "events", argType = TInterface (Name {namespace = "GLib", name = "IOCondition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an event mask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TPtr) -- throws : False -- Skip return : False foreign import ccall "g_source_add_unix_fd" g_source_add_unix_fd :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Int32 -> -- fd : TBasicType TInt CUInt -> -- events : TInterface (Name {namespace = "GLib", name = "IOCondition"}) IO (Ptr ()) {- | Monitors /@fd@/ for the IO events in /@events@/. The tag returned by this function can be used to remove or modify the monitoring of the fd using 'GI.GLib.Structs.Source.sourceRemoveUnixFd' or 'GI.GLib.Structs.Source.sourceModifyUnixFd'. It is not necessary to remove the fd before destroying the source; it will be cleaned up automatically. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. As the name suggests, this function is not available on Windows. /Since: 2.36/ -} sourceAddUnixFd :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Int32 {- ^ /@fd@/: the fd to monitor -} -> [GLib.Flags.IOCondition] {- ^ /@events@/: an event mask -} -> m (Ptr ()) {- ^ __Returns:__ an opaque tag -} sourceAddUnixFd source fd events = liftIO $ do source' <- unsafeManagedPtrGetPtr source let events' = gflagsToWord events result <- g_source_add_unix_fd source' fd events' touchManagedPtr source return result #if ENABLE_OVERLOADING data SourceAddUnixFdMethodInfo instance (signature ~ (Int32 -> [GLib.Flags.IOCondition] -> m (Ptr ())), MonadIO m) => O.MethodInfo SourceAddUnixFdMethodInfo Source signature where overloadedMethod _ = sourceAddUnixFd #endif -- method Source::attach -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "context", argType = TInterface (Name {namespace = "GLib", name = "MainContext"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GMainContext (if %NULL, the default context will be used)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_source_attach" g_source_attach :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr GLib.MainContext.MainContext -> -- context : TInterface (Name {namespace = "GLib", name = "MainContext"}) IO Word32 {- | Adds a 'GI.GLib.Structs.Source.Source' to a /@context@/ so that it will be executed within that context. Remove it by calling 'GI.GLib.Structs.Source.sourceDestroy'. -} sourceAttach :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Maybe (GLib.MainContext.MainContext) {- ^ /@context@/: a 'GI.GLib.Structs.MainContext.MainContext' (if 'Nothing', the default context will be used) -} -> m Word32 {- ^ __Returns:__ the ID (greater than 0) for the source within the 'GI.GLib.Structs.MainContext.MainContext'. -} sourceAttach source context = liftIO $ do source' <- unsafeManagedPtrGetPtr source maybeContext <- case context of Nothing -> return nullPtr Just jContext -> do jContext' <- unsafeManagedPtrGetPtr jContext return jContext' result <- g_source_attach source' maybeContext touchManagedPtr source whenJust context touchManagedPtr return result #if ENABLE_OVERLOADING data SourceAttachMethodInfo instance (signature ~ (Maybe (GLib.MainContext.MainContext) -> m Word32), MonadIO m) => O.MethodInfo SourceAttachMethodInfo Source signature where overloadedMethod _ = sourceAttach #endif -- method Source::destroy -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_destroy" g_source_destroy :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO () {- | Removes a source from its 'GI.GLib.Structs.MainContext.MainContext', if any, and mark it as destroyed. The source cannot be subsequently added to another context. It is safe to call this on sources which have already been removed from their context. -} sourceDestroy :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m () sourceDestroy source = liftIO $ do source' <- unsafeManagedPtrGetPtr source g_source_destroy source' touchManagedPtr source return () #if ENABLE_OVERLOADING data SourceDestroyMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo SourceDestroyMethodInfo Source signature where overloadedMethod _ = sourceDestroy #endif -- method Source::get_can_recurse -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", 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_source_get_can_recurse" g_source_get_can_recurse :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO CInt {- | Checks whether a source is allowed to be called recursively. see 'GI.GLib.Structs.Source.sourceSetCanRecurse'. -} sourceGetCanRecurse :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m Bool {- ^ __Returns:__ whether recursion is allowed. -} sourceGetCanRecurse source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_get_can_recurse source' let result' = (/= 0) result touchManagedPtr source return result' #if ENABLE_OVERLOADING data SourceGetCanRecurseMethodInfo instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo SourceGetCanRecurseMethodInfo Source signature where overloadedMethod _ = sourceGetCanRecurse #endif -- method Source::get_context -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "MainContext"})) -- throws : False -- Skip return : False foreign import ccall "g_source_get_context" g_source_get_context :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO (Ptr GLib.MainContext.MainContext) {- | Gets the 'GI.GLib.Structs.MainContext.MainContext' with which the source is associated. You can call this on a source that has been destroyed, provided that the 'GI.GLib.Structs.MainContext.MainContext' it was attached to still exists (in which case it will return that 'GI.GLib.Structs.MainContext.MainContext'). In particular, you can always call this function on the source returned from 'GI.GLib.Functions.mainCurrentSource'. But calling this function on a source whose 'GI.GLib.Structs.MainContext.MainContext' has been destroyed is an error. -} sourceGetContext :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m (Maybe GLib.MainContext.MainContext) {- ^ __Returns:__ the 'GI.GLib.Structs.MainContext.MainContext' with which the source is associated, or 'Nothing' if the context has not yet been added to a source. -} sourceGetContext source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_get_context source' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (newBoxed GLib.MainContext.MainContext) result' return result'' touchManagedPtr source return maybeResult #if ENABLE_OVERLOADING data SourceGetContextMethodInfo instance (signature ~ (m (Maybe GLib.MainContext.MainContext)), MonadIO m) => O.MethodInfo SourceGetContextMethodInfo Source signature where overloadedMethod _ = sourceGetContext #endif -- method Source::get_current_time -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeval", argType = TInterface (Name {namespace = "GLib", name = "TimeVal"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GTimeVal structure in which to store current time.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_get_current_time" g_source_get_current_time :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr GLib.TimeVal.TimeVal -> -- timeval : TInterface (Name {namespace = "GLib", name = "TimeVal"}) IO () {-# DEPRECATED sourceGetCurrentTime ["(Since version 2.28)","use 'GI.GLib.Structs.Source.sourceGetTime' instead"] #-} {- | This function ignores /@source@/ and is otherwise the same as 'GI.GLib.Functions.getCurrentTime'. -} sourceGetCurrentTime :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> GLib.TimeVal.TimeVal {- ^ /@timeval@/: 'GI.GLib.Structs.TimeVal.TimeVal' structure in which to store current time. -} -> m () sourceGetCurrentTime source timeval = liftIO $ do source' <- unsafeManagedPtrGetPtr source timeval' <- unsafeManagedPtrGetPtr timeval g_source_get_current_time source' timeval' touchManagedPtr source touchManagedPtr timeval return () #if ENABLE_OVERLOADING data SourceGetCurrentTimeMethodInfo instance (signature ~ (GLib.TimeVal.TimeVal -> m ()), MonadIO m) => O.MethodInfo SourceGetCurrentTimeMethodInfo Source signature where overloadedMethod _ = sourceGetCurrentTime #endif -- method Source::get_id -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "g_source_get_id" g_source_get_id :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO Word32 {- | Returns the numeric ID for a particular source. The ID of a source is a positive integer which is unique within a particular main loop context. The reverse mapping from ID to source is done by 'GI.GLib.Structs.MainContext.mainContextFindSourceById'. -} sourceGetId :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m Word32 {- ^ __Returns:__ the ID (greater than 0) for the source -} sourceGetId source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_get_id source' touchManagedPtr source return result #if ENABLE_OVERLOADING data SourceGetIdMethodInfo instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo SourceGetIdMethodInfo Source signature where overloadedMethod _ = sourceGetId #endif -- method Source::get_name -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "g_source_get_name" g_source_get_name :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO CString {- | Gets a name for the source, used in debugging and profiling. The name may be @/NULL/@ if it has never been set with 'GI.GLib.Structs.Source.sourceSetName'. /Since: 2.26/ -} sourceGetName :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m T.Text {- ^ __Returns:__ the name of the source -} sourceGetName source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_get_name source' checkUnexpectedReturnNULL "sourceGetName" result result' <- cstringToText result touchManagedPtr source return result' #if ENABLE_OVERLOADING data SourceGetNameMethodInfo instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo SourceGetNameMethodInfo Source signature where overloadedMethod _ = sourceGetName #endif -- method Source::get_priority -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TInt) -- throws : False -- Skip return : False foreign import ccall "g_source_get_priority" g_source_get_priority :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO Int32 {- | Gets the priority of a source. -} sourceGetPriority :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m Int32 {- ^ __Returns:__ the priority of the source -} sourceGetPriority source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_get_priority source' touchManagedPtr source return result #if ENABLE_OVERLOADING data SourceGetPriorityMethodInfo instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo SourceGetPriorityMethodInfo Source signature where overloadedMethod _ = sourceGetPriority #endif -- method Source::get_ready_time -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", 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_source_get_ready_time" g_source_get_ready_time :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO Int64 {- | Gets the \"ready time\" of /@source@/, as set by 'GI.GLib.Structs.Source.sourceSetReadyTime'. Any time before the current monotonic time (including 0) is an indication that the source will fire immediately. -} sourceGetReadyTime :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m Int64 {- ^ __Returns:__ the monotonic ready time, -1 for \"never\" -} sourceGetReadyTime source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_get_ready_time source' touchManagedPtr source return result #if ENABLE_OVERLOADING data SourceGetReadyTimeMethodInfo instance (signature ~ (m Int64), MonadIO m) => O.MethodInfo SourceGetReadyTimeMethodInfo Source signature where overloadedMethod _ = sourceGetReadyTime #endif -- method Source::get_time -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", 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_source_get_time" g_source_get_time :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO Int64 {- | Gets the time to be used when checking this source. The advantage of calling this function over calling 'GI.GLib.Functions.getMonotonicTime' directly is that when checking multiple sources, GLib can cache a single value instead of having to repeatedly get the system monotonic time. The time here is the system monotonic time, if available, or some other reasonable alternative otherwise. See 'GI.GLib.Functions.getMonotonicTime'. /Since: 2.28/ -} sourceGetTime :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m Int64 {- ^ __Returns:__ the monotonic time in microseconds -} sourceGetTime source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_get_time source' touchManagedPtr source return result #if ENABLE_OVERLOADING data SourceGetTimeMethodInfo instance (signature ~ (m Int64), MonadIO m) => O.MethodInfo SourceGetTimeMethodInfo Source signature where overloadedMethod _ = sourceGetTime #endif -- method Source::is_destroyed -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", 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_source_is_destroyed" g_source_is_destroyed :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO CInt {- | Returns whether /@source@/ has been destroyed. This is important when you operate upon your objects from within idle handlers, but may have freed the object before the dispatch of your idle handler. === /C code/ > >static gboolean >idle_callback (gpointer data) >{ > SomeWidget *self = data; > > GDK_THREADS_ENTER (); > // do stuff with self > self->idle_id = 0; > GDK_THREADS_LEAVE (); > > return G_SOURCE_REMOVE; >} > >static void >some_widget_do_stuff_later (SomeWidget *self) >{ > self->idle_id = g_idle_add (idle_callback, self); >} > >static void >some_widget_finalize (GObject *object) >{ > SomeWidget *self = SOME_WIDGET (object); > > if (self->idle_id) > g_source_remove (self->idle_id); > > G_OBJECT_CLASS (parent_class)->finalize (object); >} This will fail in a multi-threaded application if the widget is destroyed before the idle handler fires due to the use after free in the callback. A solution, to this particular problem, is to check to if the source has already been destroy within the callback. === /C code/ > >static gboolean >idle_callback (gpointer data) >{ > SomeWidget *self = data; > > GDK_THREADS_ENTER (); > if (!g_source_is_destroyed (g_main_current_source ())) > { > // do stuff with self > } > GDK_THREADS_LEAVE (); > > return FALSE; >} Calls to this function from a thread other than the one acquired by the 'GI.GLib.Structs.MainContext.MainContext' the 'GI.GLib.Structs.Source.Source' is attached to are typically redundant, as the source could be destroyed immediately after this function returns. However, once a source is destroyed it cannot be un-destroyed, so this function can be used for opportunistic checks from any thread. /Since: 2.12/ -} sourceIsDestroyed :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m Bool {- ^ __Returns:__ 'True' if the source has been destroyed -} sourceIsDestroyed source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_is_destroyed source' let result' = (/= 0) result touchManagedPtr source return result' #if ENABLE_OVERLOADING data SourceIsDestroyedMethodInfo instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo SourceIsDestroyedMethodInfo Source signature where overloadedMethod _ = sourceIsDestroyed #endif -- method Source::modify_unix_fd -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tag", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tag from g_source_add_unix_fd()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "new_events", argType = TInterface (Name {namespace = "GLib", name = "IOCondition"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new event mask to watch", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_modify_unix_fd" g_source_modify_unix_fd :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr () -> -- tag : TBasicType TPtr CUInt -> -- new_events : TInterface (Name {namespace = "GLib", name = "IOCondition"}) IO () {- | Updates the event mask to watch for the fd identified by /@tag@/. /@tag@/ is the tag returned from 'GI.GLib.Structs.Source.sourceAddUnixFd'. If you want to remove a fd, don\'t set its event mask to zero. Instead, call 'GI.GLib.Structs.Source.sourceRemoveUnixFd'. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. As the name suggests, this function is not available on Windows. /Since: 2.36/ -} sourceModifyUnixFd :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Ptr () {- ^ /@tag@/: the tag from 'GI.GLib.Structs.Source.sourceAddUnixFd' -} -> [GLib.Flags.IOCondition] {- ^ /@newEvents@/: the new event mask to watch -} -> m () sourceModifyUnixFd source tag newEvents = liftIO $ do source' <- unsafeManagedPtrGetPtr source let newEvents' = gflagsToWord newEvents g_source_modify_unix_fd source' tag newEvents' touchManagedPtr source return () #if ENABLE_OVERLOADING data SourceModifyUnixFdMethodInfo instance (signature ~ (Ptr () -> [GLib.Flags.IOCondition] -> m ()), MonadIO m) => O.MethodInfo SourceModifyUnixFdMethodInfo Source signature where overloadedMethod _ = sourceModifyUnixFd #endif -- method Source::query_unix_fd -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tag", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tag from g_source_add_unix_fd()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "IOCondition"})) -- throws : False -- Skip return : False foreign import ccall "g_source_query_unix_fd" g_source_query_unix_fd :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr () -> -- tag : TBasicType TPtr IO CUInt {- | Queries the events reported for the fd corresponding to /@tag@/ on /@source@/ during the last poll. The return value of this function is only defined when the function is called from the check or dispatch functions for /@source@/. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. As the name suggests, this function is not available on Windows. /Since: 2.36/ -} sourceQueryUnixFd :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Ptr () {- ^ /@tag@/: the tag from 'GI.GLib.Structs.Source.sourceAddUnixFd' -} -> m [GLib.Flags.IOCondition] {- ^ __Returns:__ the conditions reported on the fd -} sourceQueryUnixFd source tag = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_query_unix_fd source' tag let result' = wordToGFlags result touchManagedPtr source return result' #if ENABLE_OVERLOADING data SourceQueryUnixFdMethodInfo instance (signature ~ (Ptr () -> m [GLib.Flags.IOCondition]), MonadIO m) => O.MethodInfo SourceQueryUnixFdMethodInfo Source signature where overloadedMethod _ = sourceQueryUnixFd #endif -- method Source::ref -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "Source"})) -- throws : False -- Skip return : False foreign import ccall "g_source_ref" g_source_ref :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO (Ptr Source) {- | Increases the reference count on a source by one. -} sourceRef :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m Source {- ^ __Returns:__ /@source@/ -} sourceRef source = liftIO $ do source' <- unsafeManagedPtrGetPtr source result <- g_source_ref source' checkUnexpectedReturnNULL "sourceRef" result result' <- (wrapBoxed Source) result touchManagedPtr source return result' #if ENABLE_OVERLOADING data SourceRefMethodInfo instance (signature ~ (m Source), MonadIO m) => O.MethodInfo SourceRefMethodInfo Source signature where overloadedMethod _ = sourceRef #endif -- method Source::remove_child_source -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource previously passed to\n g_source_add_child_source().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_remove_child_source" g_source_remove_child_source :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr Source -> -- child_source : TInterface (Name {namespace = "GLib", name = "Source"}) IO () {- | Detaches /@childSource@/ from /@source@/ and destroys it. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. /Since: 2.28/ -} sourceRemoveChildSource :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Source {- ^ /@childSource@/: a 'GI.GLib.Structs.Source.Source' previously passed to 'GI.GLib.Structs.Source.sourceAddChildSource'. -} -> m () sourceRemoveChildSource source childSource = liftIO $ do source' <- unsafeManagedPtrGetPtr source childSource' <- unsafeManagedPtrGetPtr childSource g_source_remove_child_source source' childSource' touchManagedPtr source touchManagedPtr childSource return () #if ENABLE_OVERLOADING data SourceRemoveChildSourceMethodInfo instance (signature ~ (Source -> m ()), MonadIO m) => O.MethodInfo SourceRemoveChildSourceMethodInfo Source signature where overloadedMethod _ = sourceRemoveChildSource #endif -- method Source::remove_poll -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TInterface (Name {namespace = "GLib", name = "PollFD"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GPollFD structure previously passed to g_source_add_poll().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_remove_poll" g_source_remove_poll :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr GLib.PollFD.PollFD -> -- fd : TInterface (Name {namespace = "GLib", name = "PollFD"}) IO () {- | Removes a file descriptor from the set of file descriptors polled for this source. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. -} sourceRemovePoll :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> GLib.PollFD.PollFD {- ^ /@fd@/: a 'GI.GLib.Structs.PollFD.PollFD' structure previously passed to 'GI.GLib.Structs.Source.sourceAddPoll'. -} -> m () sourceRemovePoll source fd = liftIO $ do source' <- unsafeManagedPtrGetPtr source fd' <- unsafeManagedPtrGetPtr fd g_source_remove_poll source' fd' touchManagedPtr source touchManagedPtr fd return () #if ENABLE_OVERLOADING data SourceRemovePollMethodInfo instance (signature ~ (GLib.PollFD.PollFD -> m ()), MonadIO m) => O.MethodInfo SourceRemovePollMethodInfo Source signature where overloadedMethod _ = sourceRemovePoll #endif -- method Source::remove_unix_fd -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tag", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tag from g_source_add_unix_fd()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_remove_unix_fd" g_source_remove_unix_fd :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr () -> -- tag : TBasicType TPtr IO () {- | Reverses the effect of a previous call to 'GI.GLib.Structs.Source.sourceAddUnixFd'. You only need to call this if you want to remove an fd from being watched while keeping the same source around. In the normal case you will just want to destroy the source. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. As the name suggests, this function is not available on Windows. /Since: 2.36/ -} sourceRemoveUnixFd :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Ptr () {- ^ /@tag@/: the tag from 'GI.GLib.Structs.Source.sourceAddUnixFd' -} -> m () sourceRemoveUnixFd source tag = liftIO $ do source' <- unsafeManagedPtrGetPtr source g_source_remove_unix_fd source' tag touchManagedPtr source return () #if ENABLE_OVERLOADING data SourceRemoveUnixFdMethodInfo instance (signature ~ (Ptr () -> m ()), MonadIO m) => O.MethodInfo SourceRemoveUnixFdMethodInfo Source signature where overloadedMethod _ = sourceRemoveUnixFd #endif -- method Source::set_callback -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "GLib", name = "SourceFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a callback function", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a function to call when @data is no longer in use, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_set_callback" g_source_set_callback :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) FunPtr GLib.Callbacks.C_SourceFunc -> -- func : TInterface (Name {namespace = "GLib", name = "SourceFunc"}) Ptr () -> -- data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO () {- | Sets the callback function for a source. The callback for a source is called from the source\'s dispatch function. The exact type of /@func@/ depends on the type of source; ie. you should not count on /@func@/ being called with /@data@/ as its first parameter. See [memory management of sources][mainloop-memory-management] for details on how to handle memory management of /@data@/. Typically, you won\'t use this function. Instead use functions specific to the type of source you are using. -} sourceSetCallback :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: the source -} -> GLib.Callbacks.SourceFunc {- ^ /@func@/: a callback function -} -> m () sourceSetCallback source func = liftIO $ do source' <- unsafeManagedPtrGetPtr source func' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc func)) let data_ = castFunPtrToPtr func' let notify = safeFreeFunPtrPtr g_source_set_callback source' func' data_ notify touchManagedPtr source return () #if ENABLE_OVERLOADING data SourceSetCallbackMethodInfo instance (signature ~ (GLib.Callbacks.SourceFunc -> m ()), MonadIO m) => O.MethodInfo SourceSetCallbackMethodInfo Source signature where overloadedMethod _ = sourceSetCallback #endif -- method Source::set_callback_indirect -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "pointer to callback data \"object\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback_funcs", argType = TInterface (Name {namespace = "GLib", name = "SourceCallbackFuncs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "functions for reference counting @callback_data\n and getting the callback and data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_set_callback_indirect" g_source_set_callback_indirect :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr () -> -- callback_data : TBasicType TPtr Ptr GLib.SourceCallbackFuncs.SourceCallbackFuncs -> -- callback_funcs : TInterface (Name {namespace = "GLib", name = "SourceCallbackFuncs"}) IO () {- | Sets the callback function storing the data as a refcounted callback \"object\". This is used internally. Note that calling 'GI.GLib.Structs.Source.sourceSetCallbackIndirect' assumes an initial reference count on /@callbackData@/, and thus /@callbackFuncs@/->unref will eventually be called once more than /@callbackFuncs@/->ref. -} sourceSetCallbackIndirect :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: the source -} -> Ptr () {- ^ /@callbackData@/: pointer to callback data \"object\" -} -> GLib.SourceCallbackFuncs.SourceCallbackFuncs {- ^ /@callbackFuncs@/: functions for reference counting /@callbackData@/ and getting the callback and data -} -> m () sourceSetCallbackIndirect source callbackData callbackFuncs = liftIO $ do source' <- unsafeManagedPtrGetPtr source callbackFuncs' <- unsafeManagedPtrGetPtr callbackFuncs g_source_set_callback_indirect source' callbackData callbackFuncs' touchManagedPtr source touchManagedPtr callbackFuncs return () #if ENABLE_OVERLOADING data SourceSetCallbackIndirectMethodInfo instance (signature ~ (Ptr () -> GLib.SourceCallbackFuncs.SourceCallbackFuncs -> m ()), MonadIO m) => O.MethodInfo SourceSetCallbackIndirectMethodInfo Source signature where overloadedMethod _ = sourceSetCallbackIndirect #endif -- method Source::set_can_recurse -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "can_recurse", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether recursion is allowed for this source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_set_can_recurse" g_source_set_can_recurse :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) CInt -> -- can_recurse : TBasicType TBoolean IO () {- | Sets whether a source can be called recursively. If /@canRecurse@/ is 'True', then while the source is being dispatched then this source will be processed normally. Otherwise, all processing of this source is blocked until the dispatch function returns. -} sourceSetCanRecurse :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Bool {- ^ /@canRecurse@/: whether recursion is allowed for this source -} -> m () sourceSetCanRecurse source canRecurse = liftIO $ do source' <- unsafeManagedPtrGetPtr source let canRecurse' = (fromIntegral . fromEnum) canRecurse g_source_set_can_recurse source' canRecurse' touchManagedPtr source return () #if ENABLE_OVERLOADING data SourceSetCanRecurseMethodInfo instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo SourceSetCanRecurseMethodInfo Source signature where overloadedMethod _ = sourceSetCanRecurse #endif -- method Source::set_funcs -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "funcs", argType = TInterface (Name {namespace = "GLib", name = "SourceFuncs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new #GSourceFuncs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_set_funcs" g_source_set_funcs :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Ptr GLib.SourceFuncs.SourceFuncs -> -- funcs : TInterface (Name {namespace = "GLib", name = "SourceFuncs"}) IO () {- | Sets the source functions (can be used to override default implementations) of an unattached source. /Since: 2.12/ -} sourceSetFuncs :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> GLib.SourceFuncs.SourceFuncs {- ^ /@funcs@/: the new 'GI.GLib.Structs.SourceFuncs.SourceFuncs' -} -> m () sourceSetFuncs source funcs = liftIO $ do source' <- unsafeManagedPtrGetPtr source funcs' <- unsafeManagedPtrGetPtr funcs g_source_set_funcs source' funcs' touchManagedPtr source touchManagedPtr funcs return () #if ENABLE_OVERLOADING data SourceSetFuncsMethodInfo instance (signature ~ (GLib.SourceFuncs.SourceFuncs -> m ()), MonadIO m) => O.MethodInfo SourceSetFuncsMethodInfo Source signature where overloadedMethod _ = sourceSetFuncs #endif -- method Source::set_name -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "debug name for the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_set_name" g_source_set_name :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) CString -> -- name : TBasicType TUTF8 IO () {- | Sets a name for the source, used in debugging and profiling. The name defaults to @/NULL/@. The source name should describe in a human-readable way what the source does. For example, \"X11 event queue\" or \"GTK+ repaint idle handler\" or whatever it is. It is permitted to call this function multiple times, but is not recommended due to the potential performance impact. For example, one could change the name in the \"check\" function of a 'GI.GLib.Structs.SourceFuncs.SourceFuncs' to include details like the event type in the source name. Use caution if changing the name while another thread may be accessing it with 'GI.GLib.Structs.Source.sourceGetName'; that function does not copy the value, and changing the value will free it while the other thread may be attempting to use it. /Since: 2.26/ -} sourceSetName :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> T.Text {- ^ /@name@/: debug name for the source -} -> m () sourceSetName source name = liftIO $ do source' <- unsafeManagedPtrGetPtr source name' <- textToCString name g_source_set_name source' name' touchManagedPtr source freeMem name' return () #if ENABLE_OVERLOADING data SourceSetNameMethodInfo instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo SourceSetNameMethodInfo Source signature where overloadedMethod _ = sourceSetName #endif -- method Source::set_priority -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new priority.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_set_priority" g_source_set_priority :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Int32 -> -- priority : TBasicType TInt IO () {- | Sets the priority of a source. While the main loop is being run, a source will be dispatched if it is ready to be dispatched and no sources at a higher (numerically smaller) priority are ready to be dispatched. A child source always has the same priority as its parent. It is not permitted to change the priority of a source once it has been added as a child of another source. -} sourceSetPriority :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Int32 {- ^ /@priority@/: the new priority. -} -> m () sourceSetPriority source priority = liftIO $ do source' <- unsafeManagedPtrGetPtr source g_source_set_priority source' priority touchManagedPtr source return () #if ENABLE_OVERLOADING data SourceSetPriorityMethodInfo instance (signature ~ (Int32 -> m ()), MonadIO m) => O.MethodInfo SourceSetPriorityMethodInfo Source signature where overloadedMethod _ = sourceSetPriority #endif -- method Source::set_ready_time -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ready_time", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the monotonic time at which the source will be ready,\n 0 for \"immediately\", -1 for \"never\"", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_set_ready_time" g_source_set_ready_time :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) Int64 -> -- ready_time : TBasicType TInt64 IO () {- | Sets a 'GI.GLib.Structs.Source.Source' to be dispatched when the given monotonic time is reached (or passed). If the monotonic time is in the past (as it always will be if /@readyTime@/ is 0) then the source will be dispatched immediately. If /@readyTime@/ is -1 then the source is never woken up on the basis of the passage of time. Dispatching the source does not reset the ready time. You should do so yourself, from the source dispatch function. Note that if you have a pair of sources where the ready time of one suggests that it will be delivered first but the priority for the other suggests that it would be delivered first, and the ready time for both sources is reached during the same main context iteration, then the order of dispatch is undefined. It is a no-op to call this function on a 'GI.GLib.Structs.Source.Source' which has already been destroyed with 'GI.GLib.Structs.Source.sourceDestroy'. This API is only intended to be used by implementations of 'GI.GLib.Structs.Source.Source'. Do not call this API on a 'GI.GLib.Structs.Source.Source' that you did not create. /Since: 2.36/ -} sourceSetReadyTime :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> Int64 {- ^ /@readyTime@/: the monotonic time at which the source will be ready, 0 for \"immediately\", -1 for \"never\" -} -> m () sourceSetReadyTime source readyTime = liftIO $ do source' <- unsafeManagedPtrGetPtr source g_source_set_ready_time source' readyTime touchManagedPtr source return () #if ENABLE_OVERLOADING data SourceSetReadyTimeMethodInfo instance (signature ~ (Int64 -> m ()), MonadIO m) => O.MethodInfo SourceSetReadyTimeMethodInfo Source signature where overloadedMethod _ = sourceSetReadyTime #endif -- method Source::unref -- method type : OrdinaryMethod -- Args : [Arg {argCName = "source", argType = TInterface (Name {namespace = "GLib", name = "Source"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_unref" g_source_unref :: Ptr Source -> -- source : TInterface (Name {namespace = "GLib", name = "Source"}) IO () {- | Decreases the reference count of a source by one. If the resulting reference count is zero the source and associated memory will be destroyed. -} sourceUnref :: (B.CallStack.HasCallStack, MonadIO m) => Source {- ^ /@source@/: a 'GI.GLib.Structs.Source.Source' -} -> m () sourceUnref source = liftIO $ do source' <- unsafeManagedPtrGetPtr source g_source_unref source' touchManagedPtr source return () #if ENABLE_OVERLOADING data SourceUnrefMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo SourceUnrefMethodInfo Source signature where overloadedMethod _ = sourceUnref #endif -- method Source::remove -- method type : MemberFunction -- Args : [Arg {argCName = "tag", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the ID of the source to remove.", 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_source_remove" g_source_remove :: Word32 -> -- tag : TBasicType TUInt IO CInt {- | Removes the source with the given ID from the default main context. You must use 'GI.GLib.Structs.Source.sourceDestroy' for sources added to a non-default main context. The ID of a 'GI.GLib.Structs.Source.Source' is given by 'GI.GLib.Structs.Source.sourceGetId', or will be returned by the functions 'GI.GLib.Structs.Source.sourceAttach', @/g_idle_add()/@, 'GI.GLib.Functions.idleAdd', @/g_timeout_add()/@, 'GI.GLib.Functions.timeoutAdd', @/g_child_watch_add()/@, 'GI.GLib.Functions.childWatchAdd', @/g_io_add_watch()/@, and 'GI.GLib.Functions.ioAddWatch'. It is a programmer error to attempt to remove a non-existent source. More specifically: source IDs can be reissued after a source has been destroyed and therefore it is never valid to use this function with a source ID which may have already been removed. An example is when scheduling an idle to run in another thread with @/g_idle_add()/@: the idle may already have run and been removed by the time this function is called on its (now invalid) source ID. This source ID may have been reissued, leading to the operation being performed against the wrong source. -} sourceRemove :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@tag@/: the ID of the source to remove. -} -> m Bool {- ^ __Returns:__ For historical reasons, this function always returns 'True' -} sourceRemove tag = liftIO $ do result <- g_source_remove tag let result' = (/= 0) result return result' #if ENABLE_OVERLOADING #endif -- method Source::remove_by_funcs_user_data -- method type : MemberFunction -- Args : [Arg {argCName = "funcs", argType = TInterface (Name {namespace = "GLib", name = "SourceFuncs"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The @source_funcs passed to g_source_new()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the user data for the callback", 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_source_remove_by_funcs_user_data" g_source_remove_by_funcs_user_data :: Ptr GLib.SourceFuncs.SourceFuncs -> -- funcs : TInterface (Name {namespace = "GLib", name = "SourceFuncs"}) Ptr () -> -- user_data : TBasicType TPtr IO CInt {- | Removes a source from the default main loop context given the source functions and user data. If multiple sources exist with the same source functions and user data, only one will be destroyed. -} sourceRemoveByFuncsUserData :: (B.CallStack.HasCallStack, MonadIO m) => GLib.SourceFuncs.SourceFuncs {- ^ /@funcs@/: The /@sourceFuncs@/ passed to 'GI.GLib.Structs.Source.sourceNew' -} -> Ptr () {- ^ /@userData@/: the user data for the callback -} -> m Bool {- ^ __Returns:__ 'True' if a source was found and removed. -} sourceRemoveByFuncsUserData funcs userData = liftIO $ do funcs' <- unsafeManagedPtrGetPtr funcs result <- g_source_remove_by_funcs_user_data funcs' userData let result' = (/= 0) result touchManagedPtr funcs return result' #if ENABLE_OVERLOADING #endif -- method Source::remove_by_user_data -- method type : MemberFunction -- Args : [Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the user_data for the callback.", 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_source_remove_by_user_data" g_source_remove_by_user_data :: Ptr () -> -- user_data : TBasicType TPtr IO CInt {- | Removes a source from the default main loop context given the user data for the callback. If multiple sources exist with the same user data, only one will be destroyed. -} sourceRemoveByUserData :: (B.CallStack.HasCallStack, MonadIO m) => Ptr () {- ^ /@userData@/: the user_data for the callback. -} -> m Bool {- ^ __Returns:__ 'True' if a source was found and removed. -} sourceRemoveByUserData userData = liftIO $ do result <- g_source_remove_by_user_data userData let result' = (/= 0) result return result' #if ENABLE_OVERLOADING #endif -- method Source::set_name_by_id -- method type : MemberFunction -- Args : [Arg {argCName = "tag", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSource ID", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "debug name for the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_source_set_name_by_id" g_source_set_name_by_id :: Word32 -> -- tag : TBasicType TUInt CString -> -- name : TBasicType TUTF8 IO () {- | Sets the name of a source using its ID. This is a convenience utility to set source names from the return value of @/g_idle_add()/@, @/g_timeout_add()/@, etc. It is a programmer error to attempt to set the name of a non-existent source. More specifically: source IDs can be reissued after a source has been destroyed and therefore it is never valid to use this function with a source ID which may have already been removed. An example is when scheduling an idle to run in another thread with @/g_idle_add()/@: the idle may already have run and been removed by the time this function is called on its (now invalid) source ID. This source ID may have been reissued, leading to the operation being performed against the wrong source. /Since: 2.26/ -} sourceSetNameById :: (B.CallStack.HasCallStack, MonadIO m) => Word32 {- ^ /@tag@/: a 'GI.GLib.Structs.Source.Source' ID -} -> T.Text {- ^ /@name@/: debug name for the source -} -> m () sourceSetNameById tag name = liftIO $ do name' <- textToCString name g_source_set_name_by_id tag name' freeMem name' return () #if ENABLE_OVERLOADING #endif #if ENABLE_OVERLOADING type family ResolveSourceMethod (t :: Symbol) (o :: *) :: * where ResolveSourceMethod "addChildSource" o = SourceAddChildSourceMethodInfo ResolveSourceMethod "addPoll" o = SourceAddPollMethodInfo ResolveSourceMethod "addUnixFd" o = SourceAddUnixFdMethodInfo ResolveSourceMethod "attach" o = SourceAttachMethodInfo ResolveSourceMethod "destroy" o = SourceDestroyMethodInfo ResolveSourceMethod "isDestroyed" o = SourceIsDestroyedMethodInfo ResolveSourceMethod "modifyUnixFd" o = SourceModifyUnixFdMethodInfo ResolveSourceMethod "queryUnixFd" o = SourceQueryUnixFdMethodInfo ResolveSourceMethod "ref" o = SourceRefMethodInfo ResolveSourceMethod "removeChildSource" o = SourceRemoveChildSourceMethodInfo ResolveSourceMethod "removePoll" o = SourceRemovePollMethodInfo ResolveSourceMethod "removeUnixFd" o = SourceRemoveUnixFdMethodInfo ResolveSourceMethod "unref" o = SourceUnrefMethodInfo ResolveSourceMethod "getCanRecurse" o = SourceGetCanRecurseMethodInfo ResolveSourceMethod "getContext" o = SourceGetContextMethodInfo ResolveSourceMethod "getCurrentTime" o = SourceGetCurrentTimeMethodInfo ResolveSourceMethod "getId" o = SourceGetIdMethodInfo ResolveSourceMethod "getName" o = SourceGetNameMethodInfo ResolveSourceMethod "getPriority" o = SourceGetPriorityMethodInfo ResolveSourceMethod "getReadyTime" o = SourceGetReadyTimeMethodInfo ResolveSourceMethod "getTime" o = SourceGetTimeMethodInfo ResolveSourceMethod "setCallback" o = SourceSetCallbackMethodInfo ResolveSourceMethod "setCallbackIndirect" o = SourceSetCallbackIndirectMethodInfo ResolveSourceMethod "setCanRecurse" o = SourceSetCanRecurseMethodInfo ResolveSourceMethod "setFuncs" o = SourceSetFuncsMethodInfo ResolveSourceMethod "setName" o = SourceSetNameMethodInfo ResolveSourceMethod "setPriority" o = SourceSetPriorityMethodInfo ResolveSourceMethod "setReadyTime" o = SourceSetReadyTimeMethodInfo ResolveSourceMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveSourceMethod t Source, O.MethodInfo info Source p) => O.IsLabelProxy t (Source -> p) where fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveSourceMethod t Source, O.MethodInfo info Source p) => O.IsLabel t (Source -> p) where #if MIN_VERSION_base(4,10,0) fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #else fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif #endif #endif