Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
A PropertyAction
is a way to get a Action
with a state value
reflecting and controlling the value of a Object
property.
The state of the action will correspond to the value of the property.
Changing it will change the property (assuming the requested value
matches the requirements as specified in the ParamSpec
).
Only the most common types are presently supported. Booleans are mapped to booleans, strings to strings, signed/unsigned integers to int32/uint32 and floats and doubles to doubles.
If the property is an enum then the state will be string-typed and
conversion will automatically be performed between the enum value and
"nick" string as per the EnumValue
table.
Flags types are not currently supported.
Properties of object types, boxed types and pointer types are not supported and probably never will be.
Properties of GVariant
types are not currently supported.
If the property is boolean-valued then the action will have a NULL parameter type, and activating the action (with no parameter) will toggle the value of the property.
In all other cases, the parameter type will correspond to the type of the property.
The general idea here is to reduce the number of locations where a
particular piece of state is kept (and therefore has to be synchronised
between). PropertyAction
does not have a separate state that is kept
in sync with the property value -- its state is the property value.
For example, it might be useful to create a Action
corresponding to
the "visible-child-name" property of a GtkStack
so that the current
page can be switched from a menu. The active radio indication in the
menu is then directly determined from the active page of the
GtkStack
.
An anti-example would be binding the "active-id" property on a
GtkComboBox
. This is because the state of the combobox itself is
probably uninteresting and is actually being used to control
something else.
Another anti-example would be to bind to the "visible-child-name"
property of a GtkStack
if this value is actually stored in
Settings
. In that case, the real source of the value is
Settings
. If you want a Action
to control a setting stored in
Settings
, see settingsCreateAction
instead, and possibly
combine its use with settingsBind
.
Since: 2.38
Synopsis
- newtype PropertyAction = PropertyAction (ManagedPtr PropertyAction)
- class GObject o => IsPropertyAction o
- toPropertyAction :: (MonadIO m, IsPropertyAction o) => o -> m PropertyAction
- noPropertyAction :: Maybe PropertyAction
- propertyActionNew :: (HasCallStack, MonadIO m, IsObject a) => Text -> a -> Text -> m PropertyAction
- getPropertyActionEnabled :: (MonadIO m, IsPropertyAction o) => o -> m Bool
- constructPropertyActionInvertBoolean :: IsPropertyAction o => Bool -> IO (GValueConstruct o)
- getPropertyActionInvertBoolean :: (MonadIO m, IsPropertyAction o) => o -> m Bool
- constructPropertyActionName :: IsPropertyAction o => Text -> IO (GValueConstruct o)
- getPropertyActionName :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe Text)
- constructPropertyActionObject :: (IsPropertyAction o, IsObject a) => a -> IO (GValueConstruct o)
- getPropertyActionParameterType :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe VariantType)
- constructPropertyActionPropertyName :: IsPropertyAction o => Text -> IO (GValueConstruct o)
- getPropertyActionState :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe GVariant)
- getPropertyActionStateType :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe VariantType)
Exported types
newtype PropertyAction Source #
Memory-managed wrapper type.
Instances
GObject PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction gobjectType :: PropertyAction -> IO GType # | |
IsObject PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction | |
IsAction PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction | |
IsPropertyAction PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction |
class GObject o => IsPropertyAction o Source #
Type class for types which can be safely cast to PropertyAction
, for instance with toPropertyAction
.
Instances
(GObject a, (UnknownAncestorError PropertyAction a :: Constraint)) => IsPropertyAction a Source # | |
Defined in GI.Gio.Objects.PropertyAction | |
IsPropertyAction PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction |
toPropertyAction :: (MonadIO m, IsPropertyAction o) => o -> m PropertyAction Source #
Cast to PropertyAction
, for types for which this is known to be safe. For general casts, use castTo
.
noPropertyAction :: Maybe PropertyAction Source #
A convenience alias for Nothing
:: Maybe
PropertyAction
.
Methods
new
:: (HasCallStack, MonadIO m, IsObject a) | |
=> Text |
|
-> a |
|
-> Text |
|
-> m PropertyAction | Returns: a new |
Creates a Action
corresponding to the value of property
propertyName
on object
.
The property must be existent and readable and writable (and not construct-only).
This function takes a reference on object
and doesn't release it
until the action is destroyed.
Since: 2.38
Properties
enabled
If action
is currently enabled.
If the action is disabled then calls to actionActivate
and
actionChangeState
have no effect.
Since: 2.38
getPropertyActionEnabled :: (MonadIO m, IsPropertyAction o) => o -> m Bool Source #
Get the value of the “enabled
” property.
When overloading is enabled, this is equivalent to
get
propertyAction #enabled
invertBoolean
If True
, the state of the action will be the negation of the
property value, provided the property is boolean.
Since: 2.46
constructPropertyActionInvertBoolean :: IsPropertyAction o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “invert-boolean
” property. This is rarely needed directly, but it is used by new
.
getPropertyActionInvertBoolean :: (MonadIO m, IsPropertyAction o) => o -> m Bool Source #
Get the value of the “invert-boolean
” property.
When overloading is enabled, this is equivalent to
get
propertyAction #invertBoolean
name
The name of the action. This is mostly meaningful for identifying
the action once it has been added to a ActionMap
.
Since: 2.38
constructPropertyActionName :: IsPropertyAction o => Text -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “name
” property. This is rarely needed directly, but it is used by new
.
getPropertyActionName :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe Text) Source #
Get the value of the “name
” property.
When overloading is enabled, this is equivalent to
get
propertyAction #name
object
The object to wrap a property on.
The object must be a non-Nothing
Object
with properties.
Since: 2.38
constructPropertyActionObject :: (IsPropertyAction o, IsObject a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “object
” property. This is rarely needed directly, but it is used by new
.
parameterType
The type of the parameter that must be given when activating the action.
Since: 2.38
getPropertyActionParameterType :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe VariantType) Source #
Get the value of the “parameter-type
” property.
When overloading is enabled, this is equivalent to
get
propertyAction #parameterType
propertyName
The name of the property to wrap on the object.
The property must exist on the passed-in object and it must be readable and writable (and not construct-only).
Since: 2.38
constructPropertyActionPropertyName :: IsPropertyAction o => Text -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “property-name
” property. This is rarely needed directly, but it is used by new
.
state
The state of the action, or Nothing
if the action is stateless.
Since: 2.38
getPropertyActionState :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe GVariant) Source #
Get the value of the “state
” property.
When overloading is enabled, this is equivalent to
get
propertyAction #state
stateType
The VariantType
of the state that the action has, or Nothing
if the
action is stateless.
Since: 2.38
getPropertyActionStateType :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe VariantType) Source #
Get the value of the “state-type
” property.
When overloading is enabled, this is equivalent to
get
propertyAction #stateType