e-ui-action

e-ui-action — a UI action

Functions

Properties

char * accel Read / Write
gboolean active Read / Write
gboolean enabled Read / Write
char * icon-name Read / Write
gboolean is-visible Read
char * label Read / Write
char * map-name Read / Write / Construct Only
char * name Read / Write / Construct Only
GVariantType * parameter-type Read / Write / Construct Only
gboolean sensitive Read / Write
GVariant * state Read / Write
GVariantType * state-hint Read / Write
GVariantType * state-type Read
char * tooltip Read / Write
gboolean visible Read / Write

Signals

void accel-added Action
void accel-removed Action
void activate Run Last
void change-state Run Last
void changed Action

Types and Values

Object Hierarchy

    GObject
    ╰── EUIAction

Implemented Interfaces

EUIAction implements GAction.

Includes

#include <e-util/e-util.h>

Description

The EUIAction is similar to a GSimpleAction, with added properties suitable for easier manipulation of the action appearance. It implements a GAction interface.

The action can be part of a single EUIActionGroup only. The GAction::enabled property considers also the groups sensitive value.

While the EUIAction :visible property is relevant for the action itself, the EUIAction :is-visible property considers also visibility of the group, if any.

The object is not thread-safe, it's meant to be used only from the main/GUI thread.

Functions

EUIActionFunc ()

void
(*EUIActionFunc) (EUIAction *action,
                  GVariant *value,
                  gpointer user_data);

A function called either on action activate or change_state signal.

For the activate, the value is a parameter, with which the activate was called. Stateless actions do not provide any parameter.

For the change_state, the value is a new value the state should be changed to.

Parameters

action

an EUIAction

 

value

a GVariant value for the function.

[nullable]

user_data

user data for the function

 

Since: 3.56


e_ui_action_new ()

EUIAction *
e_ui_action_new (const gchar *map_name,
                 const gchar *action_name,
                 const GVariantType *parameter_type);

Creates a new EUIAction.

Parameters

map_name

a name of a GActionMap the action belongs to

 

action_name

a name of the action to be created

 

parameter_type

a type of the action parameter, as GVariantType, or NULL.

[nullable]

Returns

a new EUIAction.

[transfer full]

Since: 3.56


e_ui_action_new_stateful ()

EUIAction *
e_ui_action_new_stateful (const gchar *map_name,
                          const gchar *action_name,
                          const GVariantType *parameter_type,
                          GVariant *state);

Creates a new stateful EUIAction. Actions with boolean state are usually presented as toggle buttons and menu items, while actions with string states are usually presented as radio buttons and menu items. Radio actions need to have set radio group with e_ui_action_set_radio_group().

Parameters

map_name

a name of a GActionMap the action belongs to

 

action_name

a name of the action to be created

 

parameter_type

a type of the action parameter, as GVariantType, or NULL.

[nullable]

state

a GVariant for the action to have set a state to

 

Returns

a new stateful EUIAction.

[transfer full]

Since: 3.56


e_ui_action_new_from_entry ()

EUIAction *
e_ui_action_new_from_entry (const gchar *map_name,
                            const EUIActionEntry *entry,
                            const gchar *translation_domain);

Creates a new EUIAction from the entry .

Parameters

map_name

a name of a GActionMap the action belongs to

 

entry

a single EUIActionEntry to construct the action from

 

translation_domain

a translation domain to use to localize the entry members for label and tooltip.

[nullable]

Returns

a new EUIAction.

[transfer full]

Since: 3.56


e_ui_action_new_from_enum_entry ()

EUIAction *
e_ui_action_new_from_enum_entry (const gchar *map_name,
                                 const EUIActionEnumEntry *entry,
                                 const gchar *translation_domain);

Creates a new EUIAction from the entry .

Parameters

map_name

a name of a GActionMap the action belongs to

 

entry

a single EUIActionEnumEntry to construct the action from

 

translation_domain

a translation domain to use to localize the entry members for label and tooltip.

[nullable]

Returns

a new EUIAction.

[transfer full]

Since: 3.56


e_ui_action_get_map_name ()

const gchar *
e_ui_action_get_map_name (EUIAction *self);

Get name of the action map. It usually matches a name of an associated EUIActionGroup.

Parameters

self

an EUIAction

 

Returns

action map name of the self

Since: 3.56


e_ui_action_ref_target ()

GVariant *
e_ui_action_ref_target (EUIAction *self);

References target of a stateful action. This is usable for radio actions, where the state contains the current state of the whole radio group, while the target is the value to be set in the group when the action is activated.

Parameters

self

an EUIAction

 

Returns

