CtkAction

CtkAction — An action which can be triggered by a menu or toolbar item

Functions

CtkAction * ctk_action_new ()
const gchar * ctk_action_get_name ()
gboolean ctk_action_is_sensitive ()
gboolean ctk_action_get_sensitive ()
void ctk_action_set_sensitive ()
gboolean ctk_action_is_visible ()
gboolean ctk_action_get_visible ()
void ctk_action_set_visible ()
void ctk_action_activate ()
CtkWidget * ctk_action_create_icon ()
CtkWidget * ctk_action_create_menu_item ()
CtkWidget * ctk_action_create_tool_item ()
CtkWidget * ctk_action_create_menu ()
GSList * ctk_action_get_proxies ()
void ctk_action_connect_accelerator ()
void ctk_action_disconnect_accelerator ()
void ctk_action_block_activate ()
void ctk_action_unblock_activate ()
gboolean ctk_action_get_always_show_image ()
void ctk_action_set_always_show_image ()
const gchar * ctk_action_get_accel_path ()
void ctk_action_set_accel_path ()
GClosure * ctk_action_get_accel_closure ()
void ctk_action_set_accel_group ()
void ctk_action_set_label ()
const gchar * ctk_action_get_label ()
void ctk_action_set_short_label ()
const gchar * ctk_action_get_short_label ()
void ctk_action_set_tooltip ()
const gchar * ctk_action_get_tooltip ()
void ctk_action_set_stock_id ()
const gchar * ctk_action_get_stock_id ()
void ctk_action_set_gicon ()
GIcon * ctk_action_get_gicon ()
void ctk_action_set_icon_name ()
const gchar * ctk_action_get_icon_name ()
void ctk_action_set_visible_horizontal ()
gboolean ctk_action_get_visible_horizontal ()
void ctk_action_set_visible_vertical ()
gboolean ctk_action_get_visible_vertical ()
void ctk_action_set_is_important ()
gboolean ctk_action_get_is_important ()

Properties

CtkActionGroup * action-group Read / Write
gboolean always-show-image Read / Write / Construct
GIcon * gicon Read / Write
gboolean hide-if-empty Read / Write
char * icon-name Read / Write
gboolean is-important Read / Write
char * label Read / Write
char * name Read / Write / Construct Only
gboolean sensitive Read / Write
char * short-label Read / Write
char * stock-id Read / Write
char * tooltip Read / Write
gboolean visible Read / Write
gboolean visible-horizontal Read / Write
gboolean visible-overflown Read / Write
gboolean visible-vertical Read / Write

Signals

void activate No Recursion

Types and Values

struct CtkAction
struct CtkActionClass

Object Hierarchy

    GObject
    ╰── CtkAction
        ├── CtkToggleAction
        ╰── CtkRecentAction

Implemented Interfaces

CtkAction implements CtkBuildable.

Includes

#include <ctk/ctk.h>

Description

Actions represent operations that the user can be perform, along with some information how it should be presented in the interface. Each action provides methods to create icons, menu items and toolbar items representing itself.

As well as the callback that is called when the action gets activated, the following also gets associated with the action:

  • a name (not translated, for path lookup)

  • a label (translated, for display)

  • an accelerator

  • whether label indicates a stock id

  • a tooltip (optional, translated)

  • a toolbar label (optional, shorter than label)

The action will also have some state information:

  • visible (shown/hidden)

  • sensitive (enabled/disabled)

Apart from regular actions, there are toggle actions, which can be toggled between two states and radio actions, of which only one in a group can be in the “active” state. Other actions can be implemented as CtkAction subclasses.

Each action can have one or more proxy widgets. To act as an action proxy, widget needs to implement CtkActivatable interface. Proxies mirror the state of the action and should change when the action’s state changes. Properties that are always mirrored by proxies are “sensitive” and “visible”. “gicon”, “icon-name”, “label”, “short-label” and “stock-id” properties are only mirorred if proxy widget has “use-action-appearance” property set to TRUE.

When the proxy is activated, it should activate its action.

Functions

ctk_action_new ()

CtkAction *
ctk_action_new (const gchar *name,
                const gchar *label,
                const gchar *tooltip,
                const gchar *stock_id);

