Gio.MenuItem.set_action_and_target_value

### Method

# Gio MenuItemset_action_and_target_value

since: 2.32

#### Declaration [src]

    void
    g_menu_item_set_action_and_target_value (
      GMenuItem* menu_item,
      const gchar* action,
      GVariant* target_value
    )

#### Description [src]

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.

Available since: 2.32

#### Parameters

`action`

  Type: `const gchar*`

  The name of the action for this item.

  The argument can be `NULL`.
  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`target_value`

  Type: `GVariant`

  A `GVariant` to use as the action target.

  The argument can be `NULL`.
  The data is owned by the caller of the method.