the target value of the self , or NULL, when the self is not a radio action.

[transfer full][nullable]

Since: 3.56


e_ui_action_set_state ()

void
e_ui_action_set_state (EUIAction *self,
                       GVariant *value);

Sets a state of the self to value .

Parameters

self

an EUIAction

 

value

a state to set, as a GVariant.

[transfer full]

Since: 3.56


e_ui_action_set_state_hint ()

void
e_ui_action_set_state_hint (EUIAction *self,
                            GVariant *state_hint);

Sets or unsets the action state hint.

Parameters

self

an EUIAction

 

state_hint

a state hint as a GVariant, or NULL.

[nullable][transfer full]

Since: 3.56


e_ui_action_set_visible ()

void
e_ui_action_set_visible (EUIAction *self,
                         gboolean visible);

Sets whether the self is visible.

Parameters

self

an EUIAction

 

visible

a value to set

 

Since: 3.56


e_ui_action_get_visible ()

gboolean
e_ui_action_get_visible (EUIAction *self);

Gets whether the action is visible. It does not consider the associated group visibility; use e_ui_action_is_visible() instead.

Parameters

self

an EUIAction

 

Returns

whether the action itself is visible

Since: 3.56


e_ui_action_set_sensitive ()

void
e_ui_action_set_sensitive (EUIAction *self,
                           gboolean sensitive);

Sets whether the action is sensitive.

Parameters

self

an EUIAction

 

sensitive

a value to set

 

Since: 3.56


e_ui_action_get_sensitive ()

gboolean
e_ui_action_get_sensitive (EUIAction *self);

Gets whether the action is sensitive. It does not consider the associated group sensitivity; use g_action_get_enabled() instead.

Parameters

self

an EUIAction

 

Returns

whether the action itself is sensitive

Since: 3.56


e_ui_action_is_visible ()

gboolean
e_ui_action_is_visible (EUIAction *self);

Gets whether the action itself and the associated EUIActionGroup, if any, are both visible. Use e_ui_action_get_visible() to get visibility of the action itself.

Parameters

self

an EUIAction

 

Returns

whether the self with the associated action group are visible

Since: 3.56


e_ui_action_set_icon_name ()

void
e_ui_action_set_icon_name (EUIAction *self,
                           const gchar *icon_name);

Sets or unsets and icon name for the self . It can be a standard icon name, or a text with prefix "gicon::", which are generated by the action owner through “create-gicon” signal. The signal is executed without the "gicon::" prefix.

Parameters

self

an EUIAction

 

icon_name

an icon name, or NULL.

[nullable]

Since: 3.56


e_ui_action_get_icon_name ()

const gchar *
e_ui_action_get_icon_name (EUIAction *self);

Gets the icon name of the self .

Parameters

self

an EUIAction

 

Returns

an icon name for the self , or NULL, when none is set.

[nullable]

Since: 3.56


e_ui_action_set_label ()

void
e_ui_action_set_label (EUIAction *self,
                       const gchar *label);

Sets a label for the action. The label should be already localized.

Parameters

self

an EUIAction

 

label

a label to set, or NULL.

[nullable]

Since: 3.56


e_ui_action_get_label ()

const gchar *
e_ui_action_get_label (EUIAction *self);

Gets a label of the self .

Parameters

self

an EUIAction

 

Returns

a label of the self , or NULL, when none is set.

[nullable]

Since: 3.56


e_ui_action_set_accel ()

void
e_ui_action_set_accel (EUIAction *self,
                       const gchar *accel);

Sets or unsets an accelerator string for the self . The accel should be parseable by the gtk_accelerator_parse() function.

Parameters

self

an EUIAction

 

accel

an accelerator string, or NULL.

[nullable]

Since: 3.56


e_ui_action_get_accel ()

const gchar *
e_ui_action_get_accel (EUIAction *self);

Gets an accelarator string for the self .

Parameters

self

an EUIAction

 

Returns

an accelerator string for the self , or NULL, when none is set.

[nullable]

Since: 3.56


e_ui_action_add_secondary_accel ()

void
e_ui_action_add_secondary_accel (EUIAction *self,
                                 const gchar *accel);

Adds a secondary accelerator string for the self . This is in addition to the "accel" property, which is meant to be the main accelerator, shown in the GUI and such.

The accel should be parseable by the gtk_accelerator_parse() function.

Parameters

self

an EUIAction

 

accel

an accelerator string.

[not nullable]

Since: 3.56


e_ui_action_get_secondary_accels ()

GPtrArray *
e_ui_action_get_secondary_accels (EUIAction *self);

