Package: gio

Function g-menu-item-set-action-and-target-value

Lambda List

g-menu-item-set-action-and-target-value (item action value)

Arguments

item -- a g-menu-item object
action -- a string with the name of the action for this menu item
value -- a g-variant instance to use as the action target

Details

Sets or unsets the "action" and "target" attributes of the menu item.

If action is nil then both the "action" and "target" attributes are unset, and value is ignored.

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

Normal menu items, i.e. 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 teh g-action and g-action-group documentation 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, i.e. with no additional decoration.

If the action has a boolean state then the menu item is usually drawn as a toggle menu item, i.e. 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, i.e. 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 the functions 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.
 

See also

2021-8-16