Class: Gio::SimpleAction

Inherits:
Object
  • Object
show all
Defined in:
lib/gio2/simple-action.rb

Overview

A GSimpleAction is the obvious simple implementation of the [ifaceGio.Action] interface. This is the easiest way to create an action for purposes of adding it to a [classGio.SimpleActionGroup].

Instance Method Summary collapse

Constructor Details

#initialize(name, parameter_type = nil, state = nil) ⇒ Gio::SimpleAction

Creates a new stateful action.

All future state values must have the same GVariant::Type as the initial state.

If the state #GVariant is floating, it is consumed.

Parameters:

  • name (String)

    the name of the action

  • parameter_type (GLib::VariantType) (defaults to: nil)

    the type of the parameter that will be passed to handlers for the GSimple::Action::activate signal, or nil for no parameter

  • state (GLib::Variant) (defaults to: nil)

    the initial state of the action



20
21
22
23
24
25
26
27
28
29
# File 'lib/gio2/simple-action.rb', line 20

def initialize(name, parameter_type=nil, state=nil)
  if parameter_type.is_a?(String)
    parameter_type = GLib::VariantType.new(parameter_type)
  end
  if state
    initialize_raw(name, parameter_type, state)
  else
    initialize_raw(name, parameter_type)
  end
end

Instance Method Details

#enabled=(enabled) ⇒ Boolean

If action is currently enabled.

If the action is disabled then calls to g_action_activate() and g_action_change_state() have no effect.

Parameters:

  • enabled (Boolean)

Returns:

  • (Boolean)

    enabled

  • (Boolean)

    enabled

#enabled?Boolean

If action is currently enabled.

If the action is disabled then calls to g_action_activate() and g_action_change_state() have no effect.

Returns:

  • (Boolean)

    enabled

#initialize_rawGio::SimpleAction

Creates a new stateful action.

All future state values must have the same GVariant::Type as the initial state.

If the state #GVariant is floating, it is consumed.

Parameters:

  • name (String)

    the name of the action

  • parameter_type (GLib::VariantType)

    the type of the parameter that will be passed to handlers for the GSimple::Action::activate signal, or nil for no parameter

  • state (GLib::Variant)

    the initial state of the action

Returns:



# File 'lib/gio2/simple-action.rb', line 19

#nameString

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

Returns:

  • (String)

    name

#name=(name) ⇒ String

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

Parameters:

  • name (String)

Returns:

  • (String)

    name

  • (String)

    name

#parameter_typeGLib::VariantType

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

Returns:

  • (GLib::VariantType)

    parameter-type

#parameter_type=(parameter_type) ⇒ GLib::VariantType

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

Parameters:

  • parameter_type (GLib::VariantType)

Returns:

  • (GLib::VariantType)

    parameter-type

  • (GLib::VariantType)

    parameter-type

#stateGLib::Variant

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

Returns:

  • (GLib::Variant)

    state

#state=(state) ⇒ GLib::Variant

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

Parameters:

  • state (GLib::Variant)

Returns:

  • (GLib::Variant)

    state

  • (GLib::Variant)

    state

#state_hint=(state_hint) ⇒ nil

Sets the state hint for the action.

See g_action_get_state_hint() for more information about action state hints.

Parameters:

  • state_hint (GLib::Variant)

    a #GVariant representing the state hint

Returns:

  • (nil)

#state_typeGLib::VariantType

The GVariant::Type of the state that the action has, or nil if the action is stateless.

Returns:

  • (GLib::VariantType)

    state-type

#state_type=(state_type) ⇒ GLib::VariantType

The GVariant::Type of the state that the action has, or nil if the action is stateless.

Parameters:

  • state_type (GLib::VariantType)

Returns:

  • (GLib::VariantType)

    state-type

  • (GLib::VariantType)

    state-type