### Method

# Gio MenuItem set_action_and_target

since: 2.32

#### Declaration

    void
    g_menu_item_set_action_and_target (
      GMenuItem* menu_item,
      const gchar* action,
      const gchar* format_string,
      ...
    )

#### Description

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 `format_string` is ignored along with the positional parameters).

If `action` is non-`NULL` then the “action” attribute is set. `format_string` is then inspected. If it is non-`NULL` then the proper position parameters are collected to create a `GVariant` instance to use as the target value. If it is `NULL` then the positional parameters are ignored and the “target” attribute is unset.

See also `g_menu_item_set_action_and_target_value()` for an equivalent call that directly accepts a `GVariant`. See `g_menu_item_set_detailed_action()` for a more convenient version that works with string-typed targets.

See also `g_menu_item_set_action_and_target_value()` for a description of the semantics of the action and target attributes.

Available since: 2.32

This method is not directly available to language bindings.

#### 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.

`format_string`

  Type: `const gchar*`

  A GVariant format string.

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

`...`

  Type: ``

  Positional parameters, as per `format_string`.