{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) 'GI.Gio.Interfaces.Action.Action' represents a single named action. The main interface to an action is that it can be activated with 'GI.Gio.Interfaces.Action.actionActivate'. This results in the \'activate\' signal being emitted. An activation has a 'GVariant' parameter (which may be 'Nothing'). The correct type for the parameter is determined by a static parameter type (which is given at construction time). An action may optionally have a state, in which case the state may be set with 'GI.Gio.Interfaces.Action.actionChangeState'. This call takes a 'GVariant'. The correct type for the state is determined by a static state type (which is given at construction time). The state may have a hint associated with it, specifying its valid range. 'GI.Gio.Interfaces.Action.Action' is merely the interface to the concept of an action, as described above. Various implementations of actions exist, including 'GI.Gio.Objects.SimpleAction.SimpleAction'. In all cases, the implementing class is responsible for storing the name of the action, the parameter type, the enabled state, the optional state type and the state and emitting the appropriate signals when these change. The implementor is responsible for filtering calls to 'GI.Gio.Interfaces.Action.actionActivate' and 'GI.Gio.Interfaces.Action.actionChangeState' for type safety and for the state being enabled. Probably the only useful thing to do with a 'GI.Gio.Interfaces.Action.Action' is to put it inside of a 'GI.Gio.Objects.SimpleActionGroup.SimpleActionGroup'. -} module GI.Gio.Interfaces.Action ( -- * Exported types Action(..) , noAction , IsAction , toAction , -- * Methods -- ** activate #method:activate# ActionActivateMethodInfo , actionActivate , -- ** changeState #method:changeState# ActionChangeStateMethodInfo , actionChangeState , -- ** getEnabled #method:getEnabled# ActionGetEnabledMethodInfo , actionGetEnabled , -- ** getName #method:getName# ActionGetNameMethodInfo , actionGetName , -- ** getParameterType #method:getParameterType# ActionGetParameterTypeMethodInfo , actionGetParameterType , -- ** getState #method:getState# ActionGetStateMethodInfo , actionGetState , -- ** getStateHint #method:getStateHint# ActionGetStateHintMethodInfo , actionGetStateHint , -- ** getStateType #method:getStateType# ActionGetStateTypeMethodInfo , actionGetStateType , -- ** nameIsValid #method:nameIsValid# actionNameIsValid , -- ** parseDetailedName #method:parseDetailedName# actionParseDetailedName , -- ** printDetailedName #method:printDetailedName# actionPrintDetailedName , -- * Properties -- ** enabled #attr:enabled# ActionEnabledPropertyInfo , actionEnabled , getActionEnabled , -- ** name #attr:name# ActionNamePropertyInfo , actionName , getActionName , -- ** parameterType #attr:parameterType# ActionParameterTypePropertyInfo , actionParameterType , getActionParameterType , -- ** state #attr:state# ActionStatePropertyInfo , actionState , getActionState , -- ** stateType #attr:stateType# ActionStateTypePropertyInfo , actionStateType , getActionStateType , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GI.GLib.Structs.VariantType as GLib.VariantType import qualified GI.GObject.Objects.Object as GObject.Object -- interface Action newtype Action = Action (ManagedPtr Action) noAction :: Maybe Action noAction = Nothing type instance O.SignalList Action = ActionSignalList type ActionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)]) foreign import ccall "g_action_get_type" c_g_action_get_type :: IO GType instance GObject Action where gobjectType _ = c_g_action_get_type class GObject o => IsAction o #if MIN_VERSION_base(4,9,0) instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Action a) => IsAction a #endif instance IsAction Action instance GObject.Object.IsObject Action toAction :: IsAction o => o -> IO Action toAction = unsafeCastTo Action -- VVV Prop "enabled" -- Type: TBasicType TBoolean -- Flags: [PropertyReadable] -- Nullable: (Just False,Nothing) getActionEnabled :: (MonadIO m, IsAction o) => o -> m Bool getActionEnabled obj = liftIO $ getObjectPropertyBool obj "enabled" data ActionEnabledPropertyInfo instance AttrInfo ActionEnabledPropertyInfo where type AttrAllowedOps ActionEnabledPropertyInfo = '[ 'AttrGet] type AttrSetTypeConstraint ActionEnabledPropertyInfo = (~) () type AttrBaseTypeConstraint ActionEnabledPropertyInfo = IsAction type AttrGetType ActionEnabledPropertyInfo = Bool type AttrLabel ActionEnabledPropertyInfo = "enabled" type AttrOrigin ActionEnabledPropertyInfo = Action attrGet _ = getActionEnabled attrSet _ = undefined attrConstruct _ = undefined attrClear _ = undefined -- VVV Prop "name" -- Type: TBasicType TUTF8 -- Flags: [PropertyReadable] -- Nullable: (Just False,Nothing) getActionName :: (MonadIO m, IsAction o) => o -> m T.Text getActionName obj = liftIO $ checkUnexpectedNothing "getActionName" $ getObjectPropertyString obj "name" data ActionNamePropertyInfo instance AttrInfo ActionNamePropertyInfo where type AttrAllowedOps ActionNamePropertyInfo = '[ 'AttrGet, 'AttrClear] type AttrSetTypeConstraint ActionNamePropertyInfo = (~) () type AttrBaseTypeConstraint ActionNamePropertyInfo = IsAction type AttrGetType ActionNamePropertyInfo = T.Text type AttrLabel ActionNamePropertyInfo = "name" type AttrOrigin ActionNamePropertyInfo = Action attrGet _ = getActionName attrSet _ = undefined attrConstruct _ = undefined attrClear _ = undefined -- VVV Prop "parameter-type" -- Type: TInterface (Name {namespace = "GLib", name = "VariantType"}) -- Flags: [PropertyReadable] -- Nullable: (Just True,Nothing) getActionParameterType :: (MonadIO m, IsAction o) => o -> m (Maybe GLib.VariantType.VariantType) getActionParameterType obj = liftIO $ getObjectPropertyBoxed obj "parameter-type" GLib.VariantType.VariantType data ActionParameterTypePropertyInfo instance AttrInfo ActionParameterTypePropertyInfo where type AttrAllowedOps ActionParameterTypePropertyInfo = '[ 'AttrGet, 'AttrClear] type AttrSetTypeConstraint ActionParameterTypePropertyInfo = (~) () type AttrBaseTypeConstraint ActionParameterTypePropertyInfo = IsAction type AttrGetType ActionParameterTypePropertyInfo = (Maybe GLib.VariantType.VariantType) type AttrLabel ActionParameterTypePropertyInfo = "parameter-type" type AttrOrigin ActionParameterTypePropertyInfo = Action attrGet _ = getActionParameterType attrSet _ = undefined attrConstruct _ = undefined attrClear _ = undefined -- VVV Prop "state" -- Type: TVariant -- Flags: [PropertyReadable] -- Nullable: (Nothing,Nothing) getActionState :: (MonadIO m, IsAction o) => o -> m (Maybe GVariant) getActionState obj = liftIO $ getObjectPropertyVariant obj "state" data ActionStatePropertyInfo instance AttrInfo ActionStatePropertyInfo where type AttrAllowedOps ActionStatePropertyInfo = '[ 'AttrGet, 'AttrClear] type AttrSetTypeConstraint ActionStatePropertyInfo = (~) () type AttrBaseTypeConstraint ActionStatePropertyInfo = IsAction type AttrGetType ActionStatePropertyInfo = (Maybe GVariant) type AttrLabel ActionStatePropertyInfo = "state" type AttrOrigin ActionStatePropertyInfo = Action attrGet _ = getActionState attrSet _ = undefined attrConstruct _ = undefined attrClear _ = undefined -- VVV Prop "state-type" -- Type: TInterface (Name {namespace = "GLib", name = "VariantType"}) -- Flags: [PropertyReadable] -- Nullable: (Just True,Nothing) getActionStateType :: (MonadIO m, IsAction o) => o -> m (Maybe GLib.VariantType.VariantType) getActionStateType obj = liftIO $ getObjectPropertyBoxed obj "state-type" GLib.VariantType.VariantType data ActionStateTypePropertyInfo instance AttrInfo ActionStateTypePropertyInfo where type AttrAllowedOps ActionStateTypePropertyInfo = '[ 'AttrGet, 'AttrClear] type AttrSetTypeConstraint ActionStateTypePropertyInfo = (~) () type AttrBaseTypeConstraint ActionStateTypePropertyInfo = IsAction type AttrGetType ActionStateTypePropertyInfo = (Maybe GLib.VariantType.VariantType) type AttrLabel ActionStateTypePropertyInfo = "state-type" type AttrOrigin ActionStateTypePropertyInfo = Action attrGet _ = getActionStateType attrSet _ = undefined attrConstruct _ = undefined attrClear _ = undefined instance O.HasAttributeList Action type instance O.AttributeList Action = ActionAttributeList type ActionAttributeList = ('[ '("enabled", ActionEnabledPropertyInfo), '("name", ActionNamePropertyInfo), '("parameterType", ActionParameterTypePropertyInfo), '("state", ActionStatePropertyInfo), '("stateType", ActionStateTypePropertyInfo)] :: [(Symbol, *)]) actionEnabled :: AttrLabelProxy "enabled" actionEnabled = AttrLabelProxy actionName :: AttrLabelProxy "name" actionName = AttrLabelProxy actionParameterType :: AttrLabelProxy "parameterType" actionParameterType = AttrLabelProxy actionState :: AttrLabelProxy "state" actionState = AttrLabelProxy actionStateType :: AttrLabelProxy "stateType" actionStateType = AttrLabelProxy type family ResolveActionMethod (t :: Symbol) (o :: *) :: * where ResolveActionMethod "activate" o = ActionActivateMethodInfo ResolveActionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo ResolveActionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo ResolveActionMethod "changeState" o = ActionChangeStateMethodInfo ResolveActionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo ResolveActionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo ResolveActionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo ResolveActionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo ResolveActionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo ResolveActionMethod "ref" o = GObject.Object.ObjectRefMethodInfo ResolveActionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo ResolveActionMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo ResolveActionMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo ResolveActionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo ResolveActionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo ResolveActionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo ResolveActionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo ResolveActionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo ResolveActionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo ResolveActionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo ResolveActionMethod "getEnabled" o = ActionGetEnabledMethodInfo ResolveActionMethod "getName" o = ActionGetNameMethodInfo ResolveActionMethod "getParameterType" o = ActionGetParameterTypeMethodInfo ResolveActionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo ResolveActionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo ResolveActionMethod "getState" o = ActionGetStateMethodInfo ResolveActionMethod "getStateHint" o = ActionGetStateHintMethodInfo ResolveActionMethod "getStateType" o = ActionGetStateTypeMethodInfo ResolveActionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo ResolveActionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo ResolveActionMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveActionMethod t Action, O.MethodInfo info Action p) => O.IsLabelProxy t (Action -> p) where fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveActionMethod t Action, O.MethodInfo info Action p) => O.IsLabel t (Action -> p) where fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif -- method Action::activate -- method type : OrdinaryMethod -- Args : [Arg {argCName = "action", argType = TInterface (Name {namespace = "Gio", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parameter", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the parameter to the activation", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_action_activate" g_action_activate :: Ptr Action -> -- action : TInterface (Name {namespace = "Gio", name = "Action"}) Ptr GVariant -> -- parameter : TVariant IO () {- | Activates the action. /@parameter@/ must be the correct type of parameter for the action (ie: the parameter type given at construction time). If the parameter type was 'Nothing' then /@parameter@/ must also be 'Nothing'. If the /@parameter@/ GVariant is floating, it is consumed. @since 2.28 -} actionActivate :: (B.CallStack.HasCallStack, MonadIO m, IsAction a) => a {- ^ /@action@/: a 'GI.Gio.Interfaces.Action.Action' -} -> Maybe (GVariant) {- ^ /@parameter@/: the parameter to the activation -} -> m () actionActivate action parameter = liftIO $ do action' <- unsafeManagedPtrCastPtr action maybeParameter <- case parameter of Nothing -> return nullPtr Just jParameter -> do jParameter' <- unsafeManagedPtrGetPtr jParameter return jParameter' g_action_activate action' maybeParameter touchManagedPtr action whenJust parameter touchManagedPtr return () data ActionActivateMethodInfo instance (signature ~ (Maybe (GVariant) -> m ()), MonadIO m, IsAction a) => O.MethodInfo ActionActivateMethodInfo a signature where overloadedMethod _ = actionActivate -- method Action::change_state -- method type : OrdinaryMethod -- Args : [Arg {argCName = "action", argType = TInterface (Name {namespace = "Gio", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new state", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "g_action_change_state" g_action_change_state :: Ptr Action -> -- action : TInterface (Name {namespace = "Gio", name = "Action"}) Ptr GVariant -> -- value : TVariant IO () {- | Request for the state of /@action@/ to be changed to /@value@/. The action must be stateful and /@value@/ must be of the correct type. See 'GI.Gio.Interfaces.Action.actionGetStateType'. This call merely requests a change. The action may refuse to change its state or may change its state to something other than /@value@/. See 'GI.Gio.Interfaces.Action.actionGetStateHint'. If the /@value@/ GVariant is floating, it is consumed. @since 2.30 -} actionChangeState :: (B.CallStack.HasCallStack, MonadIO m, IsAction a) => a {- ^ /@action@/: a 'GI.Gio.Interfaces.Action.Action' -} -> GVariant {- ^ /@value@/: the new state -} -> m () actionChangeState action value = liftIO $ do action' <- unsafeManagedPtrCastPtr action value' <- unsafeManagedPtrGetPtr value g_action_change_state action' value' touchManagedPtr action touchManagedPtr value return () data ActionChangeStateMethodInfo instance (signature ~ (GVariant -> m ()), MonadIO m, IsAction a) => O.MethodInfo ActionChangeStateMethodInfo a signature where overloadedMethod _ = actionChangeState -- method Action::get_enabled -- method type : OrdinaryMethod -- Args : [Arg {argCName = "action", argType = TInterface (Name {namespace = "Gio", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAction", 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_action_get_enabled" g_action_get_enabled :: Ptr Action -> -- action : TInterface (Name {namespace = "Gio", name = "Action"}) IO CInt {- | Checks if /@action@/ is currently enabled. An action must be enabled in order to be activated or in order to have its state changed from outside callers. @since 2.28 -} actionGetEnabled :: (B.CallStack.HasCallStack, MonadIO m, IsAction a) => a {- ^ /@action@/: a 'GI.Gio.Interfaces.Action.Action' -} -> m Bool {- ^ __Returns:__ whether the action is enabled -} actionGetEnabled action = liftIO $ do action' <- unsafeManagedPtrCastPtr action result <- g_action_get_enabled action' let result' = (/= 0) result touchManagedPtr action return result' data ActionGetEnabledMethodInfo instance (signature ~ (m Bool), MonadIO m, IsAction a) => O.MethodInfo ActionGetEnabledMethodInfo a signature where overloadedMethod _ = actionGetEnabled -- method Action::get_name -- method type : OrdinaryMethod -- Args : [Arg {argCName = "action", argType = TInterface (Name {namespace = "Gio", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAction", 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_action_get_name" g_action_get_name :: Ptr Action -> -- action : TInterface (Name {namespace = "Gio", name = "Action"}) IO CString {- | Queries the name of /@action@/. @since 2.28 -} actionGetName :: (B.CallStack.HasCallStack, MonadIO m, IsAction a) => a {- ^ /@action@/: a 'GI.Gio.Interfaces.Action.Action' -} -> m T.Text {- ^ __Returns:__ the name of the action -} actionGetName action = liftIO $ do action' <- unsafeManagedPtrCastPtr action result <- g_action_get_name action' checkUnexpectedReturnNULL "actionGetName" result result' <- cstringToText result touchManagedPtr action return result' data ActionGetNameMethodInfo instance (signature ~ (m T.Text), MonadIO m, IsAction a) => O.MethodInfo ActionGetNameMethodInfo a signature where overloadedMethod _ = actionGetName -- method Action::get_parameter_type -- method type : OrdinaryMethod -- Args : [Arg {argCName = "action", argType = TInterface (Name {namespace = "Gio", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "VariantType"})) -- throws : False -- Skip return : False foreign import ccall "g_action_get_parameter_type" g_action_get_parameter_type :: Ptr Action -> -- action : TInterface (Name {namespace = "Gio", name = "Action"}) IO (Ptr GLib.VariantType.VariantType) {- | Queries the type of the parameter that must be given when activating /@action@/. When activating the action using 'GI.Gio.Interfaces.Action.actionActivate', the 'GVariant' given to that function must be of the type returned by this function. In the case that this function returns 'Nothing', you must not give any 'GVariant', but 'Nothing' instead. @since 2.28 -} actionGetParameterType :: (B.CallStack.HasCallStack, MonadIO m, IsAction a) => a {- ^ /@action@/: a 'GI.Gio.Interfaces.Action.Action' -} -> m (Maybe GLib.VariantType.VariantType) {- ^ __Returns:__ the parameter type -} actionGetParameterType action = liftIO $ do action' <- unsafeManagedPtrCastPtr action result <- g_action_get_parameter_type action' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (newBoxed GLib.VariantType.VariantType) result' return result'' touchManagedPtr action return maybeResult data ActionGetParameterTypeMethodInfo instance (signature ~ (m (Maybe GLib.VariantType.VariantType)), MonadIO m, IsAction a) => O.MethodInfo ActionGetParameterTypeMethodInfo a signature where overloadedMethod _ = actionGetParameterType -- method Action::get_state -- method type : OrdinaryMethod -- Args : [Arg {argCName = "action", argType = TInterface (Name {namespace = "Gio", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just TVariant -- throws : False -- Skip return : False foreign import ccall "g_action_get_state" g_action_get_state :: Ptr Action -> -- action : TInterface (Name {namespace = "Gio", name = "Action"}) IO (Ptr GVariant) {- | Queries the current state of /@action@/. If the action is not stateful then 'Nothing' will be returned. If the action is stateful then the type of the return value is the type given by 'GI.Gio.Interfaces.Action.actionGetStateType'. The return value (if non-'Nothing') should be freed with 'GI.GLib.Structs.Variant.variantUnref' when it is no longer required. @since 2.28 -} actionGetState :: (B.CallStack.HasCallStack, MonadIO m, IsAction a) => a {- ^ /@action@/: a 'GI.Gio.Interfaces.Action.Action' -} -> m GVariant {- ^ __Returns:__ the current state of the action -} actionGetState action = liftIO $ do action' <- unsafeManagedPtrCastPtr action result <- g_action_get_state action' checkUnexpectedReturnNULL "actionGetState" result result' <- wrapGVariantPtr result touchManagedPtr action return result' data ActionGetStateMethodInfo instance (signature ~ (m GVariant), MonadIO m, IsAction a) => O.MethodInfo ActionGetStateMethodInfo a signature where overloadedMethod _ = actionGetState -- method Action::get_state_hint -- method type : OrdinaryMethod -- Args : [Arg {argCName = "action", argType = TInterface (Name {namespace = "Gio", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just TVariant -- throws : False -- Skip return : False foreign import ccall "g_action_get_state_hint" g_action_get_state_hint :: Ptr Action -> -- action : TInterface (Name {namespace = "Gio", name = "Action"}) IO (Ptr GVariant) {- | Requests a hint about the valid range of values for the state of /@action@/. If 'Nothing' is returned it either means that the action is not stateful or that there is no hint about the valid range of values for the state of the action. If a 'GVariant' array is returned then each item in the array is a possible value for the state. If a 'GVariant' pair (ie: two-tuple) is returned then the tuple specifies the inclusive lower and upper bound of valid values for the state. In any case, the information is merely a hint. It may be possible to have a state value outside of the hinted range and setting a value within the range may fail. The return value (if non-'Nothing') should be freed with 'GI.GLib.Structs.Variant.variantUnref' when it is no longer required. @since 2.28 -} actionGetStateHint :: (B.CallStack.HasCallStack, MonadIO m, IsAction a) => a {- ^ /@action@/: a 'GI.Gio.Interfaces.Action.Action' -} -> m (Maybe GVariant) {- ^ __Returns:__ the state range hint -} actionGetStateHint action = liftIO $ do action' <- unsafeManagedPtrCastPtr action result <- g_action_get_state_hint action' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- wrapGVariantPtr result' return result'' touchManagedPtr action return maybeResult data ActionGetStateHintMethodInfo instance (signature ~ (m (Maybe GVariant)), MonadIO m, IsAction a) => O.MethodInfo ActionGetStateHintMethodInfo a signature where overloadedMethod _ = actionGetStateHint -- method Action::get_state_type -- method type : OrdinaryMethod -- Args : [Arg {argCName = "action", argType = TInterface (Name {namespace = "Gio", name = "Action"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAction", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GLib", name = "VariantType"})) -- throws : False -- Skip return : False foreign import ccall "g_action_get_state_type" g_action_get_state_type :: Ptr Action -> -- action : TInterface (Name {namespace = "Gio", name = "Action"}) IO (Ptr GLib.VariantType.VariantType) {- | Queries the type of the state of /@action@/. If the action is stateful (e.g. created with 'GI.Gio.Objects.SimpleAction.simpleActionNewStateful') then this function returns the 'GI.GLib.Structs.VariantType.VariantType' of the state. This is the type of the initial value given as the state. All calls to 'GI.Gio.Interfaces.Action.actionChangeState' must give a 'GVariant' of this type and 'GI.Gio.Interfaces.Action.actionGetState' will return a 'GVariant' of the same type. If the action is not stateful (e.g. created with 'GI.Gio.Objects.SimpleAction.simpleActionNew') then this function will return 'Nothing'. In that case, 'GI.Gio.Interfaces.Action.actionGetState' will return 'Nothing' and you must not call 'GI.Gio.Interfaces.Action.actionChangeState'. @since 2.28 -} actionGetStateType :: (B.CallStack.HasCallStack, MonadIO m, IsAction a) => a {- ^ /@action@/: a 'GI.Gio.Interfaces.Action.Action' -} -> m (Maybe GLib.VariantType.VariantType) {- ^ __Returns:__ the state type, if the action is stateful -} actionGetStateType action = liftIO $ do action' <- unsafeManagedPtrCastPtr action result <- g_action_get_state_type action' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (newBoxed GLib.VariantType.VariantType) result' return result'' touchManagedPtr action return maybeResult data ActionGetStateTypeMethodInfo instance (signature ~ (m (Maybe GLib.VariantType.VariantType)), MonadIO m, IsAction a) => O.MethodInfo ActionGetStateTypeMethodInfo a signature where overloadedMethod _ = actionGetStateType -- method Action::name_is_valid -- method type : MemberFunction -- Args : [Arg {argCName = "action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an potential action name", 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_action_name_is_valid" g_action_name_is_valid :: CString -> -- action_name : TBasicType TUTF8 IO CInt {- | Checks if /@actionName@/ is valid. /@actionName@/ is valid if it consists only of alphanumeric characters, plus \'-\' and \'.\'. The empty string is not a valid action name. It is an error to call this function with a non-utf8 /@actionName@/. /@actionName@/ must not be 'Nothing'. @since 2.38 -} actionNameIsValid :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@actionName@/: an potential action name -} -> m Bool {- ^ __Returns:__ 'True' if /@actionName@/ is valid -} actionNameIsValid actionName = liftIO $ do actionName' <- textToCString actionName result <- g_action_name_is_valid actionName' let result' = (/= 0) result freeMem actionName' return result' -- method Action::parse_detailed_name -- method type : MemberFunction -- Args : [Arg {argCName = "detailed_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a detailed action name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "action_name", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the action name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "target_value", argType = TVariant, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the target value, or %NULL for no target", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : True -- Skip return : False foreign import ccall "g_action_parse_detailed_name" g_action_parse_detailed_name :: CString -> -- detailed_name : TBasicType TUTF8 Ptr CString -> -- action_name : TBasicType TUTF8 Ptr (Ptr GVariant) -> -- target_value : TVariant Ptr (Ptr GError) -> -- error IO CInt {- | Parses a detailed action name into its separate name and target components. Detailed action names can have three formats. The first format is used to represent an action name with no target value and consists of just an action name containing no whitespace nor the characters \':\', \'(\' or \')\'. For example: \"app.action\". The second format is used to represent an action with a target value that is a non-empty string consisting only of alphanumerics, plus \'-\' and \'.\'. In that case, the action name and target value are separated by a double colon (\"::\"). For example: \"app.action::target\". The third format is used to represent an action with any type of target value, including strings. The target value follows the action name, surrounded in parens. For example: \"app.action(42)\". The target value is parsed using 'GI.GLib.Functions.variantParse'. If a tuple-typed value is desired, it must be specified in the same way, resulting in two sets of parens, for example: \"app.action((1,2,3))\". A string target can be specified this way as well: \"app.action(\'target\')\". For strings, this third format must be used if * target value is empty or contains characters other than alphanumerics, \'-\' and \'.\'. @since 2.38 -} actionParseDetailedName :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@detailedName@/: a detailed action name -} -> m (T.Text,GVariant) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} actionParseDetailedName detailedName = liftIO $ do detailedName' <- textToCString detailedName actionName <- allocMem :: IO (Ptr CString) targetValue <- allocMem :: IO (Ptr (Ptr GVariant)) onException (do _ <- propagateGError $ g_action_parse_detailed_name detailedName' actionName targetValue actionName' <- peek actionName actionName'' <- cstringToText actionName' freeMem actionName' targetValue' <- peek targetValue targetValue'' <- wrapGVariantPtr targetValue' freeMem detailedName' freeMem actionName freeMem targetValue return (actionName'', targetValue'') ) (do freeMem detailedName' freeMem actionName freeMem targetValue ) -- method Action::print_detailed_name -- method type : MemberFunction -- Args : [Arg {argCName = "action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a valid action name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target_value", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GVariant target value, or %NULL", 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_action_print_detailed_name" g_action_print_detailed_name :: CString -> -- action_name : TBasicType TUTF8 Ptr GVariant -> -- target_value : TVariant IO CString {- | Formats a detailed action name from /@actionName@/ and /@targetValue@/. It is an error to call this function with an invalid action name. This function is the opposite of 'GI.Gio.Functions.actionParseDetailedName'. It will produce a string that can be parsed back to the /@actionName@/ and /@targetValue@/ by that function. See that function for the types of strings that will be printed by this function. @since 2.38 -} actionPrintDetailedName :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@actionName@/: a valid action name -} -> Maybe (GVariant) {- ^ /@targetValue@/: a 'GVariant' target value, or 'Nothing' -} -> m T.Text {- ^ __Returns:__ a detailed format string -} actionPrintDetailedName actionName targetValue = liftIO $ do actionName' <- textToCString actionName maybeTargetValue <- case targetValue of Nothing -> return nullPtr Just jTargetValue -> do jTargetValue' <- unsafeManagedPtrGetPtr jTargetValue return jTargetValue' result <- g_action_print_detailed_name actionName' maybeTargetValue checkUnexpectedReturnNULL "actionPrintDetailedName" result result' <- cstringToText result freeMem result whenJust targetValue touchManagedPtr freeMem actionName' return result'