Gets an array of the secondary accelarators for the self . The caller should not modify the array in any way.

Parameters

self

an EUIAction

 

Returns

an array of the secondary accelerator strings for the self , or NULL, when none is set.

[nullable][transfer none][element-type utf8]

Since: 3.56


e_ui_action_remove_secondary_accels ()

void
e_ui_action_remove_secondary_accels (EUIAction *self);

Removes all secondary accelerator strings.

Parameters

self

an EUIAction

 

Since: 3.56


e_ui_action_set_tooltip ()

void
e_ui_action_set_tooltip (EUIAction *self,
                         const gchar *tooltip);

Sets or unsets a tooltip text (not markup) for the self .

Parameters

self

an EUIAction

 

tooltip

a tooltip text to set, or NULL.

[nullable]

Since: 3.56


e_ui_action_get_tooltip ()

const gchar *
e_ui_action_get_tooltip (EUIAction *self);

Gets tooltip text for the self .

Parameters

self

an EUIAction

 

Returns

a tooltip text (not markup) for the self , or NULL, when none is set.

[nullable]

Since: 3.56


e_ui_action_set_radio_group ()

void
e_ui_action_set_radio_group (EUIAction *self,
                             GPtrArray *radio_group);

Stateful actions can be grouped together, by setting the same radio group to each action. When not NULL, the self references the radio_group , thus the caller can just create one array, set it to each action and then unref it.

An action can be in a single radio group only. Trying to set a different radio group when one is already set is considered a programming error.

Parameters

self

an EUIAction

 

radio_group

a radio group to use, or NULL.

[nullable][transfer none][element-type EUIAction]

Since: 3.56


e_ui_action_set_action_group ()

void
e_ui_action_set_action_group (EUIAction *self,
                              struct _EUIActionGroup *action_group);

Sets the self as being part of the action_group , or unsets the group, when it's NULL. An action cannot be part of multiple action groups, thus when trying to set a different action group the action is removed from the previous group (unlike e_ui_action_set_radio_group(), which does not move an action between radio groups automatically).

The action_group usually matches the EUIAction :map-name property.

See e_ui_action_get_sensitive(), e_ui_action_get_visible(), e_ui_action_is_visible().

Parameters

self

an EUIAction

 

action_group

an EUIActionGroup to set, or NULL.

[nullable]

Since: 3.56


e_ui_action_get_action_group ()

struct _EUIActionGroup *
e_ui_action_get_action_group (EUIAction *self);

Gets an action group the self is part of.

Parameters

self

an EUIAction

 

Returns

an EUIActionGroup the self is part of, or NULL, when none is set.

[transfer none][nullable]

Since: 3.56


e_ui_action_get_active ()

gboolean
e_ui_action_get_active (EUIAction *self);

Checks whether the self state is the active, aka current, value.

For toggle actions (with boolean state) returns whether the state is TRUE. For radio actions returns whether the state matches the action target. For stateless actions returns FALSE.

Parameters

self

an EUIAction

 

Returns

whether the self is active

Since: 3.56


e_ui_action_set_active ()

void
e_ui_action_set_active (EUIAction *self,
                        gboolean active);

Sets whether the self state is the active , aka current, value.

For toggle actions (with boolean state) sets the active directly. For radio actions sets the state to the self target when active is TRUE, otherwise does nothing. For stateless actions does nothing.

Parameters

self

an EUIAction

 

active

value to set

 

Since: 3.56


e_ui_action_emit_changed ()

void
e_ui_action_emit_changed (EUIAction *self);

Emits the “changed” signal on the self .

Parameters

self

an EUIAction

 

Since: 3.56


e_ui_action_get_usable_for_kinds ()

guint32
e_ui_action_get_usable_for_kinds (EUIAction *self);

Returns bit-or of EUIElementKind, for which the action can be used. Only the E_UI_ELEMENT_KIND_HEADERBAR, E_UI_ELEMENT_KIND_TOOLBAR and E_UI_ELEMENT_KIND_MENU are considered.

By default, the self can be used for all these kinds.

Parameters

self

an EUIAction

 

Returns

bit-or of EUIElementKind

Since: 3.56


e_ui_action_set_usable_for_kinds ()

void
e_ui_action_set_usable_for_kinds (EUIAction *self,
                                  guint32 kinds);

Sets which EUIElementKind -s the self can be used for. Only the E_UI_ELEMENT_KIND_HEADERBAR, E_UI_ELEMENT_KIND_TOOLBAR and E_UI_ELEMENT_KIND_MENU are considered.

By default, the self can be used for all these kinds.

Parameters

self

an EUIAction

 

