GSimpleAction

GSimpleAction — A simple GSimpleAction

Synopsis

                    GSimpleAction;
struct              GSimpleActionClass;

GSimpleAction *          g_simple_action_new            (const gchar *name,
                                                         const GVariantType *parameter_type);
GSimpleAction *          g_simple_action_new_stateful   (const gchar *name,
                                                         const GVariantType *parameter_type,
                                                         GVariant *state);

void                g_simple_action_set_enabled         (GSimpleAction *simple,
                                                         gboolean enabled);

Object Hierarchy

  GObject
   +----GSimpleAction

Implemented Interfaces

GSimpleAction implements GAction.

Properties

  "enabled"                  gboolean              : Read / Write / Construct
  "name"                     gchar*                : Read / Write / Construct Only
  "parameter-type"           GVariantType*         : Read / Write / Construct Only
  "state"                    GVariant*             : Read / Write / Construct
  "state-type"               GVariantType*         : Read

Signals

  "activate"                                       : Run Last

Description

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

See also GtkAction.

Details

GSimpleAction

typedef struct _GSimpleAction GSimpleAction;

The GSimpleAction structure contains private data and should only be accessed using the provided API

Since 2.28


struct GSimpleActionClass

struct GSimpleActionClass {
  GObjectClass parent_class;

  /* signals */
  void  (* activate)  (GSimpleAction *simple,
                       GVariant      *parameter);
};

GObjectClass parent_class;

activate ()

the class closure for the activate signal

Since 2.28


g_simple_action_new ()

GSimpleAction *          g_simple_action_new            (const gchar *name,
                                                         const GVariantType *parameter_type);

Creates a new action.

The created action is stateless. See g_simple_action_new_stateful().

name :

the name of the action

parameter_type :

the type of parameter to the activate function. [allow-none]

Returns :

a new GSimpleAction

Since 2.28


g_simple_action_new_stateful ()

GSimpleAction *          g_simple_action_new_stateful   (const gchar *name,
                                                         const GVariantType *parameter_type,
                                                         GVariant *state);

Creates a new stateful action.

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

If the state GVariant is floating, it is consumed.

name :

the name of the action

parameter_type :

the type of the parameter to the activate function. [allow-none]

state :

the initial state of the action

Returns :

a new GSimpleAction

Since 2.28


g_simple_action_set_enabled ()

void                g_simple_action_set_enabled         (GSimpleAction *simple,
                                                         gboolean enabled);

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.

simple :

a GSimpleAction

enabled :

whether the action is enabled

Since 2.28

Property Details

The "enabled" property

  "enabled"                  gboolean              : Read / Write / Construct

If action is currently enabled.

If the action is disabled then calls to g_simple_action_activate() and g_simple_action_set_state() have no effect.

Default value: TRUE

Since 2.28


The "name" property

  "name"                     gchar*                : Read / Write / Construct Only

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

Default value: NULL

Since 2.28


The "parameter-type" property

  "parameter-type"           GVariantType*         : Read / Write / Construct Only

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

Since 2.28


The "state" property

  "state"                    GVariant*             : Read / Write / Construct

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

Allowed values: GVariant<*>

Default value: NULL

Since 2.28


The "state-type" property

  "state-type"               GVariantType*         : Read

The GVariantType of the state that the action has, or NULL if the action is stateless.

Since 2.28

Signal Details

The "activate" signal

void                user_function                      (GSimpleAction *simple,
                                                        GVariant      *parameter,
                                                        gpointer       user_data)      : Run Last

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.

simple :

the GSimpleAction

parameter :

the parameter to the activation. [allow-none]

user_data :

user data set when the signal handler was connected.

Since 2.28