gi-wireplumber-0.5.14: GI/Wp/Objects/State.hs
{-# LANGUAGE TypeApplications #-}
-- | Copyright : Will Thompson and Iñaki García Etxebarria
-- License : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
--
-- The WpState class saves and loads properties from a file
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Wp.Objects.State
(
-- * Exported types
State(..) ,
IsState ,
toState ,
-- * Methods
-- |
--
-- === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [clear]("GI.Wp.Objects.State#g:method:clear"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [load]("GI.Wp.Objects.State#g:method:load"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [save]("GI.Wp.Objects.State#g:method:save"), [saveAfterTimeout]("GI.Wp.Objects.State#g:method:saveAfterTimeout"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
--
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getLocation]("GI.Wp.Objects.State#g:method:getLocation"), [getName]("GI.Wp.Objects.State#g:method:getName"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata").
--
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").
#if defined(ENABLE_OVERLOADING)
ResolveStateMethod ,
#endif
-- ** clear #method:clear#
#if defined(ENABLE_OVERLOADING)
StateClearMethodInfo ,
#endif
stateClear ,
-- ** getLocation #method:getLocation#
#if defined(ENABLE_OVERLOADING)
StateGetLocationMethodInfo ,
#endif
stateGetLocation ,
-- ** getName #method:getName#
#if defined(ENABLE_OVERLOADING)
StateGetNameMethodInfo ,
#endif
stateGetName ,
-- ** load #method:load#
#if defined(ENABLE_OVERLOADING)
StateLoadMethodInfo ,
#endif
stateLoad ,
-- ** new #method:new#
stateNew ,
-- ** save #method:save#
#if defined(ENABLE_OVERLOADING)
StateSaveMethodInfo ,
#endif
stateSave ,
-- ** saveAfterTimeout #method:saveAfterTimeout#
#if defined(ENABLE_OVERLOADING)
StateSaveAfterTimeoutMethodInfo ,
#endif
stateSaveAfterTimeout ,
-- * Properties
-- ** name #attr:name#
-- | /No description available in the introspection data./
#if defined(ENABLE_OVERLOADING)
StateNamePropertyInfo ,
#endif
constructStateName ,
getStateName ,
#if defined(ENABLE_OVERLOADING)
stateName ,
#endif
-- ** timeout #attr:timeout#
-- | /No description available in the introspection data./
#if defined(ENABLE_OVERLOADING)
StateTimeoutPropertyInfo ,
#endif
constructStateTimeout ,
getStateTimeout ,
setStateTimeout ,
#if defined(ENABLE_OVERLOADING)
stateTimeout ,
#endif
) 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
-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Wp.Callbacks as Wp.Callbacks
import {-# SOURCE #-} qualified GI.Wp.Enums as Wp.Enums
import {-# SOURCE #-} qualified GI.Wp.Flags as Wp.Flags
import {-# SOURCE #-} qualified GI.Wp.Objects.Conf as Wp.Conf
import {-# SOURCE #-} qualified GI.Wp.Objects.Core as Wp.Core
import {-# SOURCE #-} qualified GI.Wp.Objects.Object as Wp.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.ObjectManager as Wp.ObjectManager
import {-# SOURCE #-} qualified GI.Wp.Structs.Iterator as Wp.Iterator
import {-# SOURCE #-} qualified GI.Wp.Structs.IteratorMethods as Wp.IteratorMethods
import {-# SOURCE #-} qualified GI.Wp.Structs.ObjectInterest as Wp.ObjectInterest
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaJson as Wp.SpaJson
#else
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.Core as Wp.Core
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
#endif
-- | Memory-managed wrapper type.
newtype State = State (SP.ManagedPtr State)
deriving (Eq)
instance SP.ManagedPtrNewtype State where
toManagedPtr (State p) = p
foreign import ccall "wp_state_get_type"
c_wp_state_get_type :: IO B.Types.GType
instance B.Types.TypedObject State where
glibType = c_wp_state_get_type
instance B.Types.GObject State
-- | Type class for types which can be safely cast to t'State', for instance with `toState`.
class (SP.GObject o, O.IsDescendantOf State o) => IsState o
instance (SP.GObject o, O.IsDescendantOf State o) => IsState o
instance O.HasParentTypes State
type instance O.ParentTypes State = '[GObject.Object.Object]
-- | Cast to t'State', for types for which this is known to be safe. For general casts, use 'Data.GI.Base.ManagedPtr.castTo'.
toState :: (MIO.MonadIO m, IsState o) => o -> m State
toState = MIO.liftIO . B.ManagedPtr.unsafeCastTo State
-- | Convert t'State' to and from t'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe State) where
gvalueGType_ = c_wp_state_get_type
gvalueSet_ gv P.Nothing = B.GValue.set_object gv (FP.nullPtr :: FP.Ptr State)
gvalueSet_ gv (P.Just obj) = B.ManagedPtr.withManagedPtr obj (B.GValue.set_object gv)
gvalueGet_ gv = do
ptr <- B.GValue.get_object gv :: IO (FP.Ptr State)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject State ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveStateMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveStateMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveStateMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveStateMethod "clear" o = StateClearMethodInfo
ResolveStateMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveStateMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveStateMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveStateMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveStateMethod "load" o = StateLoadMethodInfo
ResolveStateMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveStateMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveStateMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveStateMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveStateMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveStateMethod "save" o = StateSaveMethodInfo
ResolveStateMethod "saveAfterTimeout" o = StateSaveAfterTimeoutMethodInfo
ResolveStateMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveStateMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveStateMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveStateMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveStateMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveStateMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveStateMethod "getLocation" o = StateGetLocationMethodInfo
ResolveStateMethod "getName" o = StateGetNameMethodInfo
ResolveStateMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveStateMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveStateMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveStateMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveStateMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveStateMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveStateMethod t State, O.OverloadedMethod info State p) => OL.IsLabel t (State -> 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 ~ ResolveStateMethod t State, O.OverloadedMethod info State p, R.HasField t State p) => R.HasField t State p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveStateMethod t State, O.OverloadedMethodInfo info State) => OL.IsLabel t (O.MethodProxy info State) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
-- VVV Prop "name"
-- Type: TBasicType TUTF8
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Just False,Nothing)
-- | Get the value of the “@name@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
--
-- @
-- 'Data.GI.Base.Attributes.get' state #name
-- @
getStateName :: (MonadIO m, IsState o) => o -> m T.Text
getStateName obj = MIO.liftIO $ checkUnexpectedNothing "getStateName" $ B.Properties.getObjectPropertyString obj "name"
-- | Construct a t'GValueConstruct' with valid value for the “@name@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructStateName :: (IsState o, MIO.MonadIO m) => T.Text -> m (GValueConstruct o)
constructStateName val = MIO.liftIO $ do
MIO.liftIO $ B.Properties.constructObjectPropertyString "name" (P.Just val)
#if defined(ENABLE_OVERLOADING)
data StateNamePropertyInfo
instance AttrInfo StateNamePropertyInfo where
type AttrAllowedOps StateNamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrBaseTypeConstraint StateNamePropertyInfo = IsState
type AttrSetTypeConstraint StateNamePropertyInfo = (~) T.Text
type AttrTransferTypeConstraint StateNamePropertyInfo = (~) T.Text
type AttrTransferType StateNamePropertyInfo = T.Text
type AttrGetType StateNamePropertyInfo = T.Text
type AttrLabel StateNamePropertyInfo = "name"
type AttrOrigin StateNamePropertyInfo = State
attrGet = getStateName
attrSet = undefined
attrPut = undefined
attrTransfer _ v = do
return v
attrConstruct = constructStateName
attrClear = undefined
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Wp.Objects.State.name"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-State.html#g:attr:name"
})
#endif
-- VVV Prop "timeout"
-- Type: TBasicType TUInt
-- Flags: [PropertyReadable,PropertyWritable]
-- Nullable: (Nothing,Nothing)
-- | Get the value of the “@timeout@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
--
-- @
-- 'Data.GI.Base.Attributes.get' state #timeout
-- @
getStateTimeout :: (MonadIO m, IsState o) => o -> m Word32
getStateTimeout obj = MIO.liftIO $ B.Properties.getObjectPropertyUInt32 obj "timeout"
-- | Set the value of the “@timeout@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
--
-- @
-- 'Data.GI.Base.Attributes.set' state [ #timeout 'Data.GI.Base.Attributes.:=' value ]
-- @
setStateTimeout :: (MonadIO m, IsState o) => o -> Word32 -> m ()
setStateTimeout obj val = MIO.liftIO $ do
B.Properties.setObjectPropertyUInt32 obj "timeout" val
-- | Construct a t'GValueConstruct' with valid value for the “@timeout@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructStateTimeout :: (IsState o, MIO.MonadIO m) => Word32 -> m (GValueConstruct o)
constructStateTimeout val = MIO.liftIO $ do
MIO.liftIO $ B.Properties.constructObjectPropertyUInt32 "timeout" val
#if defined(ENABLE_OVERLOADING)
data StateTimeoutPropertyInfo
instance AttrInfo StateTimeoutPropertyInfo where
type AttrAllowedOps StateTimeoutPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrPut]
type AttrBaseTypeConstraint StateTimeoutPropertyInfo = IsState
type AttrSetTypeConstraint StateTimeoutPropertyInfo = (~) Word32
type AttrTransferTypeConstraint StateTimeoutPropertyInfo = (~) Word32
type AttrTransferType StateTimeoutPropertyInfo = Word32
type AttrGetType StateTimeoutPropertyInfo = Word32
type AttrLabel StateTimeoutPropertyInfo = "timeout"
type AttrOrigin StateTimeoutPropertyInfo = State
attrGet = getStateTimeout
attrSet = setStateTimeout
attrPut = setStateTimeout
attrTransfer _ v = do
return v
attrConstruct = constructStateTimeout
attrClear = undefined
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Wp.Objects.State.timeout"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-State.html#g:attr:timeout"
})
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList State
type instance O.AttributeList State = StateAttributeList
type StateAttributeList = ('[ '("name", StateNamePropertyInfo), '("timeout", StateTimeoutPropertyInfo)] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
stateName :: AttrLabelProxy "name"
stateName = AttrLabelProxy
stateTimeout :: AttrLabelProxy "timeout"
stateTimeout = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList State = StateSignalList
type StateSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif
-- method State::new
-- method type : Constructor
-- Args: [ Arg
-- { argCName = "name"
-- , argType = TBasicType TUTF8
-- , argCType = Just "const gchar*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText = Just "the state name" , sinceVersion = Nothing }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "State" })
-- throws : False
-- Skip return : False
foreign import ccall "wp_state_new" wp_state_new ::
CString -> -- name : TBasicType TUTF8
IO (Ptr State)
-- | Constructs a new state object.
stateNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-- ^ /@name@/: the state name
-> m State
-- ^ __Returns:__ the new WpState
stateNew name = liftIO $ do
name' <- textToCString name
result <- wp_state_new name'
checkUnexpectedReturnNULL "stateNew" result
result' <- (wrapObject State) result
freeMem name'
return result'
#if defined(ENABLE_OVERLOADING)
#endif
-- method State::clear
-- method type : OrdinaryMethod
-- Args: [ Arg
-- { argCName = "self"
-- , argType = TInterface Name { namespace = "Wp" , name = "State" }
-- , argCType = Just "WpState*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText = Just "the state" , sinceVersion = Nothing }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False
foreign import ccall "wp_state_clear" wp_state_clear ::
Ptr State -> -- self : TInterface (Name {namespace = "Wp", name = "State"})
IO ()
-- | Clears the state removing its file.
stateClear ::
(B.CallStack.HasCallStack, MonadIO m, IsState a) =>
a
-- ^ /@self@/: the state
-> m ()
stateClear self = liftIO $ do
self' <- unsafeManagedPtrCastPtr self
wp_state_clear self'
touchManagedPtr self
return ()
#if defined(ENABLE_OVERLOADING)
data StateClearMethodInfo
instance (signature ~ (m ()), MonadIO m, IsState a) => O.OverloadedMethod StateClearMethodInfo a signature where
overloadedMethod = stateClear
instance O.OverloadedMethodInfo StateClearMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Wp.Objects.State.stateClear",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-State.html#v:stateClear"
})
#endif
-- method State::get_location
-- method type : OrdinaryMethod
-- Args: [ Arg
-- { argCName = "self"
-- , argType = TInterface Name { namespace = "Wp" , name = "State" }
-- , argCType = Just "WpState*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText = Just "the state" , sinceVersion = Nothing }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "wp_state_get_location" wp_state_get_location ::
Ptr State -> -- self : TInterface (Name {namespace = "Wp", name = "State"})
IO CString
-- | Gets the location of a state object.
stateGetLocation ::
(B.CallStack.HasCallStack, MonadIO m, IsState a) =>
a
-- ^ /@self@/: the state
-> m T.Text
-- ^ __Returns:__ the location of this state
stateGetLocation self = liftIO $ do
self' <- unsafeManagedPtrCastPtr self
result <- wp_state_get_location self'
checkUnexpectedReturnNULL "stateGetLocation" result
result' <- cstringToText result
touchManagedPtr self
return result'
#if defined(ENABLE_OVERLOADING)
data StateGetLocationMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsState a) => O.OverloadedMethod StateGetLocationMethodInfo a signature where
overloadedMethod = stateGetLocation
instance O.OverloadedMethodInfo StateGetLocationMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Wp.Objects.State.stateGetLocation",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-State.html#v:stateGetLocation"
})
#endif
-- method State::get_name
-- method type : OrdinaryMethod
-- Args: [ Arg
-- { argCName = "self"
-- , argType = TInterface Name { namespace = "Wp" , name = "State" }
-- , argCType = Just "WpState*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText = Just "the state" , sinceVersion = Nothing }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "wp_state_get_name" wp_state_get_name ::
Ptr State -> -- self : TInterface (Name {namespace = "Wp", name = "State"})
IO CString
-- | Gets the name of a state object.
stateGetName ::
(B.CallStack.HasCallStack, MonadIO m, IsState a) =>
a
-- ^ /@self@/: the state
-> m T.Text
-- ^ __Returns:__ the name of this state
stateGetName self = liftIO $ do
self' <- unsafeManagedPtrCastPtr self
result <- wp_state_get_name self'
checkUnexpectedReturnNULL "stateGetName" result
result' <- cstringToText result
touchManagedPtr self
return result'
#if defined(ENABLE_OVERLOADING)
data StateGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsState a) => O.OverloadedMethod StateGetNameMethodInfo a signature where
overloadedMethod = stateGetName
instance O.OverloadedMethodInfo StateGetNameMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Wp.Objects.State.stateGetName",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-State.html#v:stateGetName"
})
#endif
-- method State::load
-- method type : OrdinaryMethod
-- Args: [ Arg
-- { argCName = "self"
-- , argType = TInterface Name { namespace = "Wp" , name = "State" }
-- , argCType = Just "WpState*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText = Just "the state" , sinceVersion = Nothing }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "Properties" })
-- throws : False
-- Skip return : False
foreign import ccall "wp_state_load" wp_state_load ::
Ptr State -> -- self : TInterface (Name {namespace = "Wp", name = "State"})
IO (Ptr Wp.Properties.Properties)
-- | Loads the state data from the file system.
--
--
-- This function will never fail. If it cannot load the state, for any reason, it will simply return an empty WpProperties, behaving as if there was no previous state stored.
stateLoad ::
(B.CallStack.HasCallStack, MonadIO m, IsState a) =>
a
-- ^ /@self@/: the state
-> m Wp.Properties.Properties
-- ^ __Returns:__ a new WpProperties containing the state data
stateLoad self = liftIO $ do
self' <- unsafeManagedPtrCastPtr self
result <- wp_state_load self'
checkUnexpectedReturnNULL "stateLoad" result
result' <- (wrapBoxed Wp.Properties.Properties) result
touchManagedPtr self
return result'
#if defined(ENABLE_OVERLOADING)
data StateLoadMethodInfo
instance (signature ~ (m Wp.Properties.Properties), MonadIO m, IsState a) => O.OverloadedMethod StateLoadMethodInfo a signature where
overloadedMethod = stateLoad
instance O.OverloadedMethodInfo StateLoadMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Wp.Objects.State.stateLoad",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-State.html#v:stateLoad"
})
#endif
-- method State::save
-- method type : OrdinaryMethod
-- Args: [ Arg
-- { argCName = "self"
-- , argType = TInterface Name { namespace = "Wp" , name = "State" }
-- , argCType = Just "WpState*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText = Just "the state" , sinceVersion = Nothing }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- , Arg
-- { argCName = "props"
-- , argType =
-- TInterface Name { namespace = "Wp" , name = "Properties" }
-- , argCType = Just "WpProperties*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText = Just "the properties to save"
-- , sinceVersion = Nothing
-- }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False
foreign import ccall "wp_state_save" wp_state_save ::
Ptr State -> -- self : TInterface (Name {namespace = "Wp", name = "State"})
Ptr Wp.Properties.Properties -> -- props : TInterface (Name {namespace = "Wp", name = "Properties"})
Ptr (Ptr GError) -> -- error
IO CInt
-- | Saves new properties in the state, overwriting all previous data.
stateSave ::
(B.CallStack.HasCallStack, MonadIO m, IsState a) =>
a
-- ^ /@self@/: the state
-> Wp.Properties.Properties
-- ^ /@props@/: the properties to save
-> m ()
-- ^ /(Can throw 'Data.GI.Base.GError.GError')/
stateSave self props = liftIO $ do
self' <- unsafeManagedPtrCastPtr self
props' <- unsafeManagedPtrGetPtr props
onException (do
_ <- propagateGError $ wp_state_save self' props'
touchManagedPtr self
touchManagedPtr props
return ()
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data StateSaveMethodInfo
instance (signature ~ (Wp.Properties.Properties -> m ()), MonadIO m, IsState a) => O.OverloadedMethod StateSaveMethodInfo a signature where
overloadedMethod = stateSave
instance O.OverloadedMethodInfo StateSaveMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Wp.Objects.State.stateSave",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-State.html#v:stateSave"
})
#endif
-- method State::save_after_timeout
-- method type : OrdinaryMethod
-- Args: [ Arg
-- { argCName = "self"
-- , argType = TInterface Name { namespace = "Wp" , name = "State" }
-- , argCType = Just "WpState*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText = Just "the state" , sinceVersion = Nothing }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- , Arg
-- { argCName = "core"
-- , argType = TInterface Name { namespace = "Wp" , name = "Core" }
-- , argCType = Just "WpCore*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText =
-- Just "the core, used to add the timeout callback to the main loop"
-- , sinceVersion = Nothing
-- }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- , Arg
-- { argCName = "props"
-- , argType =
-- TInterface Name { namespace = "Wp" , name = "Properties" }
-- , argCType = Just "WpProperties*"
-- , direction = DirectionIn
-- , mayBeNull = False
-- , argDoc =
-- Documentation
-- { rawDocText =
-- Just
-- "the properties to save. This object will be referenced and kept alive until the timeout elapses, but not deep copied."
-- , sinceVersion = Nothing
-- }
-- , argScope = ScopeTypeInvalid
-- , argClosure = -1
-- , argDestroy = -1
-- , argCallerAllocates = False
-- , argCallbackUserData = False
-- , transfer = TransferNothing
-- }
-- ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False
foreign import ccall "wp_state_save_after_timeout" wp_state_save_after_timeout ::
Ptr State -> -- self : TInterface (Name {namespace = "Wp", name = "State"})
Ptr Wp.Core.Core -> -- core : TInterface (Name {namespace = "Wp", name = "Core"})
Ptr Wp.Properties.Properties -> -- props : TInterface (Name {namespace = "Wp", name = "Properties"})
IO ()
-- | Saves new properties in the state, overwriting all previous data, after a timeout.
--
--
-- This is similar to 'GI.Wp.Objects.State.stateSave' but it will save the state after a timeout has elapsed. If the state is saved again before the timeout elapses, the timeout is reset.
-- This function is useful to avoid saving the state too often. When called consecutively, it will save the state only once. Every time it is called, it will cancel the previous timer and start a new one, resulting in timing out only after the last call.
--
-- /Since: 0.5.0/
stateSaveAfterTimeout ::
(B.CallStack.HasCallStack, MonadIO m, IsState a, Wp.Core.IsCore b) =>
a
-- ^ /@self@/: the state
-> b
-- ^ /@core@/: the core, used to add the timeout callback to the main loop
-> Wp.Properties.Properties
-- ^ /@props@/: the properties to save. This object will be referenced and kept alive until the timeout elapses, but not deep copied.
-> m ()
stateSaveAfterTimeout self core props = liftIO $ do
self' <- unsafeManagedPtrCastPtr self
core' <- unsafeManagedPtrCastPtr core
props' <- unsafeManagedPtrGetPtr props
wp_state_save_after_timeout self' core' props'
touchManagedPtr self
touchManagedPtr core
touchManagedPtr props
return ()
#if defined(ENABLE_OVERLOADING)
data StateSaveAfterTimeoutMethodInfo
instance (signature ~ (b -> Wp.Properties.Properties -> m ()), MonadIO m, IsState a, Wp.Core.IsCore b) => O.OverloadedMethod StateSaveAfterTimeoutMethodInfo a signature where
overloadedMethod = stateSaveAfterTimeout
instance O.OverloadedMethodInfo StateSaveAfterTimeoutMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Wp.Objects.State.stateSaveAfterTimeout",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-State.html#v:stateSaveAfterTimeout"
})
#endif