Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GActionMap

[18:7] extends: object

GActionMap is an interface for action containers. The GActionMap interface is implemented by [iface@Gio.ActionGroup] implementations that operate by containing a number of named [iface@Gio.Action] instances, such as [class@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.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GActionMap (Handle = null)

    Creates a new ActionMap by wrapping a native handle or another wrapper.

    • @p Handle is the native handle or another wrapper whose handle to adopt.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • add_action (object action)

    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.

    • @p action is a [iface@Gio.Action].
    • @r None.
  • add_action_entries (list entries, user_data)

    A convenience function for creating multiple [class@Gio.SimpleAction] instances and adding them to a [iface@Gio.ActionMap]. Each action is constructed as per one [struct@Gio.ActionEntry]. c static void activate_quit (GSimpleAction *simple, GVariant *parameter, gpointer user_data) { exit (0); } static void activate_print_string (GSimpleAction *simple, GVariant *parameter, gpointer user_data) { g_print ("%s\n", g_variant_get_string (parameter, NULL)); } static GActionGroup * create_action_group (void) { const GActionEntry entries[] = { { "quit", activate_quit }, { "print-string", activate_print_string, "s" } }; GSimpleActionGroup *group; group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), NULL); return G_ACTION_GROUP (group); }

    • @p entries is a pointer to the first item in an array of [struct@Gio.ActionEntry] structs.
    • @p n_entries is the length of @entries, or -1 if @entries is NULL-terminated.
    • @p user_data is the user data for signal connections.
    • @r None.
  • lookup_action (string action_name)

    Looks up the action with the name @action_name in @action_map. If no such action exists, returns NULL.

    • @p action_name is the name of an action.
    • @r a [iface@Gio.Action].
  • remove_action (string action_name)

    Removes the named action from the action map. If no action of this name is in the map then nothing happens.

    • @p action_name is the name of the action.
    • @r None.
  • remove_action_entries (list entries)

    Remove actions from a [iface@Gio.ActionMap]. This is meant as the reverse of [method@Gio.ActionMap.add_action_entries]. c 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)); }

    • @p entries is a pointer to the first item in an array of [struct@Gio.ActionEntry] structs.
    • @p n_entries is the length of @entries, or -1 if @entries is NULL-terminated.
    • @r None.