{-# LANGUAGE ImplicitParams, RankNTypes, TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Interfaces.MemoryMonitor
(
MemoryMonitor(..) ,
IsMemoryMonitor ,
toMemoryMonitor ,
#if defined(ENABLE_OVERLOADING)
ResolveMemoryMonitorMethod ,
#endif
memoryMonitorDupDefault ,
MemoryMonitorLowMemoryWarningCallback ,
#if defined(ENABLE_OVERLOADING)
MemoryMonitorLowMemoryWarningSignalInfo ,
#endif
afterMemoryMonitorLowMemoryWarning ,
onMemoryMonitorLowMemoryWarning ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.PollFD as GLib.PollFD
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Callbacks as GObject.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.GObject.Structs.Parameter as GObject.Parameter
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Initable as Gio.Initable
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
#else
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Initable as Gio.Initable
#endif
newtype MemoryMonitor = MemoryMonitor (SP.ManagedPtr MemoryMonitor)
deriving (MemoryMonitor -> MemoryMonitor -> Bool
(MemoryMonitor -> MemoryMonitor -> Bool)
-> (MemoryMonitor -> MemoryMonitor -> Bool) -> Eq MemoryMonitor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MemoryMonitor -> MemoryMonitor -> Bool
== :: MemoryMonitor -> MemoryMonitor -> Bool
$c/= :: MemoryMonitor -> MemoryMonitor -> Bool
/= :: MemoryMonitor -> MemoryMonitor -> Bool
Eq)
instance SP.ManagedPtrNewtype MemoryMonitor where
toManagedPtr :: MemoryMonitor -> ManagedPtr MemoryMonitor
toManagedPtr (MemoryMonitor ManagedPtr MemoryMonitor
p) = ManagedPtr MemoryMonitor
p
foreign import ccall "g_memory_monitor_get_type"
c_g_memory_monitor_get_type :: IO B.Types.GType
instance B.Types.TypedObject MemoryMonitor where
glibType :: IO GType
glibType = IO GType
c_g_memory_monitor_get_type
instance B.Types.GObject MemoryMonitor
class (SP.GObject o, O.IsDescendantOf MemoryMonitor o) => IsMemoryMonitor o
instance (SP.GObject o, O.IsDescendantOf MemoryMonitor o) => IsMemoryMonitor o
instance O.HasParentTypes MemoryMonitor
type instance O.ParentTypes MemoryMonitor = '[Gio.Initable.Initable, GObject.Object.Object]
toMemoryMonitor :: (MIO.MonadIO m, IsMemoryMonitor o) => o -> m MemoryMonitor
toMemoryMonitor :: forall (m :: * -> *) o.
(MonadIO m, IsMemoryMonitor o) =>
o -> m MemoryMonitor
toMemoryMonitor = IO MemoryMonitor -> m MemoryMonitor
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO MemoryMonitor -> m MemoryMonitor)
-> (o -> IO MemoryMonitor) -> o -> m MemoryMonitor
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr MemoryMonitor -> MemoryMonitor)
-> o -> IO MemoryMonitor
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr MemoryMonitor -> MemoryMonitor
MemoryMonitor
instance B.GValue.IsGValue (Maybe MemoryMonitor) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_memory_monitor_get_type
gvalueSet_ :: Ptr GValue -> Maybe MemoryMonitor -> IO ()
gvalueSet_ Ptr GValue
gv Maybe MemoryMonitor
P.Nothing = Ptr GValue -> Ptr MemoryMonitor -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr MemoryMonitor
forall a. Ptr a
FP.nullPtr :: FP.Ptr MemoryMonitor)
gvalueSet_ Ptr GValue
gv (P.Just MemoryMonitor
obj) = MemoryMonitor -> (Ptr MemoryMonitor -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr MemoryMonitor
obj (Ptr GValue -> Ptr MemoryMonitor -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe MemoryMonitor)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr MemoryMonitor)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr MemoryMonitor)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject MemoryMonitor ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList MemoryMonitor
type instance O.AttributeList MemoryMonitor = MemoryMonitorAttributeList
type MemoryMonitorAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveMemoryMonitorMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveMemoryMonitorMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveMemoryMonitorMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveMemoryMonitorMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveMemoryMonitorMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveMemoryMonitorMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveMemoryMonitorMethod "init" o = Gio.Initable.InitableInitMethodInfo
ResolveMemoryMonitorMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveMemoryMonitorMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveMemoryMonitorMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveMemoryMonitorMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveMemoryMonitorMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveMemoryMonitorMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveMemoryMonitorMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveMemoryMonitorMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveMemoryMonitorMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveMemoryMonitorMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveMemoryMonitorMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveMemoryMonitorMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveMemoryMonitorMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveMemoryMonitorMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveMemoryMonitorMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveMemoryMonitorMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveMemoryMonitorMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveMemoryMonitorMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveMemoryMonitorMethod t MemoryMonitor, O.OverloadedMethod info MemoryMonitor p) => OL.IsLabel t (MemoryMonitor -> 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 ~ ResolveMemoryMonitorMethod t MemoryMonitor, O.OverloadedMethod info MemoryMonitor p, R.HasField t MemoryMonitor p) => R.HasField t MemoryMonitor p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveMemoryMonitorMethod t MemoryMonitor, O.OverloadedMethodInfo info MemoryMonitor) => OL.IsLabel t (O.MethodProxy info MemoryMonitor) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
foreign import ccall "g_memory_monitor_dup_default" g_memory_monitor_dup_default ::
IO (Ptr MemoryMonitor)
memoryMonitorDupDefault ::
(B.CallStack.HasCallStack, MonadIO m) =>
m MemoryMonitor
memoryMonitorDupDefault :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m MemoryMonitor
memoryMonitorDupDefault = IO MemoryMonitor -> m MemoryMonitor
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO MemoryMonitor -> m MemoryMonitor)
-> IO MemoryMonitor -> m MemoryMonitor
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr MemoryMonitor)
g_memory_monitor_dup_default
checkUnexpectedReturnNULL "memoryMonitorDupDefault" result
result' <- (wrapObject MemoryMonitor) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
type MemoryMonitorLowMemoryWarningCallback =
Gio.Enums.MemoryMonitorWarningLevel
-> IO ()
type C_MemoryMonitorLowMemoryWarningCallback =
Ptr MemoryMonitor ->
CUInt ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mk_MemoryMonitorLowMemoryWarningCallback :: C_MemoryMonitorLowMemoryWarningCallback -> IO (FunPtr C_MemoryMonitorLowMemoryWarningCallback)
wrap_MemoryMonitorLowMemoryWarningCallback ::
GObject a => (a -> MemoryMonitorLowMemoryWarningCallback) ->
C_MemoryMonitorLowMemoryWarningCallback
wrap_MemoryMonitorLowMemoryWarningCallback :: forall a.
GObject a =>
(a -> MemoryMonitorLowMemoryWarningCallback)
-> C_MemoryMonitorLowMemoryWarningCallback
wrap_MemoryMonitorLowMemoryWarningCallback a -> MemoryMonitorLowMemoryWarningCallback
gi'cb Ptr MemoryMonitor
gi'selfPtr CUInt
level Ptr ()
_ = do
let level' :: MemoryMonitorWarningLevel
level' = (Int -> MemoryMonitorWarningLevel
forall a. Enum a => Int -> a
toEnum (Int -> MemoryMonitorWarningLevel)
-> (CUInt -> Int) -> CUInt -> MemoryMonitorWarningLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
level
Ptr MemoryMonitor -> (MemoryMonitor -> IO ()) -> IO ()
forall o b.
(HasCallStack, GObject o) =>
Ptr o -> (o -> IO b) -> IO b
B.ManagedPtr.withNewObject Ptr MemoryMonitor
gi'selfPtr ((MemoryMonitor -> IO ()) -> IO ())
-> (MemoryMonitor -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \MemoryMonitor
gi'self -> a -> MemoryMonitorLowMemoryWarningCallback
gi'cb (MemoryMonitor -> a
forall a b. Coercible a b => a -> b
Coerce.coerce MemoryMonitor
gi'self) MemoryMonitorWarningLevel
level'
onMemoryMonitorLowMemoryWarning :: (IsMemoryMonitor a, MonadIO m) => a -> ((?self :: a) => MemoryMonitorLowMemoryWarningCallback) -> m SignalHandlerId
onMemoryMonitorLowMemoryWarning :: forall a (m :: * -> *).
(IsMemoryMonitor a, MonadIO m) =>
a
-> ((?self::a) => MemoryMonitorLowMemoryWarningCallback)
-> m SignalHandlerId
onMemoryMonitorLowMemoryWarning a
obj (?self::a) => MemoryMonitorLowMemoryWarningCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
let wrapped :: a -> MemoryMonitorLowMemoryWarningCallback
wrapped a
self = let ?self = a
?self::a
self in (?self::a) => MemoryMonitorLowMemoryWarningCallback
MemoryMonitorLowMemoryWarningCallback
cb
let wrapped' :: C_MemoryMonitorLowMemoryWarningCallback
wrapped' = (a -> MemoryMonitorLowMemoryWarningCallback)
-> C_MemoryMonitorLowMemoryWarningCallback
forall a.
GObject a =>
(a -> MemoryMonitorLowMemoryWarningCallback)
-> C_MemoryMonitorLowMemoryWarningCallback
wrap_MemoryMonitorLowMemoryWarningCallback a -> MemoryMonitorLowMemoryWarningCallback
wrapped
wrapped'' <- C_MemoryMonitorLowMemoryWarningCallback
-> IO (FunPtr C_MemoryMonitorLowMemoryWarningCallback)
mk_MemoryMonitorLowMemoryWarningCallback C_MemoryMonitorLowMemoryWarningCallback
wrapped'
connectSignalFunPtr obj "low-memory-warning" wrapped'' SignalConnectBefore Nothing
afterMemoryMonitorLowMemoryWarning :: (IsMemoryMonitor a, MonadIO m) => a -> ((?self :: a) => MemoryMonitorLowMemoryWarningCallback) -> m SignalHandlerId
afterMemoryMonitorLowMemoryWarning :: forall a (m :: * -> *).
(IsMemoryMonitor a, MonadIO m) =>
a
-> ((?self::a) => MemoryMonitorLowMemoryWarningCallback)
-> m SignalHandlerId
afterMemoryMonitorLowMemoryWarning a
obj (?self::a) => MemoryMonitorLowMemoryWarningCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
let wrapped :: a -> MemoryMonitorLowMemoryWarningCallback
wrapped a
self = let ?self = a
?self::a
self in (?self::a) => MemoryMonitorLowMemoryWarningCallback
MemoryMonitorLowMemoryWarningCallback
cb
let wrapped' :: C_MemoryMonitorLowMemoryWarningCallback
wrapped' = (a -> MemoryMonitorLowMemoryWarningCallback)
-> C_MemoryMonitorLowMemoryWarningCallback
forall a.
GObject a =>
(a -> MemoryMonitorLowMemoryWarningCallback)
-> C_MemoryMonitorLowMemoryWarningCallback
wrap_MemoryMonitorLowMemoryWarningCallback a -> MemoryMonitorLowMemoryWarningCallback
wrapped
wrapped'' <- C_MemoryMonitorLowMemoryWarningCallback
-> IO (FunPtr C_MemoryMonitorLowMemoryWarningCallback)
mk_MemoryMonitorLowMemoryWarningCallback C_MemoryMonitorLowMemoryWarningCallback
wrapped'
connectSignalFunPtr obj "low-memory-warning" wrapped'' SignalConnectAfter Nothing
#if defined(ENABLE_OVERLOADING)
data MemoryMonitorLowMemoryWarningSignalInfo
instance SignalInfo MemoryMonitorLowMemoryWarningSignalInfo where
type HaskellCallbackType MemoryMonitorLowMemoryWarningSignalInfo = MemoryMonitorLowMemoryWarningCallback
connectSignal obj cb connectMode detail = do
let cb' = wrap_MemoryMonitorLowMemoryWarningCallback cb
cb'' <- mk_MemoryMonitorLowMemoryWarningCallback cb'
connectSignalFunPtr obj "low-memory-warning" cb'' connectMode detail
dbgSignalInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.MemoryMonitor::low-memory-warning"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-MemoryMonitor.html#g:signal:lowMemoryWarning"})
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList MemoryMonitor = MemoryMonitorSignalList
type MemoryMonitorSignalList = ('[ '("lowMemoryWarning", MemoryMonitorLowMemoryWarningSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif