    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- The @GSource@ struct is an opaque data type
    -- representing an event source.

    #if !defined(__HADDOCK_VERSION__)
    #define ENABLE_OVERLOADING
    #endif

    module GI.GLib.Structs.Source
        (

    -- * Exported types
        Source(..)                              ,
        newZeroSource                           ,

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

    #if defined(ENABLE_OVERLOADING)
        ResolveSourceMethod                     ,
    #endif

    -- ** addChildSource #method:addChildSource#

    #if defined(ENABLE_OVERLOADING)
        SourceAddChildSourceMethodInfo          ,
    #endif
        sourceAddChildSource                    ,

    -- ** addPoll #method:addPoll#

    #if defined(ENABLE_OVERLOADING)
        SourceAddPollMethodInfo                 ,
    #endif
        sourceAddPoll                           ,

    -- ** addUnixFd #method:addUnixFd#

    #if defined(ENABLE_OVERLOADING)
        SourceAddUnixFdMethodInfo               ,
    #endif
        sourceAddUnixFd                         ,

    -- ** attach #method:attach#

    #if defined(ENABLE_OVERLOADING)
        SourceAttachMethodInfo                  ,
    #endif
        sourceAttach                            ,

    -- ** destroy #method:destroy#

    #if defined(ENABLE_OVERLOADING)
        SourceDestroyMethodInfo                 ,
    #endif
        sourceDestroy                           ,

    -- ** getCanRecurse #method:getCanRecurse#

    #if defined(ENABLE_OVERLOADING)
        SourceGetCanRecurseMethodInfo           ,
    #endif
        sourceGetCanRecurse                     ,

    -- ** getContext #method:getContext#

    #if defined(ENABLE_OVERLOADING)
        SourceGetContextMethodInfo              ,
    #endif
        sourceGetContext                        ,

    -- ** getCurrentTime #method:getCurrentTime#

    #if defined(ENABLE_OVERLOADING)
        SourceGetCurrentTimeMethodInfo          ,
    #endif
        sourceGetCurrentTime                    ,

    -- ** getId #method:getId#

    #if defined(ENABLE_OVERLOADING)
        SourceGetIdMethodInfo                   ,
    #endif
        sourceGetId                             ,

    -- ** getName #method:getName#

    #if defined(ENABLE_OVERLOADING)
        SourceGetNameMethodInfo                 ,
    #endif
        sourceGetName                           ,

    -- ** getPriority #method:getPriority#

    #if defined(ENABLE_OVERLOADING)
        SourceGetPriorityMethodInfo             ,
    #endif
        sourceGetPriority                       ,

    -- ** getReadyTime #method:getReadyTime#

    #if defined(ENABLE_OVERLOADING)
        SourceGetReadyTimeMethodInfo            ,
    #endif
        sourceGetReadyTime                      ,

    -- ** getTime #method:getTime#

    #if defined(ENABLE_OVERLOADING)
        SourceGetTimeMethodInfo                 ,
    #endif
        sourceGetTime                           ,

    -- ** isDestroyed #method:isDestroyed#

    #if defined(ENABLE_OVERLOADING)
        SourceIsDestroyedMethodInfo             ,
    #endif
        sourceIsDestroyed                       ,

    -- ** modifyUnixFd #method:modifyUnixFd#

    #if defined(ENABLE_OVERLOADING)
        SourceModifyUnixFdMethodInfo            ,
    #endif
        sourceModifyUnixFd                      ,

    -- ** new #method:new#

        sourceNew                               ,

    -- ** queryUnixFd #method:queryUnixFd#

    #if defined(ENABLE_OVERLOADING)
        SourceQueryUnixFdMethodInfo             ,
    #endif
        sourceQueryUnixFd                       ,

    -- ** ref #method:ref#

    #if defined(ENABLE_OVERLOADING)
        SourceRefMethodInfo                     ,
    #endif
        sourceRef                               ,

    -- ** remove #method:remove#

        sourceRemove                            ,

    -- ** removeByFuncsUserData #method:removeByFuncsUserData#

        sourceRemoveByFuncsUserData             ,

    -- ** removeByUserData #method:removeByUserData#

        sourceRemoveByUserData                  ,

    -- ** removeChildSource #method:removeChildSource#

    #if defined(ENABLE_OVERLOADING)
        SourceRemoveChildSourceMethodInfo       ,
    #endif
        sourceRemoveChildSource                 ,

    -- ** removePoll #method:removePoll#

    #if defined(ENABLE_OVERLOADING)
        SourceRemovePollMethodInfo              ,
    #endif
        sourceRemovePoll                        ,

    -- ** removeUnixFd #method:removeUnixFd#

    #if defined(ENABLE_OVERLOADING)
        SourceRemoveUnixFdMethodInfo            ,
    #endif
        sourceRemoveUnixFd                      ,

    -- ** setCallback #method:setCallback#

    #if defined(ENABLE_OVERLOADING)
        SourceSetCallbackMethodInfo             ,
    #endif
        sourceSetCallback                       ,

    -- ** setCallbackIndirect #method:setCallbackIndirect#

    #if defined(ENABLE_OVERLOADING)
        SourceSetCallbackIndirectMethodInfo     ,
    #endif
        sourceSetCallbackIndirect               ,

    -- ** setCanRecurse #method:setCanRecurse#

    #if defined(ENABLE_OVERLOADING)
        SourceSetCanRecurseMethodInfo           ,
    #endif
        sourceSetCanRecurse                     ,

    -- ** setFuncs #method:setFuncs#

    #if defined(ENABLE_OVERLOADING)
        SourceSetFuncsMethodInfo                ,
    #endif
        sourceSetFuncs                          ,

    -- ** setName #method:setName#

    #if defined(ENABLE_OVERLOADING)
        SourceSetNameMethodInfo                 ,
    #endif
        sourceSetName                           ,

    -- ** setNameById #method:setNameById#

        sourceSetNameById                       ,

    -- ** setPriority #method:setPriority#

    #if defined(ENABLE_OVERLOADING)
        SourceSetPriorityMethodInfo             ,
    #endif
        sourceSetPriority                       ,

    -- ** setReadyTime #method:setReadyTime#

    #if defined(ENABLE_OVERLOADING)
        SourceSetReadyTimeMethodInfo            ,
    #endif
        sourceSetReadyTime                      ,

    -- ** unref #method:unref#

    #if defined(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.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.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.Text as T
    import qualified Data.ByteString.Char8 as B
    import qualified Data.Map as Map
    import qualified Foreign.Ptr as FP
    import qualified GHC.OverloadedLabels as OL

    import qualified GI.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 (SP.ManagedPtr Source)
        deriving (Source -> Source -> Bool
    (Source -> Source -> Bool)
    -> (Source -> Source -> Bool) -> Eq Source
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: Source -> Source -> Bool
    $c/= :: Source -> Source -> Bool
    == :: Source -> Source -> Bool
    $c== :: Source -> Source -> Bool
    Eq)

    instance SP.ManagedPtrNewtype Source where
        toManagedPtr :: Source -> ManagedPtr Source
    toManagedPtr (Source p :: ManagedPtr Source
    p) = ManagedPtr Source
    p

    foreign import ccall "g_source_get_type" c_g_source_get_type ::
        IO GType

    type instance O.ParentTypes Source = '[]
    instance O.HasParentTypes Source

    instance B.Types.TypedObject Source where
        glibType :: IO GType
    glibType = IO GType
    c_g_source_get_type

    instance B.Types.GBoxed Source

    -- | Convert 'Source' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
    instance B.GValue.IsGValue Source where
        toGValue :: Source -> IO GValue
    toGValue o :: Source
    o = do
            GType
    gtype <- IO GType
    c_g_source_get_type
            Source -> (Ptr Source -> IO GValue) -> IO GValue
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    B.ManagedPtr.withManagedPtr Source
    o (GType -> (GValue -> Ptr Source -> IO ()) -> Ptr Source -> IO GValue
    forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
    B.GValue.buildGValue GType
    gtype GValue -> Ptr Source -> IO ()
    forall a. GValue -> Ptr a -> IO ()
    B.GValue.set_boxed)

        fromGValue :: GValue -> IO Source
    fromGValue gv :: GValue
    gv = do
            Ptr Source
    ptr <- GValue -> IO (Ptr Source)
    forall b. GValue -> IO (Ptr b)
    B.GValue.get_boxed GValue
    gv :: IO (Ptr Source)
            (ManagedPtr Source -> Source) -> Ptr Source -> IO Source
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    B.ManagedPtr.newBoxed ManagedPtr Source -> Source
    Source Ptr Source
    ptr

    -- | Construct a `Source` struct initialized to zero.
    newZeroSource :: MonadIO m => m Source
    newZeroSource :: m Source
    newZeroSource = IO Source -> m Source
    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
    $ Int -> IO (Ptr Source)
    forall a. GBoxed a => Int -> IO (Ptr a)
    callocBoxedBytes 96 IO (Ptr Source) -> (Ptr Source -> IO Source) -> IO Source
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= (ManagedPtr Source -> Source) -> Ptr Source -> IO Source
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    wrapBoxed ManagedPtr Source -> Source
    Source

    instance tag ~ 'AttrSet => Constructible Source tag where
        new :: (ManagedPtr Source -> Source) -> [AttrOp Source tag] -> m Source
    new _ attrs :: [AttrOp Source tag]
    attrs = do
            Source
    o <- m Source
    forall (m :: * -> *). MonadIO m => m Source
    newZeroSource
            Source -> [AttrOp Source 'AttrSet] -> m ()
    forall o (m :: * -> *).
    MonadIO m =>
    o -> [AttrOp o 'AttrSet] -> m ()
    GI.Attributes.set Source
    o [AttrOp Source tag]
    [AttrOp Source 'AttrSet]
    attrs
            Source -> m Source
    forall (m :: * -> *) a. Monad m => a -> m a
    return Source
    o

    #if defined(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 t'GI.GLib.Structs.Source.Source' structure. The size is specified to
    -- allow creating structures derived from t'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 t'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 t'GI.GLib.Structs.Source.Source' structure to create.
        -> m Source
        -- ^ __Returns:__ the newly-created t'GI.GLib.Structs.Source.Source'.
    sourceNew :: SourceFuncs -> Word32 -> m Source
    sourceNew sourceFuncs :: SourceFuncs
    sourceFuncs structSize :: Word32
    structSize = IO Source -> m Source
    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
        Ptr SourceFuncs
    sourceFuncs' <- SourceFuncs -> IO (Ptr SourceFuncs)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr SourceFuncs
    sourceFuncs
        Ptr Source
    result <- Ptr SourceFuncs -> Word32 -> IO (Ptr Source)
    g_source_new Ptr SourceFuncs
    sourceFuncs' Word32
    structSize
        Text -> Ptr Source -> IO ()
    forall a. HasCallStack => Text -> Ptr a -> IO ()
    checkUnexpectedReturnNULL "sourceNew" Ptr Source
    result
        Source
    result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    wrapBoxed ManagedPtr Source -> Source
    Source) Ptr Source
    result
        SourceFuncs -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr SourceFuncs
    sourceFuncs
        Source -> IO Source
    forall (m :: * -> *) a. Monad m => a -> m a
    return Source
    result'

    #if defined(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 t'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 'P.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 t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'GI.GLib.Structs.Source.Source' that you did not create.
    --
    -- /Since: 2.28/
    sourceAddChildSource ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: a t'GI.GLib.Structs.Source.Source'
        -> Source
        -- ^ /@childSource@/: a second t'GI.GLib.Structs.Source.Source' that /@source@/ should \"poll\"
        -> m ()
    sourceAddChildSource :: Source -> Source -> m ()
    sourceAddChildSource source :: Source
    source childSource :: Source
    childSource = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr Source
    childSource' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    childSource
        Ptr Source -> Ptr Source -> IO ()
    g_source_add_child_source Ptr Source
    source' Ptr Source
    childSource'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    childSource
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.PollFD.PollFD' struct and return 'P.True' if events need
    -- to be processed.
    --
    -- This API is only intended to be used by implementations of t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'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 t'GI.GLib.Structs.Source.Source'
        -> GLib.PollFD.PollFD
        -- ^ /@fd@/: a t'GI.GLib.Structs.PollFD.PollFD' structure holding information about a file
        --      descriptor to watch.
        -> m ()
    sourceAddPoll :: Source -> PollFD -> m ()
    sourceAddPoll source :: Source
    source fd :: PollFD
    fd = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr PollFD
    fd' <- PollFD -> IO (Ptr PollFD)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr PollFD
    fd
        Ptr Source -> Ptr PollFD -> IO ()
    g_source_add_poll Ptr Source
    source' Ptr PollFD
    fd'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        PollFD -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr PollFD
    fd
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'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 t'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 -> Int32 -> [IOCondition] -> m (Ptr ())
    sourceAddUnixFd source :: Source
    source fd :: Int32
    fd events :: [IOCondition]
    events = IO (Ptr ()) -> m (Ptr ())
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        let events' :: CUInt
    events' = [IOCondition] -> CUInt
    forall b a. (Num b, IsGFlag a) => [a] -> b
    gflagsToWord [IOCondition]
    events
        Ptr ()
    result <- Ptr Source -> Int32 -> CUInt -> IO (Ptr ())
    g_source_add_unix_fd Ptr Source
    source' Int32
    fd CUInt
    events'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Ptr () -> IO (Ptr ())
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr ()
    result

    #if defined(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 t'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'.
    --
    -- This function is safe to call from any thread, regardless of which thread
    -- the /@context@/ is running in.
    sourceAttach ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: a t'GI.GLib.Structs.Source.Source'
        -> Maybe (GLib.MainContext.MainContext)
        -- ^ /@context@/: a t'GI.GLib.Structs.MainContext.MainContext' (if 'P.Nothing', the default context will be used)
        -> m Word32
        -- ^ __Returns:__ the ID (greater than 0) for the source within the
        --   t'GI.GLib.Structs.MainContext.MainContext'.
    sourceAttach :: Source -> Maybe MainContext -> m Word32
    sourceAttach source :: Source
    source context :: Maybe MainContext
    context = IO Word32 -> m Word32
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr MainContext
    maybeContext <- case Maybe MainContext
    context of
            Nothing -> Ptr MainContext -> IO (Ptr MainContext)
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr MainContext
    forall a. Ptr a
    nullPtr
            Just jContext :: MainContext
    jContext -> do
                Ptr MainContext
    jContext' <- MainContext -> IO (Ptr MainContext)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr MainContext
    jContext
                Ptr MainContext -> IO (Ptr MainContext)
    forall (m :: * -> *) a. Monad m => a -> m a
    return Ptr MainContext
    jContext'
        Word32
    result <- Ptr Source -> Ptr MainContext -> IO Word32
    g_source_attach Ptr Source
    source' Ptr MainContext
    maybeContext
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Maybe MainContext -> (MainContext -> IO ()) -> IO ()
    forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
    whenJust Maybe MainContext
    context MainContext -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr
        Word32 -> IO Word32
    forall (m :: * -> *) a. Monad m => a -> m a
    return Word32
    result

    #if defined(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 t'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.
    --
    -- This does not unref the t'GI.GLib.Structs.Source.Source': if you still hold a reference, use
    -- 'GI.GLib.Structs.Source.sourceUnref' to drop it.
    --
    -- This function is safe to call from any thread, regardless of which thread
    -- the t'GI.GLib.Structs.MainContext.MainContext' is running in.
    sourceDestroy ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: a t'GI.GLib.Structs.Source.Source'
        -> m ()
    sourceDestroy :: Source -> m ()
    sourceDestroy source :: Source
    source = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr Source -> IO ()
    g_source_destroy Ptr Source
    source'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> m Bool
        -- ^ __Returns:__ whether recursion is allowed.
    sourceGetCanRecurse :: Source -> m Bool
    sourceGetCanRecurse source :: Source
    source = IO Bool -> m Bool
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        CInt
    result <- Ptr Source -> IO CInt
    g_source_get_can_recurse Ptr Source
    source'
        let result' :: Bool
    result' = (CInt -> CInt -> Bool
    forall a. Eq a => a -> a -> Bool
    /= 0) CInt
    result
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Bool -> IO Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    result'

    #if defined(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 t'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 t'GI.GLib.Structs.MainContext.MainContext' it was attached to still exists (in which
    -- case it will return that t'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 t'GI.GLib.Structs.MainContext.MainContext' has been destroyed is an error.
    sourceGetContext ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: a t'GI.GLib.Structs.Source.Source'
        -> m (Maybe GLib.MainContext.MainContext)
        -- ^ __Returns:__ the t'GI.GLib.Structs.MainContext.MainContext' with which the
        --               source is associated, or 'P.Nothing' if the context has not
        --               yet been added to a source.
    sourceGetContext :: Source -> m (Maybe MainContext)
    sourceGetContext source :: Source
    source = IO (Maybe MainContext) -> m (Maybe MainContext)
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO (Maybe MainContext) -> m (Maybe MainContext))
    -> IO (Maybe MainContext) -> m (Maybe MainContext)
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr MainContext
    result <- Ptr Source -> IO (Ptr MainContext)
    g_source_get_context Ptr Source
    source'
        Maybe MainContext
    maybeResult <- Ptr MainContext
    -> (Ptr MainContext -> IO MainContext) -> IO (Maybe MainContext)
    forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
    convertIfNonNull Ptr MainContext
    result ((Ptr MainContext -> IO MainContext) -> IO (Maybe MainContext))
    -> (Ptr MainContext -> IO MainContext) -> IO (Maybe MainContext)
    forall a b. (a -> b) -> a -> b
    $ \result' :: Ptr MainContext
    result' -> do
            MainContext
    result'' <- ((ManagedPtr MainContext -> MainContext)
    -> Ptr MainContext -> IO MainContext
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    newBoxed ManagedPtr MainContext -> MainContext
    GLib.MainContext.MainContext) Ptr MainContext
    result'
            MainContext -> IO MainContext
    forall (m :: * -> *) a. Monad m => a -> m a
    return MainContext
    result''
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Maybe MainContext -> IO (Maybe MainContext)
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe MainContext
    maybeResult

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> GLib.TimeVal.TimeVal
        -- ^ /@timeval@/: t'GI.GLib.Structs.TimeVal.TimeVal' structure in which to store current time.
        -> m ()
    sourceGetCurrentTime :: Source -> TimeVal -> m ()
    sourceGetCurrentTime source :: Source
    source timeval :: TimeVal
    timeval = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr TimeVal
    timeval' <- TimeVal -> IO (Ptr TimeVal)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr TimeVal
    timeval
        Ptr Source -> Ptr TimeVal -> IO ()
    g_source_get_current_time Ptr Source
    source' Ptr TimeVal
    timeval'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        TimeVal -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr TimeVal
    timeval
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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'.
    --
    -- You can only call this function while the source is associated to a
    -- t'GI.GLib.Structs.MainContext.MainContext' instance; calling this function before 'GI.GLib.Structs.Source.sourceAttach'
    -- or after 'GI.GLib.Structs.Source.sourceDestroy' yields undefined behavior. The ID returned
    -- is unique within the t'GI.GLib.Structs.MainContext.MainContext' instance passed to 'GI.GLib.Structs.Source.sourceAttach'.
    sourceGetId ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: a t'GI.GLib.Structs.Source.Source'
        -> m Word32
        -- ^ __Returns:__ the ID (greater than 0) for the source
    sourceGetId :: Source -> m Word32
    sourceGetId source :: Source
    source = IO Word32 -> m Word32
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Word32
    result <- Ptr Source -> IO Word32
    g_source_get_id Ptr Source
    source'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Word32 -> IO Word32
    forall (m :: * -> *) a. Monad m => a -> m a
    return Word32
    result

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> m T.Text
        -- ^ __Returns:__ the name of the source
    sourceGetName :: Source -> m Text
    sourceGetName source :: Source
    source = IO Text -> m Text
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Text -> m Text) -> IO Text -> m Text
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        CString
    result <- Ptr Source -> IO CString
    g_source_get_name Ptr Source
    source'
        Text -> CString -> IO ()
    forall a. HasCallStack => Text -> Ptr a -> IO ()
    checkUnexpectedReturnNULL "sourceGetName" CString
    result
        Text
    result' <- HasCallStack => CString -> IO Text
    CString -> IO Text
    cstringToText CString
    result
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Text -> IO Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    result'

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> m Int32
        -- ^ __Returns:__ the priority of the source
    sourceGetPriority :: Source -> m Int32
    sourceGetPriority source :: Source
    source = IO Int32 -> m Int32
    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
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Int32
    result <- Ptr Source -> IO Int32
    g_source_get_priority Ptr Source
    source'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Int32 -> IO Int32
    forall (m :: * -> *) a. Monad m => a -> m a
    return Int32
    result

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> m Int64
        -- ^ __Returns:__ the monotonic ready time, -1 for \"never\"
    sourceGetReadyTime :: Source -> m Int64
    sourceGetReadyTime source :: Source
    source = IO Int64 -> m Int64
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Int64
    result <- Ptr Source -> IO Int64
    g_source_get_ready_time Ptr Source
    source'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Int64 -> IO Int64
    forall (m :: * -> *) a. Monad m => a -> m a
    return Int64
    result

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> m Int64
        -- ^ __Returns:__ the monotonic time in microseconds
    sourceGetTime :: Source -> m Int64
    sourceGetTime source :: Source
    source = IO Int64 -> m Int64
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Int64
    result <- Ptr Source -> IO Int64
    g_source_get_time Ptr Source
    source'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Int64 -> IO Int64
    forall (m :: * -> *) a. Monad m => a -> m a
    return Int64
    result

    #if defined(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
    -- t'GI.GLib.Structs.MainContext.MainContext' the t'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 t'GI.GLib.Structs.Source.Source'
        -> m Bool
        -- ^ __Returns:__ 'P.True' if the source has been destroyed
    sourceIsDestroyed :: Source -> m Bool
    sourceIsDestroyed source :: Source
    source = IO Bool -> m Bool
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        CInt
    result <- Ptr Source -> IO CInt
    g_source_is_destroyed Ptr Source
    source'
        let result' :: Bool
    result' = (CInt -> CInt -> Bool
    forall a. Eq a => a -> a -> Bool
    /= 0) CInt
    result
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Bool -> IO Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    result'

    #if defined(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 t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'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 t'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 -> Ptr () -> [IOCondition] -> m ()
    sourceModifyUnixFd source :: Source
    source tag :: Ptr ()
    tag newEvents :: [IOCondition]
    newEvents = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        let newEvents' :: CUInt
    newEvents' = [IOCondition] -> CUInt
    forall b a. (Num b, IsGFlag a) => [a] -> b
    gflagsToWord [IOCondition]
    newEvents
        Ptr Source -> Ptr () -> CUInt -> IO ()
    g_source_modify_unix_fd Ptr Source
    source' Ptr ()
    tag CUInt
    newEvents'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'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 t'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 -> Ptr () -> m [IOCondition]
    sourceQueryUnixFd source :: Source
    source tag :: Ptr ()
    tag = IO [IOCondition] -> m [IOCondition]
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO [IOCondition] -> m [IOCondition])
    -> IO [IOCondition] -> m [IOCondition]
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        CUInt
    result <- Ptr Source -> Ptr () -> IO CUInt
    g_source_query_unix_fd Ptr Source
    source' Ptr ()
    tag
        let result' :: [IOCondition]
    result' = CUInt -> [IOCondition]
    forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
    wordToGFlags CUInt
    result
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        [IOCondition] -> IO [IOCondition]
    forall (m :: * -> *) a. Monad m => a -> m a
    return [IOCondition]
    result'

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> m Source
        -- ^ __Returns:__ /@source@/
    sourceRef :: Source -> m Source
    sourceRef source :: Source
    source = IO Source -> m Source
    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
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr Source
    result <- Ptr Source -> IO (Ptr Source)
    g_source_ref Ptr Source
    source'
        Text -> Ptr Source -> IO ()
    forall a. HasCallStack => Text -> Ptr a -> IO ()
    checkUnexpectedReturnNULL "sourceRef" Ptr Source
    result
        Source
    result' <- ((ManagedPtr Source -> Source) -> Ptr Source -> IO Source
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    wrapBoxed ManagedPtr Source -> Source
    Source) Ptr Source
    result
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Source -> IO Source
    forall (m :: * -> *) a. Monad m => a -> m a
    return Source
    result'

    #if defined(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 t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'GI.GLib.Structs.Source.Source' that you did not create.
    --
    -- /Since: 2.28/
    sourceRemoveChildSource ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: a t'GI.GLib.Structs.Source.Source'
        -> Source
        -- ^ /@childSource@/: a t'GI.GLib.Structs.Source.Source' previously passed to
        --     'GI.GLib.Structs.Source.sourceAddChildSource'.
        -> m ()
    sourceRemoveChildSource :: Source -> Source -> m ()
    sourceRemoveChildSource source :: Source
    source childSource :: Source
    childSource = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr Source
    childSource' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    childSource
        Ptr Source -> Ptr Source -> IO ()
    g_source_remove_child_source Ptr Source
    source' Ptr Source
    childSource'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    childSource
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'GI.GLib.Structs.Source.Source' that you did not create.
    sourceRemovePoll ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: a t'GI.GLib.Structs.Source.Source'
        -> GLib.PollFD.PollFD
        -- ^ /@fd@/: a t'GI.GLib.Structs.PollFD.PollFD' structure previously passed to 'GI.GLib.Structs.Source.sourceAddPoll'.
        -> m ()
    sourceRemovePoll :: Source -> PollFD -> m ()
    sourceRemovePoll source :: Source
    source fd :: PollFD
    fd = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr PollFD
    fd' <- PollFD -> IO (Ptr PollFD)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr PollFD
    fd
        Ptr Source -> Ptr PollFD -> IO ()
    g_source_remove_poll Ptr Source
    source' Ptr PollFD
    fd'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        PollFD -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr PollFD
    fd
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'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 t'GI.GLib.Structs.Source.Source'
        -> Ptr ()
        -- ^ /@tag@/: the tag from 'GI.GLib.Structs.Source.sourceAddUnixFd'
        -> m ()
    sourceRemoveUnixFd :: Source -> Ptr () -> m ()
    sourceRemoveUnixFd source :: Source
    source tag :: Ptr ()
    tag = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr Source -> Ptr () -> IO ()
    g_source_remove_unix_fd Ptr Source
    source' Ptr ()
    tag
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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. Cast /@func@/ with @/G_SOURCE_FUNC()/@ to avoid warnings about
    -- incompatible function types.
    --
    -- 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, such as @/g_idle_add()/@ or @/g_timeout_add()/@.
    --
    -- It is safe to call this function multiple times on a source which has already
    -- been attached to a context. The changes will take effect for the next time
    -- the source is dispatched after this call returns.
    sourceSetCallback ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: the source
        -> GLib.Callbacks.SourceFunc
        -- ^ /@func@/: a callback function
        -> m ()
    sourceSetCallback :: Source -> IO Bool -> m ()
    sourceSetCallback source :: Source
    source func :: IO Bool
    func = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        FunPtr C_SourceFunc
    func' <- C_SourceFunc -> IO (FunPtr C_SourceFunc)
    GLib.Callbacks.mk_SourceFunc (Maybe (Ptr (FunPtr C_SourceFunc))
    -> SourceFunc_WithClosures -> C_SourceFunc
    GLib.Callbacks.wrap_SourceFunc Maybe (Ptr (FunPtr C_SourceFunc))
    forall a. Maybe a
    Nothing (IO Bool -> SourceFunc_WithClosures
    GLib.Callbacks.drop_closures_SourceFunc IO Bool
    func))
        let data_ :: Ptr ()
    data_ = FunPtr C_SourceFunc -> Ptr ()
    forall a b. FunPtr a -> Ptr b
    castFunPtrToPtr FunPtr C_SourceFunc
    func'
        let notify :: FunPtr (Ptr a -> IO ())
    notify = FunPtr (Ptr a -> IO ())
    forall a. FunPtr (Ptr a -> IO ())
    safeFreeFunPtrPtr
        Ptr Source
    -> FunPtr C_SourceFunc
    -> Ptr ()
    -> FunPtr (Ptr () -> IO ())
    -> IO ()
    g_source_set_callback Ptr Source
    source' FunPtr C_SourceFunc
    func' Ptr ()
    data_ FunPtr (Ptr () -> IO ())
    forall a. FunPtr (Ptr a -> IO ())
    notify
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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.
    --
    -- It is safe to call this function multiple times on a source which has already
    -- been attached to a context. The changes will take effect for the next time
    -- the source is dispatched after this call returns.
    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 -> Ptr () -> SourceCallbackFuncs -> m ()
    sourceSetCallbackIndirect source :: Source
    source callbackData :: Ptr ()
    callbackData callbackFuncs :: SourceCallbackFuncs
    callbackFuncs = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr SourceCallbackFuncs
    callbackFuncs' <- SourceCallbackFuncs -> IO (Ptr SourceCallbackFuncs)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr SourceCallbackFuncs
    callbackFuncs
        Ptr Source -> Ptr () -> Ptr SourceCallbackFuncs -> IO ()
    g_source_set_callback_indirect Ptr Source
    source' Ptr ()
    callbackData Ptr SourceCallbackFuncs
    callbackFuncs'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        SourceCallbackFuncs -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr SourceCallbackFuncs
    callbackFuncs
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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
    -- 'P.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 t'GI.GLib.Structs.Source.Source'
        -> Bool
        -- ^ /@canRecurse@/: whether recursion is allowed for this source
        -> m ()
    sourceSetCanRecurse :: Source -> Bool -> m ()
    sourceSetCanRecurse source :: Source
    source canRecurse :: Bool
    canRecurse = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        let canRecurse' :: CInt
    canRecurse' = (Int -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Bool -> Int
    forall a. Enum a => a -> Int
    fromEnum) Bool
    canRecurse
        Ptr Source -> CInt -> IO ()
    g_source_set_can_recurse Ptr Source
    source' CInt
    canRecurse'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> GLib.SourceFuncs.SourceFuncs
        -- ^ /@funcs@/: the new t'GI.GLib.Structs.SourceFuncs.SourceFuncs'
        -> m ()
    sourceSetFuncs :: Source -> SourceFuncs -> m ()
    sourceSetFuncs source :: Source
    source funcs :: SourceFuncs
    funcs = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr SourceFuncs
    funcs' <- SourceFuncs -> IO (Ptr SourceFuncs)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr SourceFuncs
    funcs
        Ptr Source -> Ptr SourceFuncs -> IO ()
    g_source_set_funcs Ptr Source
    source' Ptr SourceFuncs
    funcs'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        SourceFuncs -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr SourceFuncs
    funcs
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'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 t'GI.GLib.Structs.Source.Source'
        -> T.Text
        -- ^ /@name@/: debug name for the source
        -> m ()
    sourceSetName :: Source -> Text -> m ()
    sourceSetName source :: Source
    source name :: Text
    name = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        CString
    name' <- Text -> IO CString
    textToCString Text
    name
        Ptr Source -> CString -> IO ()
    g_source_set_name Ptr Source
    source' CString
    name'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        CString -> IO ()
    forall a. Ptr a -> IO ()
    freeMem CString
    name'
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> Int32
        -- ^ /@priority@/: the new priority.
        -> m ()
    sourceSetPriority :: Source -> Int32 -> m ()
    sourceSetPriority source :: Source
    source priority :: Int32
    priority = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr Source -> Int32 -> IO ()
    g_source_set_priority Ptr Source
    source' Int32
    priority
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'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 t'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 t'GI.GLib.Structs.Source.Source'.
    -- Do not call this API on a t'GI.GLib.Structs.Source.Source' that you did not create.
    --
    -- /Since: 2.36/
    sourceSetReadyTime ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Source
        -- ^ /@source@/: a t'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 -> Int64 -> m ()
    sourceSetReadyTime source :: Source
    source readyTime :: Int64
    readyTime = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr Source -> Int64 -> IO ()
    g_source_set_ready_time Ptr Source
    source' Int64
    readyTime
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'GI.GLib.Structs.Source.Source'
        -> m ()
    sourceUnref :: Source -> m ()
    sourceUnref source :: Source
    source = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr Source
    source' <- Source -> IO (Ptr Source)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr Source
    source
        Ptr Source -> IO ()
    g_source_unref Ptr Source
    source'
        Source -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr Source
    source
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(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 t'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 'P.True'
    sourceRemove :: Word32 -> m Bool
    sourceRemove tag :: Word32
    tag = IO Bool -> m Bool
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
    forall a b. (a -> b) -> a -> b
    $ do
        CInt
    result <- Word32 -> IO CInt
    g_source_remove Word32
    tag
        let result' :: Bool
    result' = (CInt -> CInt -> Bool
    forall a. Eq a => a -> a -> Bool
    /= 0) CInt
    result
        Bool -> IO Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    result'

    #if defined(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:__ 'P.True' if a source was found and removed.
    sourceRemoveByFuncsUserData :: SourceFuncs -> Ptr () -> m Bool
    sourceRemoveByFuncsUserData funcs :: SourceFuncs
    funcs userData :: Ptr ()
    userData = IO Bool -> m Bool
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
    forall a b. (a -> b) -> a -> b
    $ do
        Ptr SourceFuncs
    funcs' <- SourceFuncs -> IO (Ptr SourceFuncs)
    forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
    unsafeManagedPtrGetPtr SourceFuncs
    funcs
        CInt
    result <- Ptr SourceFuncs -> C_SourceFunc
    g_source_remove_by_funcs_user_data Ptr SourceFuncs
    funcs' Ptr ()
    userData
        let result' :: Bool
    result' = (CInt -> CInt -> Bool
    forall a. Eq a => a -> a -> Bool
    /= 0) CInt
    result
        SourceFuncs -> IO ()
    forall a. ManagedPtrNewtype a => a -> IO ()
    touchManagedPtr SourceFuncs
    funcs
        Bool -> IO Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    result'

    #if defined(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:__ 'P.True' if a source was found and removed.
    sourceRemoveByUserData :: Ptr () -> m Bool
    sourceRemoveByUserData userData :: Ptr ()
    userData = IO Bool -> m Bool
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
    forall a b. (a -> b) -> a -> b
    $ do
        CInt
    result <- C_SourceFunc
    g_source_remove_by_user_data Ptr ()
    userData
        let result' :: Bool
    result' = (CInt -> CInt -> Bool
    forall a. Eq a => a -> a -> Bool
    /= 0) CInt
    result
        Bool -> IO Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    result'

    #if defined(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 t'GI.GLib.Structs.Source.Source' ID
        -> T.Text
        -- ^ /@name@/: debug name for the source
        -> m ()
    sourceSetNameById :: Word32 -> Text -> m ()
    sourceSetNameById tag :: Word32
    tag name :: Text
    name = IO () -> m ()
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
        CString
    name' <- Text -> IO CString
    textToCString Text
    name
        Word32 -> CString -> IO ()
    g_source_set_name_by_id Word32
    tag CString
    name'
        CString -> IO ()
    forall a. Ptr a -> IO ()
    freeMem CString
    name'
        () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    #if defined(ENABLE_OVERLOADING)
    #endif

    #if defined(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) => OL.IsLabel t (Source -> p) where
    #if MIN_VERSION_base(4,10,0)
        fromLabel = O.overloadedMethod @info
    #else
        fromLabel _ = O.overloadedMethod @info
    #endif

    #endif