Creates a new CtkAction object. To add the action to a CtkActionGroup and set the accelerator for the action, call ctk_action_group_add_action_with_accel(). See the UI Definition section for information on allowed action names.

Parameters

name

A unique name for the action

 

label

the label displayed in menu items and on buttons, or NULL.

[allow-none]

tooltip

a tooltip for the action, or NULL.

[allow-none]

stock_id

the stock icon to display in widgets representing the action, or NULL.

[allow-none]

Returns

a new CtkAction

Since: 2.4


ctk_action_get_name ()

const gchar *
ctk_action_get_name (CtkAction *action);

Returns the name of the action.

Parameters

action

the action object

 

Returns

the name of the action. The string belongs to CTK+ and should not be freed.

Since: 2.4


ctk_action_is_sensitive ()

gboolean
ctk_action_is_sensitive (CtkAction *action);

Returns whether the action is effectively sensitive.

Parameters

action

the action object

 

Returns

TRUE if the action and its associated action group are both sensitive.

Since: 2.4


ctk_action_get_sensitive ()

gboolean
ctk_action_get_sensitive (CtkAction *action);

Returns whether the action itself is sensitive. Note that this doesn’t necessarily mean effective sensitivity. See ctk_action_is_sensitive() for that.

Parameters

action

the action object

 

Returns

TRUE if the action itself is sensitive.

Since: 2.4


ctk_action_set_sensitive ()

void
ctk_action_set_sensitive (CtkAction *action,
                          gboolean sensitive);

Sets the :sensitive property of the action to sensitive . Note that this doesn’t necessarily mean effective sensitivity. See ctk_action_is_sensitive() for that.

Parameters

action

the action object

 

sensitive

TRUE to make the action sensitive

 

Since: 2.6


ctk_action_is_visible ()

gboolean
ctk_action_is_visible (CtkAction *action);

Returns whether the action is effectively visible.

Parameters

action

the action object

 

Returns

TRUE if the action and its associated action group are both visible.

Since: 2.4


ctk_action_get_visible ()

gboolean
ctk_action_get_visible (CtkAction *action);

Returns whether the action itself is visible. Note that this doesn’t necessarily mean effective visibility. See ctk_action_is_sensitive() for that.

Parameters

action

the action object

 

Returns

TRUE if the action itself is visible.

Since: 2.4


ctk_action_set_visible ()

void
ctk_action_set_visible (CtkAction *action,
                        gboolean visible);

Sets the :visible property of the action to visible . Note that this doesn’t necessarily mean effective visibility. See ctk_action_is_visible() for that.

Parameters

action

the action object

 

visible

TRUE to make the action visible

 

Since: 2.6


ctk_action_activate ()

void
ctk_action_activate (CtkAction *action);

Emits the “activate” signal on the specified action, if it isn't insensitive. This gets called by the proxy widgets when they get activated.

It can also be used to manually activate an action.

Parameters

action

the action object

 

Since: 2.4


ctk_action_create_icon ()

CtkWidget *
ctk_action_create_icon (CtkAction *action,
                        CtkIconSize icon_size);

This function is intended for use by action implementations to create icons displayed in the proxy widgets.

Parameters

action

the action object

 

icon_size

the size of the icon (CtkIconSize) that should be created.

[type int]

Returns

a widget that displays the icon for this action.

[transfer none]

Since: 2.4


ctk_action_create_menu_item ()

CtkWidget *
ctk_action_create_menu_item (CtkAction *action);

Creates a menu item widget that proxies for the given action.

Parameters

action

the action object

 

Returns

a menu item connected to the action.

[transfer none]

Since: 2.4


ctk_action_create_tool_item ()

CtkWidget *
ctk_action_create_tool_item (CtkAction *action);

Creates a toolbar item widget that proxies for the given action.

Parameters

action

the action object

 

Returns

a toolbar item connected to the action.

[transfer none]

Since: 2.4


ctk_action_create_menu ()

CtkWidget *
ctk_action_create_menu (CtkAction *action);

If action provides a CtkMenu widget as a submenu for the menu item or the toolbar item it creates, this function returns an instance of that menu.

Parameters

action

a CtkAction

 

Returns

the menu item provided by the action, or NULL.

[transfer none]

Since: 2.12


ctk_action_get_proxies ()

GSList *
ctk_action_get_proxies (CtkAction *action);

Returns the proxy widgets for an action. See also ctk_activatable_get_related_action().

Parameters

action

the action object

 

Returns

a GSList of proxy widgets. The list is owned by CTK+ and must not be modified.

[element-type CtkWidget][transfer none]

Since: 2.4


ctk_action_connect_accelerator ()

void
ctk_action_connect_accelerator (CtkAction *action);

Installs the accelerator for action if action has an accel path and group. See ctk_action_set_accel_path() and ctk_action_set_accel_group()

Since multiple proxies may independently trigger the installation of the accelerator, the action counts the number of times this function has been called and doesn’t remove the accelerator until ctk_action_disconnect_accelerator() has been called as many times.

Parameters

action

a CtkAction

 

Since: 2.4


ctk_action_disconnect_accelerator ()

void
ctk_action_disconnect_accelerator (CtkAction *action);

Undoes the effect of one call to ctk_action_connect_accelerator().

Parameters

action

a CtkAction

 

Since: 2.4


ctk_action_block_activate ()

void
ctk_action_block_activate (CtkAction *action);

Disable activation signals from the action

This is needed when updating the state of your proxy CtkActivatable widget could result in calling ctk_action_activate(), this is a convenience function to avoid recursing in those cases (updating toggle state for instance).

Parameters

action

a CtkAction

 

Since: 2.16


ctk_action_unblock_activate ()

void
ctk_action_unblock_activate (CtkAction *action);

Reenable activation signals from the action

Parameters

action

a CtkAction

 

Since: 2.16


ctk_action_get_always_show_image ()

gboolean
ctk_action_get_always_show_image (CtkAction *action);

Returns whether action 's menu item proxies will always show their image, if available.

Parameters

action

a CtkAction

 

Returns

TRUE if the menu item proxies will always show their image

Since: 2.20


ctk_action_set_always_show_image ()

void
ctk_action_set_always_show_image (CtkAction *action,
                                  gboolean always_show);

Sets whether action 's menu item proxies will ignore the “ctk-menu-images” setting and always show their image, if available.

Use this if the menu item would be useless or hard to use without their image.

Parameters

action

a CtkAction

 

always_show

TRUE if menuitem proxies should always show their image

 

Since: 2.20


ctk_action_get_accel_path ()

const gchar *
ctk_action_get_accel_path (CtkAction *action);

Returns the accel path for this action.

Parameters

action

the action object

 

Returns

the accel path for this action, or NULL if none is set. The returned string is owned by CTK+ and must not be freed or modified.

Since: 2.6


ctk_action_set_accel_path ()

void
ctk_action_set_accel_path (CtkAction *action,
                           const gchar *accel_path);

Sets the accel path for this action. All proxy widgets associated with the action will have this accel path, so that their accelerators are consistent.

Note that accel_path string will be stored in a GQuark. Therefore, if you pass a static string, you can save some memory by interning it first with g_intern_static_string().

Parameters

action

the action object

 

accel_path

the accelerator path

 

Since: 2.4


ctk_action_get_accel_closure ()

GClosure *
ctk_action_get_accel_closure (CtkAction *action);

Returns the accel closure for this action.

Parameters

action

the action object

 

Returns

the accel closure for this action. The returned closure is owned by CTK+ and must not be unreffed or modified.

[transfer none]

Since: 2.8


ctk_action_set_accel_group ()

void
ctk_action_set_accel_group (CtkAction *action,
                            CtkAccelGroup *accel_group);

Sets the CtkAccelGroup in which the accelerator for this action will be installed.

Parameters

action

the action object

 

accel_group

a CtkAccelGroup or NULL.

[allow-none]

Since: 2.4


ctk_action_set_label ()

void
ctk_action_set_label (CtkAction *action,
                      const gchar *label);

Sets the label of action .

Parameters

action

a CtkAction

 

label

the label text to set

 

Since: 2.16


ctk_action_get_label ()

const gchar *
ctk_action_get_label (CtkAction *action);

Gets the label text of action .

Parameters

action

a CtkAction

 

Returns

the label text

Since: 2.16


ctk_action_set_short_label ()

void
ctk_action_set_short_label (CtkAction *action,
                            const gchar *short_label);

Sets a shorter label text on action .

Parameters

action

a CtkAction

 

short_label

the label text to set

 

Since: 2.16


ctk_action_get_short_label ()

const gchar *
ctk_action_get_short_label (CtkAction *action);

Gets the short label text of action .

Parameters

action

a CtkAction

 

Returns

the short label text.

Since: 2.16


ctk_action_set_tooltip ()

void
ctk_action_set_tooltip (CtkAction *action,
                        const gchar *tooltip);

Sets the tooltip text on action

Parameters

action

a CtkAction

 

tooltip

the tooltip text

 

Since: 2.16


ctk_action_get_tooltip ()

const gchar *
ctk_action_get_tooltip (CtkAction *action);

Gets the tooltip text of action .

Parameters

action

a CtkAction

 

Returns

the tooltip text

Since: 2.16


ctk_action_set_stock_id ()

void
ctk_action_set_stock_id (CtkAction *action,
                         const gchar *stock_id);

Sets the stock id on action

Parameters

action

a CtkAction

 

stock_id

the stock id

 

Since: 2.16


ctk_action_get_stock_id ()

const gchar *
ctk_action_get_stock_id (CtkAction *action);

Gets the stock id of action .

Parameters

action

a CtkAction

 

Returns

the stock id

Since: 2.16


ctk_action_set_gicon ()

void
ctk_action_set_gicon (CtkAction *action,
                      GIcon *icon);

Sets the icon of action .

Parameters

action

a CtkAction

 

icon

the GIcon to set

 

Since: 2.16


ctk_action_get_gicon ()

GIcon *
ctk_action_get_gicon (CtkAction *action);

Gets the gicon of action .

Parameters

action

a CtkAction

 

Returns

The action’s GIcon if one is set.

[transfer none]

Since: 2.16


ctk_action_set_icon_name ()

void
ctk_action_set_icon_name (CtkAction *action,
                          const gchar *icon_name);

Sets the icon name on action

Parameters

action

a CtkAction

 

icon_name

the icon name to set

 

Since: 2.16


ctk_action_get_icon_name ()

const gchar *
ctk_action_get_icon_name (CtkAction *action);

Gets the icon name of action .

Parameters

action

a CtkAction

 

Returns

the icon name

Since: 2.16


ctk_action_set_visible_horizontal ()

void
ctk_action_set_visible_horizontal (CtkAction *action,
                                   gboolean visible_horizontal);

Sets whether action is visible when horizontal

Parameters

action

a CtkAction

 

visible_horizontal

whether the action is visible horizontally

 

Since: 2.16


ctk_action_get_visible_horizontal ()

gboolean
ctk_action_get_visible_horizontal (CtkAction *action);

Checks whether action is visible when horizontal

Parameters

action

a CtkAction

 

Returns

whether action is visible when horizontal

Since: 2.16


ctk_action_set_visible_vertical ()

void
ctk_action_set_visible_vertical (CtkAction *action,
                                 gboolean visible_vertical);

Sets whether action is visible when vertical

Parameters

action

a CtkAction

 

visible_vertical

whether the action is visible vertically

 

Since: 2.16


ctk_action_get_visible_vertical ()

gboolean
ctk_action_get_visible_vertical (CtkAction *action);

Checks whether action is visible when horizontal

Parameters

action

a CtkAction

 

Returns

whether action is visible when horizontal

Since: 2.16


ctk_action_set_is_important ()

void
ctk_action_set_is_important (CtkAction *action,
                             gboolean is_important);

Sets whether the action is important, this attribute is used primarily by toolbar items to decide whether to show a label or not.

Parameters

action

the action object

 

is_important

TRUE to make the action important

 

Since: 2.16


ctk_action_get_is_important ()

gboolean
ctk_action_get_is_important (CtkAction *action);

Checks whether action is important or not

Parameters

action

a CtkAction

 

Returns

whether action is important

Since: 2.16

Types and Values

struct CtkAction

struct CtkAction;

struct CtkActionClass

struct CtkActionClass {
  GObjectClass parent_class;

  /* activation signal */
  void       (* activate)           (CtkAction    *action);
};

Members

activate ()

Signal emitted when the action is activated.

 

Property Details

The “action-group” property

  “action-group”             CtkActionGroup *

The CtkActionGroup this CtkAction is associated with, or NULL (for internal use).

Owner: CtkAction

Flags: Read / Write


The “always-show-image” property

  “always-show-image”        gboolean

If TRUE, the action's menu item proxies will ignore the “ctk-menu-images” setting and always show their image, if available.

Use this property if the menu item would be useless or hard to use without their image.

Owner: CtkAction

Flags: Read / Write / Construct

Default value: FALSE

Since: 2.20


The “gicon” property

  “gicon”                    GIcon *

The GIcon displayed in the CtkAction.

Note that the stock icon is preferred, if the “stock-id” property holds the id of an existing stock icon.

This is an appearance property and thus only applies if “use-action-appearance” is TRUE.

Owner: CtkAction

Flags: Read / Write

Since: 2.16


The “hide-if-empty” property

  “hide-if-empty”            gboolean

When TRUE, empty menu proxies for this action are hidden.

Owner: CtkAction

Flags: Read / Write

Default value: TRUE


The “icon-name” property

  “icon-name”                char *

The name of the icon from the icon theme.

Note that the stock icon is preferred, if the “stock-id” property holds the id of an existing stock icon, and the GIcon is preferred if the “gicon” property is set.

This is an appearance property and thus only applies if “use-action-appearance” is TRUE.

Owner: CtkAction

Flags: Read / Write

Default value: NULL

Since: 2.10


The “is-important” property

  “is-important”             gboolean

Whether the action is considered important. When TRUE, toolitem proxies for this action show text in CTK_TOOLBAR_BOTH_HORIZ mode.

Owner: CtkAction

Flags: Read / Write

Default value: FALSE


The “label” property

  “label”                    char *

The label used for menu items and buttons that activate this action. If the label is NULL, CTK+ uses the stock label specified via the stock-id property.

This is an appearance property and thus only applies if “use-action-appearance” is TRUE.

Owner: CtkAction

Flags: Read / Write

Default value: NULL


The “name” property

  “name”                     char *

A unique name for the action.

Owner: CtkAction

Flags: Read / Write / Construct Only

Default value: NULL


The “sensitive” property

  “sensitive”                gboolean

Whether the action is enabled.

Owner: CtkAction

Flags: Read / Write

Default value: TRUE


The “short-label” property

  “short-label”              char *

A shorter label that may be used on toolbar buttons.

This is an appearance property and thus only applies if “use-action-appearance” is TRUE.

Owner: CtkAction

Flags: Read / Write

Default value: NULL


The “stock-id” property

  “stock-id”                 char *

The stock icon displayed in widgets representing this action.

This is an appearance property and thus only applies if “use-action-appearance” is TRUE.

Owner: CtkAction

Flags: Read / Write

Default value: NULL


The “tooltip” property

  “tooltip”                  char *

A tooltip for this action.

Owner: CtkAction

Flags: Read / Write

Default value: NULL


The “visible” property

  “visible”                  gboolean

Whether the action is visible.

Owner: CtkAction

Flags: Read / Write

Default value: TRUE


The “visible-horizontal” property

  “visible-horizontal”       gboolean

Whether the toolbar item is visible when the toolbar is in a horizontal orientation.

Owner: CtkAction

Flags: Read / Write

Default value: TRUE


The “visible-overflown” property

  “visible-overflown”        gboolean

When TRUE, toolitem proxies for this action are represented in the toolbar overflow menu.

Owner: CtkAction

Flags: Read / Write

Default value: TRUE

Since: 2.6


The “visible-vertical” property

  “visible-vertical”         gboolean

Whether the toolbar item is visible when the toolbar is in a vertical orientation.

Owner: CtkAction

Flags: Read / Write

Default value: TRUE

Signal Details

The “activate” signal

void
user_function (CtkAction *action,
               gpointer   user_data)

The "activate" signal is emitted when the action is activated.

Parameters

action

the CtkAction

 

user_data

user data set when the signal handler was connected.

 

Flags: No Recursion

Since: 2.4

See Also

CtkActionGroup, CtkUIManager, CtkActivatable