gi-gio-2.0.32: Gio bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | Safe-Inferred
Language | Haskell2010

GI.Gio.Objects.PropertyAction

Contents

- Exported types
- Methods
  - new
- Properties
  - enabled
  - invertBoolean
  - name
  - object
  - parameterType
  - propertyName
  - state
  - stateType

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 [type`gObject`.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 [type`gObject`.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 [type`gLib`.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

Instances details

Eq PropertyAction Source # |
Instance details Defined in GI.Gio.Objects.PropertyAction Methods (==) :: PropertyAction -> PropertyAction -> Bool Source # (/=) :: PropertyAction -> PropertyAction -> Bool Source #
GObject PropertyAction Source # |
Instance details Defined in GI.Gio.Objects.PropertyAction
ManagedPtrNewtype PropertyAction Source # |
Instance details Defined in GI.Gio.Objects.PropertyAction Methods toManagedPtr :: PropertyAction -> ManagedPtr PropertyAction Source #
TypedObject PropertyAction Source # |
Instance details Defined in GI.Gio.Objects.PropertyAction Methods glibType :: IO GType Source #
HasParentTypes PropertyAction Source # |
Instance details Defined in GI.Gio.Objects.PropertyAction
IsGValue (Maybe PropertyAction) Source # | Convert `PropertyAction` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gio.Objects.PropertyAction Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe PropertyAction -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe PropertyAction) Source #
type ParentTypes PropertyAction Source # |
Instance details Defined in GI.Gio.Objects.PropertyAction type ParentTypes PropertyAction = '[Object, Action]

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

Instances details

(GObject o, IsDescendantOf PropertyAction o) => IsPropertyAction o Source # |
Instance details 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

Expand

#### 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

setData, setDataFull, setProperty.

## new

propertyActionNew Source #

Arguments

:: (HasCallStack, MonadIO m, IsObject a) |
=> Text | `name`: the name of the action to create
-> a | `object`: the object that has the property to wrap
-> Text | `propertyName`: the name of the property
-> m PropertyAction | Returns: a new `PropertyAction`

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