gi-gio-2.0.18: Gio bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Objects.SimpleAction

Contents

Description

A SimpleAction is the obvious simple implementation of the Action interface. This is the easiest way to create an action for purposes of adding it to a SimpleActionGroup.

See also GtkAction.

Synopsis

Exported types

newtype SimpleAction Source #

Memory-managed wrapper type.

class GObject o => IsSimpleAction o Source #

Type class for types which can be safely cast to SimpleAction, for instance with toSimpleAction.

toSimpleAction :: (MonadIO m, IsSimpleAction o) => o -> m SimpleAction Source #

Cast to SimpleAction, for types for which this is known to be safe. For general casts, use castTo.

Methods

new

simpleActionNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

name: the name of the action

-> Maybe VariantType

parameterType: the type of parameter to the activate function

-> m SimpleAction

Returns: a new SimpleAction

Creates a new action.

The created action is stateless. See simpleActionNewStateful.

Since: 2.28

newStateful

simpleActionNewStateful Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

name: the name of the action

-> Maybe VariantType

parameterType: the type of the parameter to the activate function

-> GVariant

state: the initial state of the action

-> m SimpleAction

Returns: a new SimpleAction

Creates a new stateful action.

state is the initial state of the action. All future state values must have the same VariantType as the initial state.

If the state GVariant is floating, it is consumed.

Since: 2.28

setEnabled

simpleActionSetEnabled Source #

Arguments

:: (HasCallStack, MonadIO m, IsSimpleAction a) 
=> a

simple: a SimpleAction

-> Bool

enabled: whether the action is enabled

-> m () 

Sets the action as enabled or not.

An action must be enabled in order to be activated or in order to have its state changed from outside callers.

This should only be called by the implementor of the action. Users of the action should not attempt to modify its enabled flag.

Since: 2.28

setState

simpleActionSetState Source #

Arguments

:: (HasCallStack, MonadIO m, IsSimpleAction a) 
=> a

simple: a SimpleAction

-> GVariant

value: the new GVariant for the state

-> m () 

Sets the state of the action.

This directly updates the 'state' property to the given value.

This should only be called by the implementor of the action. Users of the action should not attempt to directly modify the 'state' property. Instead, they should call actionChangeState to request the change.

If the value GVariant is floating, it is consumed.

Since: 2.30

setStateHint

simpleActionSetStateHint Source #

Arguments

:: (HasCallStack, MonadIO m, IsSimpleAction a) 
=> a

simple: a SimpleAction

-> Maybe GVariant

stateHint: a GVariant representing the state hint

-> m () 

Sets the state hint for the action.

See actionGetStateHint for more information about action state hints.

Since: 2.44

Properties

enabled

If action is currently enabled.

If the action is disabled then calls to actionActivate and actionChangeState have no effect.

Since: 2.28

constructSimpleActionEnabled :: IsSimpleAction o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “enabled” property. This is rarely needed directly, but it is used by new.

getSimpleActionEnabled :: (MonadIO m, IsSimpleAction o) => o -> m Bool Source #

Get the value of the “enabled” property. When overloading is enabled, this is equivalent to

get simpleAction #enabled

setSimpleActionEnabled :: (MonadIO m, IsSimpleAction o) => o -> Bool -> m () Source #

Set the value of the “enabled” property. When overloading is enabled, this is equivalent to

set simpleAction [ #enabled := value ]

name

The name of the action. This is mostly meaningful for identifying the action once it has been added to a SimpleActionGroup.

Since: 2.28

constructSimpleActionName :: IsSimpleAction 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.

getSimpleActionName :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe Text) Source #

Get the value of the “name” property. When overloading is enabled, this is equivalent to

get simpleAction #name

parameterType

The type of the parameter that must be given when activating the action.

Since: 2.28

constructSimpleActionParameterType :: IsSimpleAction o => VariantType -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “parameter-type” property. This is rarely needed directly, but it is used by new.

getSimpleActionParameterType :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe VariantType) Source #

Get the value of the “parameter-type” property. When overloading is enabled, this is equivalent to

get simpleAction #parameterType

state

The state of the action, or Nothing if the action is stateless.

Since: 2.28

constructSimpleActionState :: IsSimpleAction o => GVariant -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “state” property. This is rarely needed directly, but it is used by new.

getSimpleActionState :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe GVariant) Source #

Get the value of the “state” property. When overloading is enabled, this is equivalent to

get simpleAction #state

setSimpleActionState :: (MonadIO m, IsSimpleAction o) => o -> GVariant -> m () Source #

Set the value of the “state” property. When overloading is enabled, this is equivalent to

set simpleAction [ #state := value ]

stateType

The VariantType of the state that the action has, or Nothing if the action is stateless.

Since: 2.28

getSimpleActionStateType :: (MonadIO m, IsSimpleAction o) => o -> m (Maybe VariantType) Source #

Get the value of the “state-type” property. When overloading is enabled, this is equivalent to

get simpleAction #stateType

Signals

activate

type C_SimpleActionActivateCallback = Ptr () -> Ptr GVariant -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type SimpleActionActivateCallback Source #

Arguments

 = Maybe GVariant

parameter: the parameter to the activation

-> IO () 

Indicates that the action was just activated.

parameter will always be of the expected type. In the event that an incorrect type was given, no signal will be emitted.

Since GLib 2.40, if no handler is connected to this signal then the default behaviour for boolean-stated actions with a Nothing parameter type is to toggle them via the SimpleAction::change-state signal. For stateful actions where the state type is equal to the parameter type, the default is to forward them directly to SimpleAction::change-state. This should allow almost all users of SimpleAction to connect only one handler or the other.

Since: 2.28

afterSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => a -> SimpleActionActivateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “activate” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after simpleAction #activate callback

onSimpleActionActivate :: (IsSimpleAction a, MonadIO m) => a -> SimpleActionActivateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “activate” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on simpleAction #activate callback

changeState

type C_SimpleActionChangeStateCallback = Ptr () -> Ptr GVariant -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type SimpleActionChangeStateCallback Source #

Arguments

 = Maybe GVariant

value: the requested value for the state

-> IO () 

Indicates that the action just received a request to change its state.

value will always be of the correct state type. In the event that an incorrect type was given, no signal will be emitted.

If no handler is connected to this signal then the default behaviour is to call simpleActionSetState to set the state to the requested value. If you connect a signal handler then no default action is taken. If the state should change then you must call simpleActionSetState from the handler.

An example of a 'change-state' handler:

C code

static void
change_volume_state (GSimpleAction *action,
                     GVariant      *value,
                     gpointer       user_data)
{
  gint requested;

  requested = g_variant_get_int32 (value);

  // Volume only goes from 0 to 10
  if (0 <= requested && requested <= 10)
    g_simple_action_set_state (action, value);
}

The handler need not set the state to the requested value. It could set it to any value at all, or take some other action.

Since: 2.30

afterSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => a -> SimpleActionChangeStateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “change-state” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after simpleAction #changeState callback

onSimpleActionChangeState :: (IsSimpleAction a, MonadIO m) => a -> SimpleActionChangeStateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “change-state” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on simpleAction #changeState callback