| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.Gio.Objects.PropertyAction
Description
A GPropertyAction 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 [typegObject.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 [typegObject.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 [typegLib.Variant] 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). GPropertyAction 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 combo box 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, IsDescendantOf PropertyAction o) => IsPropertyAction o
- toPropertyAction :: (MonadIO m, IsPropertyAction o) => o -> m PropertyAction
- propertyActionNew :: (HasCallStack, MonadIO m, IsObject a) => Text -> a -> Text -> m PropertyAction
- getPropertyActionEnabled :: (MonadIO m, IsPropertyAction o) => o -> m Bool
- constructPropertyActionInvertBoolean :: (IsPropertyAction o, MonadIO m) => Bool -> m (GValueConstruct o)
- getPropertyActionInvertBoolean :: (MonadIO m, IsPropertyAction o) => o -> m Bool
- constructPropertyActionName :: (IsPropertyAction o, MonadIO m) => Text -> m (GValueConstruct o)
- getPropertyActionName :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe Text)
- constructPropertyActionObject :: (IsPropertyAction o, MonadIO m, IsObject a) => a -> m (GValueConstruct o)
- getPropertyActionParameterType :: (MonadIO m, IsPropertyAction o) => o -> m (Maybe VariantType)
- constructPropertyActionPropertyName :: (IsPropertyAction o, MonadIO m) => Text -> m (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.
Constructors
| PropertyAction (ManagedPtr PropertyAction) |
Instances
| Eq PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction Methods (==) :: PropertyAction -> PropertyAction -> Bool # (/=) :: PropertyAction -> PropertyAction -> Bool # | |
| GObject PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction | |
| ManagedPtrNewtype PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction Methods toManagedPtr :: PropertyAction -> ManagedPtr PropertyAction # | |
| TypedObject PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction | |
| HasParentTypes PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction | |
| IsGValue (Maybe PropertyAction) Source # | Convert |
Defined in GI.Gio.Objects.PropertyAction Methods gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe PropertyAction -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe PropertyAction) # | |
| type ParentTypes PropertyAction Source # | |
Defined in GI.Gio.Objects.PropertyAction | |
class (GObject o, IsDescendantOf PropertyAction o) => IsPropertyAction o Source #
Type class for types which can be safely cast to PropertyAction, for instance with toPropertyAction.
Instances
| (GObject o, IsDescendantOf PropertyAction o) => IsPropertyAction o 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.
Methods
Click to display all available methods, including inherited ones
Methods
activate, bindProperty, bindPropertyFull, changeState, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getEnabled, getName, getParameterType, getProperty, getQdata, getState, getStateHint, getStateType.
Setters
new
Arguments
| :: (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, MonadIO m) => Bool -> m (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, MonadIO m) => Text -> m (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, MonadIO m, IsObject a) => a -> m (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, MonadIO m) => Text -> m (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