kinds

a bit-or of EUIElementKind

 

Since: 3.56


e_ui_action_util_gvalue_to_enum_state ()

gboolean
e_ui_action_util_gvalue_to_enum_state (GBinding *binding,
                                       const GValue *from_value,
                                       GValue *to_value,
                                       gpointer user_data);

A utility function, which can be used as a transformation function of a GBinding from an enum property to an enum state of an EUIAction created by e_ui_action_new_from_enum_entry().

Parameters

binding

a GBinding

 

from_value

a source GValue

 

to_value

a destination GValue

 

user_data

unused binding user data

 

Returns

TRUE

Since: 3.56


e_ui_action_util_enum_state_to_gvalue ()

gboolean
e_ui_action_util_enum_state_to_gvalue (GBinding *binding,
                                       const GValue *from_value,
                                       GValue *to_value,
                                       gpointer user_data);

A utility function, which can be used as a transformation function of a GBinding from an enum state of an EUIAction created by e_ui_action_new_from_enum_entry() to an enum property.

Parameters

binding

a GBinding

 

from_value

a source GValue

 

to_value

a destination GValue

 

user_data

unused binding user data

 

Returns

TRUE

Since: 3.56


e_ui_action_util_assign_to_widget ()

void
e_ui_action_util_assign_to_widget (EUIAction *action,
                                   struct _GtkWidget *widget);

Assigns action to the widget , syncing visible, sensitive and tooltip properties, together with the actionable properties.

Parameters

action

an EUIAction

 

widget

a GtkWidget

 

Since: 3.56

Types and Values

E_TYPE_UI_ACTION

#define E_TYPE_UI_ACTION e_ui_action_get_type ()

EUIActionEntry

typedef struct {
	const gchar *name;
	const gchar *icon_name;
	const gchar *label;
	const gchar *accel;
	const gchar *tooltip;
	EUIActionFunc activate;
	const gchar *parameter_type;
	const gchar *state;
	EUIActionFunc change_state;
} EUIActionEntry;

A structure describing an action, which can be created in bulk with e_ui_manager_add_actions() function.

Simple actions declare only the activate callback, where it reacts to the action activation.

To create a checkbox-like widgets from the action, set the state to a boolean value (like "true") and provide a change_state function, which will set e_ui_action_set_state (action, value); and also react to the change of the state.

To create a radiobutton-like widgets from the action, set the parameter_type for example to string ("s"), the state to the value the radio group should be switched to (like "'value1'") and the change_state function, which calls e_ui_action_set_state (action, value); and reacts to the change of the state. Each action in the radio group can use the same change_state callback. Make sure the actions are part of the same radio group with the e_ui_action_set_radio_group().

See EUIActionEnumEntry

Members

const gchar *name;

an action name

 

const gchar *icon_name;

an icon name

 

const gchar *label;

an action label

 

const gchar *accel;

an action accelerator

 

const gchar *tooltip;

an action tooltip

 

EUIActionFunc activate;

an EUIActionFunc callback to call when the action is activated, or NULL.

[nullable]

const gchar *parameter_type;

an action parameter type

 

const gchar *state;

an action state for stateful actions

 

EUIActionFunc change_state;

an EUIActionFunc callback to call when the state of the action should be changed, or NULL.

[nullable]

Since: 3.56


EUIActionEnumEntry

typedef struct {
	const gchar *name;
	const gchar *icon_name;
	const gchar *label;
	const gchar *accel;
	const gchar *tooltip;
	EUIActionFunc activate;
	gint state;
} EUIActionEnumEntry;

A structure describing a radio action, whose states are enum values. The actions can be created in bulk with e_ui_manager_add_actions_enum() function.

See EUIActionEntry.

Members

const gchar *name;

an action name

 

const gchar *icon_name;

an icon name

 

const gchar *label;

an action label

 

const gchar *accel;

an action accelerator

 

const gchar *tooltip;

an action tooltip

 

EUIActionFunc activate;

an EUIActionFunc callback to call when the action is activated, or NULL.

[nullable]

gint state;

the corresponding enum value, as gint

 

Since: 3.56


EUIAction

typedef struct _EUIAction EUIAction;

Property Details

The “accel” property

  “accel”                    char *

An action accelerator.

Owner: EUIAction

Flags: Read / Write

Default value: NULL

Since: 3.56


The “active” property

  “active”                   gboolean

Action's active state. It is relevant only for stateful actions, like toggle actions (with a boolean state) or radio actions (with state and target). See e_ui_action_get_active() and e_ui_action_set_active() for more information.

Owner: EUIAction

Flags: Read / Write

