diff options
Diffstat (limited to 'gio/gactionmap.c')
-rw-r--r-- | gio/gactionmap.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/gio/gactionmap.c b/gio/gactionmap.c index 1fb13e7af..60c5ed551 100644 --- a/gio/gactionmap.c +++ b/gio/gactionmap.c @@ -217,12 +217,10 @@ g_action_map_add_action_entries (GActionMap *action_map, gint n_entries, gpointer user_data) { - gint i; - g_return_if_fail (G_IS_ACTION_MAP (action_map)); g_return_if_fail (entries != NULL || n_entries == 0); - for (i = 0; n_entries == -1 ? entries[i].name != NULL : i < n_entries; i++) + for (int i = 0; n_entries < 0 ? entries[i].name != NULL : i < n_entries; i++) { const GActionEntry *entry = &entries[i]; const GVariantType *parameter_type; @@ -285,3 +283,47 @@ g_action_map_add_action_entries (GActionMap *action_map, g_object_unref (action); } } + +/** + * g_action_map_remove_action_entries: + * @action_map: The #GActionMap + * @entries: (array length=n_entries) (element-type GActionEntry): a pointer to + * the first item in an array of #GActionEntry structs + * @n_entries: the length of @entries, or -1 if @entries is %NULL-terminated + * + * Remove actions from a #GActionMap. This is meant as the reverse of + * g_action_map_add_action_entries(). + * + * + * |[<!-- language="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)); + * } + * ]| + * + * Since: 2.78 + */ +void +g_action_map_remove_action_entries (GActionMap *action_map, + const GActionEntry entries[], + gint n_entries) +{ + g_return_if_fail (G_IS_ACTION_MAP (action_map)); + g_return_if_fail (entries != NULL || n_entries == 0); + + for (int i = 0; n_entries < 0 ? entries[i].name != NULL : i < n_entries; i++) + g_action_map_remove_action (action_map, entries[i].name); +} |