{-# LANGUAGE TypeApplications #-}
#if !defined(__HADDOCK_VERSION__)
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.MainLoop
(
MainLoop(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveMainLoopMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
MainLoopGetContextMethodInfo ,
#endif
mainLoopGetContext ,
#if defined(ENABLE_OVERLOADING)
MainLoopIsRunningMethodInfo ,
#endif
mainLoopIsRunning ,
mainLoopNew ,
#if defined(ENABLE_OVERLOADING)
MainLoopQuitMethodInfo ,
#endif
mainLoopQuit ,
#if defined(ENABLE_OVERLOADING)
MainLoopRefMethodInfo ,
#endif
mainLoopRef ,
#if defined(ENABLE_OVERLOADING)
MainLoopRunMethodInfo ,
#endif
mainLoopRun ,
#if defined(ENABLE_OVERLOADING)
MainLoopUnrefMethodInfo ,
#endif
mainLoopUnref ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import {-# SOURCE #-} qualified GI.GLib.Flags as GLib.Flags
import {-# SOURCE #-} qualified GI.GLib.Structs.Cond as GLib.Cond
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.Source as GLib.Source
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
import {-# SOURCE #-} qualified GI.GLib.Unions.Mutex as GLib.Mutex
#else
import {-# SOURCE #-} qualified GI.GLib.Structs.MainContext as GLib.MainContext
#endif
newtype MainLoop = MainLoop (SP.ManagedPtr MainLoop)
deriving (MainLoop -> MainLoop -> Bool
(MainLoop -> MainLoop -> Bool)
-> (MainLoop -> MainLoop -> Bool) -> Eq MainLoop
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MainLoop -> MainLoop -> Bool
== :: MainLoop -> MainLoop -> Bool
$c/= :: MainLoop -> MainLoop -> Bool
/= :: MainLoop -> MainLoop -> Bool
Eq)
instance SP.ManagedPtrNewtype MainLoop where
toManagedPtr :: MainLoop -> ManagedPtr MainLoop
toManagedPtr (MainLoop ManagedPtr MainLoop
p) = ManagedPtr MainLoop
p
foreign import ccall "g_main_loop_get_type" c_g_main_loop_get_type ::
IO GType
type instance O.ParentTypes MainLoop = '[]
instance O.HasParentTypes MainLoop
instance B.Types.TypedObject MainLoop where
glibType :: IO GType
glibType = IO GType
c_g_main_loop_get_type
instance B.Types.GBoxed MainLoop
instance B.GValue.IsGValue (Maybe MainLoop) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_main_loop_get_type
gvalueSet_ :: Ptr GValue -> Maybe MainLoop -> IO ()
gvalueSet_ Ptr GValue
gv Maybe MainLoop
P.Nothing = Ptr GValue -> Ptr MainLoop -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr MainLoop
forall a. Ptr a
FP.nullPtr :: FP.Ptr MainLoop)
gvalueSet_ Ptr GValue
gv (P.Just MainLoop
obj) = MainLoop -> (Ptr MainLoop -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr MainLoop
obj (Ptr GValue -> Ptr MainLoop -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe MainLoop)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr MainLoop)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr MainLoop)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newBoxed MainLoop ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList MainLoop
type instance O.AttributeList MainLoop = MainLoopAttributeList
type MainLoopAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_main_loop_new" g_main_loop_new ::
Ptr GLib.MainContext.MainContext ->
CInt ->
IO (Ptr MainLoop)
mainLoopNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
Maybe (GLib.MainContext.MainContext)
-> Bool
-> m MainLoop
mainLoopNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe MainContext -> Bool -> m MainLoop
mainLoopNew Maybe MainContext
context Bool
isRunning = IO MainLoop -> m MainLoop
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO MainLoop -> m MainLoop) -> IO MainLoop -> m MainLoop
forall a b. (a -> b) -> a -> b
$ do
maybeContext <- case Maybe MainContext
context of
Maybe MainContext
Nothing -> Ptr MainContext -> IO (Ptr MainContext)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr MainContext
forall a. Ptr a
FP.nullPtr
Just MainContext
jContext -> do
jContext' <- MainContext -> IO (Ptr MainContext)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainContext
jContext
return jContext'
let isRunning' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.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
P.fromEnum) Bool
isRunning
result <- g_main_loop_new maybeContext isRunning'
checkUnexpectedReturnNULL "mainLoopNew" result
result' <- (wrapBoxed MainLoop) result
whenJust context touchManagedPtr
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_main_loop_get_context" g_main_loop_get_context ::
Ptr MainLoop ->
IO (Ptr GLib.MainContext.MainContext)
mainLoopGetContext ::
(B.CallStack.HasCallStack, MonadIO m) =>
MainLoop
-> m GLib.MainContext.MainContext
mainLoopGetContext :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MainLoop -> m MainContext
mainLoopGetContext MainLoop
loop = IO MainContext -> m MainContext
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO MainContext -> m MainContext)
-> IO MainContext -> m MainContext
forall a b. (a -> b) -> a -> b
$ do
loop' <- MainLoop -> IO (Ptr MainLoop)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainLoop
loop
result <- g_main_loop_get_context loop'
checkUnexpectedReturnNULL "mainLoopGetContext" result
result' <- (newBoxed GLib.MainContext.MainContext) result
touchManagedPtr loop
return result'
#if defined(ENABLE_OVERLOADING)
data MainLoopGetContextMethodInfo
instance (signature ~ (m GLib.MainContext.MainContext), MonadIO m) => O.OverloadedMethod MainLoopGetContextMethodInfo MainLoop signature where
overloadedMethod = mainLoopGetContext
instance O.OverloadedMethodInfo MainLoopGetContextMethodInfo MainLoop where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MainLoop.mainLoopGetContext",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-MainLoop.html#v:mainLoopGetContext"
})
#endif
foreign import ccall "g_main_loop_is_running" g_main_loop_is_running ::
Ptr MainLoop ->
IO CInt
mainLoopIsRunning ::
(B.CallStack.HasCallStack, MonadIO m) =>
MainLoop
-> m Bool
mainLoopIsRunning :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MainLoop -> m Bool
mainLoopIsRunning MainLoop
loop = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
loop' <- MainLoop -> IO (Ptr MainLoop)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainLoop
loop
result <- g_main_loop_is_running loop'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr loop
return result'
#if defined(ENABLE_OVERLOADING)
data MainLoopIsRunningMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.OverloadedMethod MainLoopIsRunningMethodInfo MainLoop signature where
overloadedMethod = mainLoopIsRunning
instance O.OverloadedMethodInfo MainLoopIsRunningMethodInfo MainLoop where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MainLoop.mainLoopIsRunning",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-MainLoop.html#v:mainLoopIsRunning"
})
#endif
foreign import ccall "g_main_loop_quit" g_main_loop_quit ::
Ptr MainLoop ->
IO ()
mainLoopQuit ::
(B.CallStack.HasCallStack, MonadIO m) =>
MainLoop
-> m ()
mainLoopQuit :: forall (m :: * -> *). (HasCallStack, MonadIO m) => MainLoop -> m ()
mainLoopQuit MainLoop
loop = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
loop' <- MainLoop -> IO (Ptr MainLoop)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainLoop
loop
g_main_loop_quit loop'
touchManagedPtr loop
return ()
#if defined(ENABLE_OVERLOADING)
data MainLoopQuitMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod MainLoopQuitMethodInfo MainLoop signature where
overloadedMethod = mainLoopQuit
instance O.OverloadedMethodInfo MainLoopQuitMethodInfo MainLoop where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MainLoop.mainLoopQuit",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-MainLoop.html#v:mainLoopQuit"
})
#endif
foreign import ccall "g_main_loop_ref" g_main_loop_ref ::
Ptr MainLoop ->
IO (Ptr MainLoop)
mainLoopRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
MainLoop
-> m MainLoop
mainLoopRef :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
MainLoop -> m MainLoop
mainLoopRef MainLoop
loop = IO MainLoop -> m MainLoop
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO MainLoop -> m MainLoop) -> IO MainLoop -> m MainLoop
forall a b. (a -> b) -> a -> b
$ do
loop' <- MainLoop -> IO (Ptr MainLoop)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainLoop
loop
result <- g_main_loop_ref loop'
checkUnexpectedReturnNULL "mainLoopRef" result
result' <- (wrapBoxed MainLoop) result
touchManagedPtr loop
return result'
#if defined(ENABLE_OVERLOADING)
data MainLoopRefMethodInfo
instance (signature ~ (m MainLoop), MonadIO m) => O.OverloadedMethod MainLoopRefMethodInfo MainLoop signature where
overloadedMethod = mainLoopRef
instance O.OverloadedMethodInfo MainLoopRefMethodInfo MainLoop where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MainLoop.mainLoopRef",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-MainLoop.html#v:mainLoopRef"
})
#endif
foreign import ccall "g_main_loop_run" g_main_loop_run ::
Ptr MainLoop ->
IO ()
mainLoopRun ::
(B.CallStack.HasCallStack, MonadIO m) =>
MainLoop
-> m ()
mainLoopRun :: forall (m :: * -> *). (HasCallStack, MonadIO m) => MainLoop -> m ()
mainLoopRun MainLoop
loop = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
loop' <- MainLoop -> IO (Ptr MainLoop)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainLoop
loop
g_main_loop_run loop'
touchManagedPtr loop
return ()
#if defined(ENABLE_OVERLOADING)
data MainLoopRunMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod MainLoopRunMethodInfo MainLoop signature where
overloadedMethod = mainLoopRun
instance O.OverloadedMethodInfo MainLoopRunMethodInfo MainLoop where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MainLoop.mainLoopRun",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-MainLoop.html#v:mainLoopRun"
})
#endif
foreign import ccall "g_main_loop_unref" g_main_loop_unref ::
Ptr MainLoop ->
IO ()
mainLoopUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
MainLoop
-> m ()
mainLoopUnref :: forall (m :: * -> *). (HasCallStack, MonadIO m) => MainLoop -> m ()
mainLoopUnref MainLoop
loop = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
loop' <- MainLoop -> IO (Ptr MainLoop)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MainLoop
loop
g_main_loop_unref loop'
touchManagedPtr loop
return ()
#if defined(ENABLE_OVERLOADING)
data MainLoopUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod MainLoopUnrefMethodInfo MainLoop signature where
overloadedMethod = mainLoopUnref
instance O.OverloadedMethodInfo MainLoopUnrefMethodInfo MainLoop where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.MainLoop.mainLoopUnref",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-MainLoop.html#v:mainLoopUnref"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveMainLoopMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveMainLoopMethod "isRunning" o = MainLoopIsRunningMethodInfo
ResolveMainLoopMethod "quit" o = MainLoopQuitMethodInfo
ResolveMainLoopMethod "ref" o = MainLoopRefMethodInfo
ResolveMainLoopMethod "run" o = MainLoopRunMethodInfo
ResolveMainLoopMethod "unref" o = MainLoopUnrefMethodInfo
ResolveMainLoopMethod "getContext" o = MainLoopGetContextMethodInfo
ResolveMainLoopMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveMainLoopMethod t MainLoop, O.OverloadedMethod info MainLoop p) => OL.IsLabel t (MainLoop -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveMainLoopMethod t MainLoop, O.OverloadedMethod info MainLoop p, R.HasField t MainLoop p) => R.HasField t MainLoop p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveMainLoopMethod t MainLoop, O.OverloadedMethodInfo info MainLoop) => OL.IsLabel t (O.MethodProxy info MainLoop) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif