setActionAndTargetValue

open fun setActionAndTargetValue(action: String? = null, targetValue: <Error class: unknown class>? = null)

Sets or unsets the "action" and "target" attributes of @menu_item.

If @action is null then both the "action" and "target" attributes are unset (and @target_value is ignored).

If @action is non-null then the "action" attribute is set. The "target" attribute is then set to the value of @target_value if it is non-null or unset otherwise.

Normal menu items (ie: not submenu, section or other custom item types) are expected to have the "action" attribute set to identify the action that they are associated with. The state type of the action help to determine the disposition of the menu item. See #GAction and #GActionGroup for an overview of actions.

In general, clicking on the menu item will result in activation of the named action with the "target" attribute given as the parameter to the action invocation. If the "target" attribute is not set then the action is invoked with no parameter.

If the action has no state then the menu item is usually drawn as a plain menu item (ie: with no additional decoration).

If the action has a boolean state then the menu item is usually drawn as a toggle menu item (ie: with a checkmark or equivalent indication). The item should be marked as 'toggled' or 'checked' when the boolean state is true.

If the action has a string state then the menu item is usually drawn as a radio menu item (ie: with a radio bullet or equivalent indication). The item should be marked as 'selected' when the string state is equal to the value of the @target property.

See g_menu_item_set_action_and_target() or g_menu_item_set_detailed_action() for two equivalent calls that are probably more convenient for most uses.

Since

2.32

Parameters

action

the name of the action for this item

targetValue

a #GVariant to use as the action target