:right-sidebar: True ActionMap =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.32 .. class:: ActionMap(*args, **kwargs) :no-contents-entry: Implementations: :class:`~gi.repository.Gio.Application`, :class:`~gi.repository.Gio.SimpleActionGroup` ``GActionMap`` is an interface for action containers. The ``GActionMap`` interface is implemented by :obj:`~gi.repository.Gio.ActionGroup` implementations that operate by containing a number of named :obj:`~gi.repository.Gio.Action` instances, such as :obj:`~gi.repository.Gio.SimpleActionGroup`. One useful application of this interface is to map the names of actions from various action groups to unique, prefixed names (e.g. by prepending "app." or "win."). This is the motivation for the 'Map' part of the interface name. Methods ------- .. rst-class:: interim-class .. class:: ActionMap :no-index: .. method:: add_action(action: ~gi.repository.Gio.Action) -> None Adds an action to the ``action_map``. If the action map already contains an action with the same name as ``action`` then the old action is dropped from the action map. The action map takes its own reference on ``action``. .. versionadded:: 2.32 :param action: a :obj:`~gi.repository.Gio.Action` .. method:: add_action_entries(entries, user_data=None) The add_action_entries() method is a convenience function for creating multiple Gio.SimpleAction instances and adding them to a Gio.ActionMap. Each action is constructed as per one entry. :param list entries: List of entry tuples for add_action() method. The entry tuple can vary in size with the following information: * The name of the action. Must be specified. * The callback to connect to the "activate" signal of the action. Since GLib 2.40, this can be None for stateful actions, in which case the default handler is used. For boolean-stated actions with no parameter, this is a toggle. For other state types (and parameter type equal to the state type) this will be a function that just calls change_state (which you should provide). * The type of the parameter that must be passed to the activate function for this action, given as a single GLib.Variant type string (or None for no parameter) * The initial state for this action, given in GLib.Variant text format. The state is parsed with no extra type information, so type tags must be added to the string if they are necessary. Stateless actions should give None here. * The callback to connect to the "change-state" signal of the action. All stateful actions should provide a handler here; stateless actions should not. :param user_data: The user data for signal connections, or None .. versionadded:: 2.32 .. method:: lookup_action(action_name: str) -> ~gi.repository.Gio.Action | None Looks up the action with the name ``action_name`` in ``action_map``. If no such action exists, returns :const:`None`. .. versionadded:: 2.32 :param action_name: the name of an action .. method:: remove_action(action_name: str) -> None Removes the named action from the action map. If no action of this name is in the map then nothing happens. .. versionadded:: 2.32 :param action_name: the name of the action .. method:: remove_action_entries(entries: ~typing.Sequence[~gi.repository.Gio.ActionEntry]) -> None Remove actions from a :obj:`~gi.repository.Gio.ActionMap`. This is meant as the reverse of :func:`~gi.repository.Gio.ActionMap.add_action_entries`. .. code-block:: C :dedent: static const GActionEntry entries[] = { { "quit", activate_quit }, { "print-string", activate_print_string, "s" } }; void add_actions (GActionMap *map) { g_action_map_add_action_entries (map, entries, G_N_ELEMENTS (entries), NULL); } void remove_actions (GActionMap *map) { g_action_map_remove_action_entries (map, entries, G_N_ELEMENTS (entries)); } .. versionadded:: 2.78 :param entries: a pointer to the first item in an array of :obj:`~gi.repository.Gio.ActionEntry` structs Virtual Methods --------------- .. rst-class:: interim-class .. class:: ActionMap :no-index: .. method:: do_add_action(action: ~gi.repository.Gio.Action) -> None Adds an action to the ``action_map``. If the action map already contains an action with the same name as ``action`` then the old action is dropped from the action map. The action map takes its own reference on ``action``. .. versionadded:: 2.32 :param action: a :obj:`~gi.repository.Gio.Action` .. method:: do_lookup_action(action_name: str) -> ~gi.repository.Gio.Action | None Looks up the action with the name ``action_name`` in ``action_map``. If no such action exists, returns :const:`None`. .. versionadded:: 2.32 :param action_name: the name of an action .. method:: do_remove_action(action_name: str) -> None Removes the named action from the action map. If no action of this name is in the map then nothing happens. .. versionadded:: 2.32 :param action_name: the name of the action