Default value: TRUE

Since: 3.56


The “enabled” property

  “enabled”                  gboolean

An enabled state of the action. When the action is part of an action group, the EUIActionGroup :sensitive is consulted together with the EUIAction :sensitive property when determining whether the action is enabled.

Owner: EUIAction

Flags: Read / Write

Default value: TRUE

Since: 3.56


The “icon-name” property

  “icon-name”                char *

An icon name, which can be a standard icon name, or a text with prefix "gicon::", which are generated by the action owner through “create-gicon” signal. The signal is executed without the "gicon::" prefix.

Owner: EUIAction

Flags: Read / Write

Default value: NULL

Since: 3.56


The “is-visible” property

  “is-visible”               gboolean

Read-only property to determine whether both EUIAction :visible property and possibly associated EUIActionGroup 's visible property are TRUE.

Owner: EUIAction

Flags: Read

Default value: TRUE

Since: 3.56


The “label” property

  “label”                    char *

An action label.

Owner: EUIAction

Flags: Read / Write

Default value: NULL

Since: 3.56


The “map-name” property

  “map-name”                 char *

A GActionMap name the action is declared at. It usually matches EUIActionGroup name, when one is set on the action.

Owner: EUIAction

Flags: Read / Write / Construct Only

Default value: NULL

Since: 3.56


The “name” property

  “name”                     char *

An action name.

Owner: EUIAction

Flags: Read / Write / Construct Only

Default value: NULL

Since: 3.56


The “parameter-type” property

  “parameter-type”           GVariantType *

A parameter type of a stateful action, as a GVariantType, or NULL.

Owner: EUIAction

Flags: Read / Write / Construct Only

Since: 3.56


The “sensitive” property

  “sensitive”                gboolean

Action's sensitive state. It does not consult associated EUIActionGroup sensitivity.

Owner: EUIAction

Flags: Read / Write

Default value: TRUE

Since: 3.56


The “state” property

  “state”                    GVariant *

A state of a stateful action, as a GVariant, or NULL.

Owner: EUIAction

Flags: Read / Write

Allowed values: GVariant<*>

Default value: NULL

Since: 3.56


The “state-hint” property

  “state-hint”               GVariantType *

A state hint of a stateful action, as a GVariantType, or NULL.

Owner: EUIAction

Flags: Read / Write

Since: 3.56


The “state-type” property

  “state-type”               GVariantType *

State type of a stateful action, as a GVariantType, or NULL.

Owner: EUIAction

Flags: Read

Since: 3.56


The “tooltip” property

  “tooltip”                  char *

An action tooltip text (not markup).

Owner: EUIAction

Flags: Read / Write

Default value: NULL

Since: 3.56


The “visible” property

  “visible”                  gboolean

Whether the action is visible. It does not consult associated EUIActionGroup visibility.

Owner: EUIAction

Flags: Read / Write

Default value: TRUE

Since: 3.56

Signal Details

The “accel-added” signal

void
user_function (EUIAction *self,
               char      *accel,
               gpointer   user_data)

A signal emitted when the action has either set the primary accelerator or it has added a secondary accelerator.

Parameters

self

an EUIAction

 

accel

the added accelerator string

 

user_data

user data set when the signal handler was connected.

 

Flags: Action

Since: 3.56


The “accel-removed” signal

void
user_function (EUIAction *self,
               char      *accel,
               gpointer   user_data)

A signal emitted when the action has either unset the primary accelerator or it has removed a secondary accelerator. The accel is the removed accelerator string.

Parameters

self

an EUIAction

 

accel

the removed accelerator string

 

user_data

user data set when the signal handler was connected.

 

Flags: Action

Since: 3.56


The “activate” signal

void
user_function (EUIAction *self,
               GVariant  *parameter,
               gpointer   user_data)

A signal emitted when the action should be activated. The parameter is provided only for stateful actions.

Parameters

self

an EUIAction

 

parameter

an activation parameter as a GVariant, or NULL.

[nullable]

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

Since: 3.56


The “change-state” signal

void
user_function (EUIAction *self,
               GVariant  *new_state,
               gpointer   user_data)

A signal emitted to set a new state to a stateful action.

Parameters

self

an EUIAction

 

new_state

a new state

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

Since: 3.56


The “changed” signal

void
user_function (EUIAction *self,
               gpointer   user_data)

A signal emitted when the action changes its content. It's meant to be called when the menu content corresponding to this action should be regenerated, similar to when the “is-visible” property changes.

Parameters

self

an EUIAction

 

user_data

user data set when the signal handler was connected.

 

Flags: Action

Since: 3.56