| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | /*
 | 
					
						
							|  |  |  |  |  * Copyright © 2010 Codethink Limited | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2022-05-18 09:12:45 +01:00
										 |  |  |  |  * SPDX-License-Identifier: LGPL-2.1-or-later | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-05-27 18:21:30 +02:00
										 |  |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * This library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * You should have received a copy of the GNU Lesser General | 
					
						
							| 
									
										
										
										
											2014-01-23 12:58:29 +01:00
										 |  |  |  |  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * Authors: Ryan Lortie <desrt@desrt.ca> | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #include "config.h"
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #include "gsimpleaction.h"
 | 
					
						
							|  |  |  |  | #include "gactionmap.h"
 | 
					
						
							|  |  |  |  | #include "gaction.h"
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2023-09-25 20:47:08 -04:00
										 |  |  |  |  * GActionMap: | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * `GActionMap` is an interface for action containers. | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2023-10-23 11:17:24 +01:00
										 |  |  |  |  * The `GActionMap` interface is implemented by [iface@Gio.ActionGroup] | 
					
						
							| 
									
										
										
										
											2023-09-25 20:47:08 -04:00
										 |  |  |  |  * implementations that operate by containing a number of named | 
					
						
							| 
									
										
										
										
											2023-10-23 11:17:24 +01:00
										 |  |  |  |  * [iface@Gio.Action] instances, such as [class@Gio.SimpleActionGroup]. | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * 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."). | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * This is the motivation for the ‘Map’ part of the interface | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * name. | 
					
						
							| 
									
										
										
										
											2011-12-10 17:21:53 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * Since: 2.32 | 
					
						
							| 
									
										
										
										
											2023-09-25 20:47:08 -04:00
										 |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-02-05 16:20:43 +01:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-10 17:21:53 -05:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * GActionMapInterface: | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * @lookup_action: the virtual function pointer for | 
					
						
							|  |  |  |  |  *   [method@Gio.ActionMap.lookup_action] | 
					
						
							|  |  |  |  |  * @add_action: the virtual function pointer for | 
					
						
							|  |  |  |  |  *   [method@Gio.ActionMap.add_action] | 
					
						
							|  |  |  |  |  * @remove_action: the virtual function pointer for | 
					
						
							|  |  |  |  |  *   [method@Gio.ActionMap.remove_action] | 
					
						
							| 
									
										
										
										
											2011-12-10 17:21:53 -05:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * The virtual function table for [iface@Gio.ActionMap]. | 
					
						
							| 
									
										
										
										
											2011-12-10 17:21:53 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * Since: 2.32 | 
					
						
							|  |  |  |  |  **/ | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-20 18:58:14 -04:00
										 |  |  |  | G_DEFINE_INTERFACE (GActionMap, g_action_map, G_TYPE_OBJECT) | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | static void | 
					
						
							|  |  |  |  | g_action_map_default_init (GActionMapInterface *iface) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_action_map_lookup_action: | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * @action_map: an action map | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * @action_name: the name of an action | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Looks up the action with the name @action_name in @action_map. | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * If no such action exists, returns `NULL`. | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * Returns: (nullable) (transfer none): a [iface@Gio.Action] | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * Since: 2.32 | 
					
						
							|  |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | GAction * | 
					
						
							|  |  |  |  | g_action_map_lookup_action (GActionMap  *action_map, | 
					
						
							|  |  |  |  |                             const gchar *action_name) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   return G_ACTION_MAP_GET_IFACE (action_map) | 
					
						
							|  |  |  |  |     ->lookup_action (action_map, action_name); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_action_map_add_action: | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * @action_map: an action map | 
					
						
							|  |  |  |  |  * @action: a [iface@Gio.Action] | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * 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. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Since: 2.32 | 
					
						
							|  |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | void | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  | g_action_map_add_action (GActionMap *action_map, | 
					
						
							|  |  |  |  |                          GAction    *action) | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-06 20:41:19 -04:00
										 |  |  |  |   G_ACTION_MAP_GET_IFACE (action_map)->add_action (action_map, action); | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_action_map_remove_action: | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * @action_map: an action map | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * @action_name: the name of the action | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Removes the named action from the action map. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * If no action of this name is in the map then nothing happens. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Since: 2.32 | 
					
						
							|  |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | void | 
					
						
							|  |  |  |  | g_action_map_remove_action (GActionMap  *action_map, | 
					
						
							|  |  |  |  |                             const gchar *action_name) | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-06 20:41:19 -04:00
										 |  |  |  |   G_ACTION_MAP_GET_IFACE (action_map)->remove_action (action_map, action_name); | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * GActionEntry: | 
					
						
							|  |  |  |  |  * @name: the name of the action | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * @activate: the callback to connect to the "activate" signal of the action. | 
					
						
							|  |  |  |  |  *   Since GLib 2.40, this can be `NULL` 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). | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * @parameter_type: the type of the parameter that must be passed to the | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  *   activate function for this action, given as a single GVariant type string | 
					
						
							|  |  |  |  |  *   (or `NULL` for no parameter) | 
					
						
							| 
									
										
										
										
											2014-06-29 11:34:16 -04:00
										 |  |  |  |  * @state: the initial state for this action, given in | 
					
						
							| 
									
										
										
										
											2025-02-20 12:13:42 +00:00
										 |  |  |  |  *   [GVariant text format](../glib/gvariant-text-format.html).  The state is parsed | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  *   with no extra type information, so type tags must be added to the string | 
					
						
							|  |  |  |  |  *   if they are necessary.  Stateless actions should give `NULL` here. | 
					
						
							|  |  |  |  |  * @change_state: the callback to connect to the "change-state" signal of the | 
					
						
							|  |  |  |  |  *   action.  All stateful actions should provide a handler here; stateless | 
					
						
							|  |  |  |  |  *   actions should not. | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * This struct defines a single action.  It is for use with | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * [method@Gio.ActionMap.add_action_entries]. | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * The order of the items in the structure are intended to reflect | 
					
						
							|  |  |  |  |  * frequency of use.  It is permissible to use an incomplete initialiser | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * in order to leave some of the later values as `NULL`.  All values | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * after @name are optional.  Additional optional fields may be added in | 
					
						
							|  |  |  |  |  * the future. | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * See [method@Gio.ActionMap.add_action_entries] for an example. | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  **/ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_action_map_add_action_entries: | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * @action_map: an action map | 
					
						
							| 
									
										
										
										
											2013-01-13 20:49:15 +01:00
										 |  |  |  |  * @entries: (array length=n_entries) (element-type GActionEntry): a pointer to | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  *   the first item in an array of [struct@Gio.ActionEntry] structs | 
					
						
							|  |  |  |  |  * @n_entries: the length of @entries, or -1 if @entries is `NULL`-terminated | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * @user_data: the user data for signal connections | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * A convenience function for creating multiple [class@Gio.SimpleAction] | 
					
						
							|  |  |  |  |  * instances and adding them to a [iface@Gio.ActionMap]. | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * Each action is constructed as per one [struct@Gio.ActionEntry]. | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * ```c | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * 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); | 
					
						
							|  |  |  |  |  * } | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * ``` | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-11-30 19:03:41 -05:00
										 |  |  |  |  * Since: 2.32 | 
					
						
							|  |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  | void | 
					
						
							|  |  |  |  | g_action_map_add_action_entries (GActionMap         *action_map, | 
					
						
							|  |  |  |  |                                  const GActionEntry *entries, | 
					
						
							|  |  |  |  |                                  gint                n_entries, | 
					
						
							|  |  |  |  |                                  gpointer            user_data) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   g_return_if_fail (G_IS_ACTION_MAP (action_map)); | 
					
						
							|  |  |  |  |   g_return_if_fail (entries != NULL || n_entries == 0); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-24 16:00:30 +02:00
										 |  |  |  |   for (int i = 0; n_entries < 0 ? entries[i].name != NULL : i < n_entries; i++) | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |     { | 
					
						
							|  |  |  |  |       const GActionEntry *entry = &entries[i]; | 
					
						
							|  |  |  |  |       const GVariantType *parameter_type; | 
					
						
							|  |  |  |  |       GSimpleAction *action; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       if (entry->parameter_type) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |           if (!g_variant_type_string_is_valid (entry->parameter_type)) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2012-04-04 06:36:45 -04:00
										 |  |  |  |               g_critical ("g_action_map_add_entries: the type " | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |                           "string '%s' given as the parameter type for " | 
					
						
							|  |  |  |  |                           "action '%s' is not a valid GVariant type " | 
					
						
							|  |  |  |  |                           "string.  This action will not be added.", | 
					
						
							|  |  |  |  |                           entry->parameter_type, entry->name); | 
					
						
							|  |  |  |  |               return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |           parameter_type = G_VARIANT_TYPE (entry->parameter_type); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |       else | 
					
						
							|  |  |  |  |         parameter_type = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       if (entry->state) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |           GError *error = NULL; | 
					
						
							|  |  |  |  |           GVariant *state; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |           state = g_variant_parse (NULL, entry->state, NULL, NULL, &error); | 
					
						
							|  |  |  |  |           if (state == NULL) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2012-04-04 06:36:45 -04:00
										 |  |  |  |               g_critical ("g_action_map_add_entries: GVariant could " | 
					
						
							| 
									
										
										
										
											2011-11-30 11:36:08 -05:00
										 |  |  |  |                           "not parse the state value given for action '%s' " | 
					
						
							|  |  |  |  |                           "('%s'): %s.  This action will not be added.", | 
					
						
							|  |  |  |  |                           entry->name, entry->state, error->message); | 
					
						
							|  |  |  |  |               g_error_free (error); | 
					
						
							|  |  |  |  |               continue; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |           action = g_simple_action_new_stateful (entry->name, | 
					
						
							|  |  |  |  |                                                  parameter_type, | 
					
						
							|  |  |  |  |                                                  state); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |           g_variant_unref (state); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |       else | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |           action = g_simple_action_new (entry->name, | 
					
						
							|  |  |  |  |                                         parameter_type); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       if (entry->activate != NULL) | 
					
						
							|  |  |  |  |         g_signal_connect (action, "activate", | 
					
						
							|  |  |  |  |                           G_CALLBACK (entry->activate), user_data); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       if (entry->change_state != NULL) | 
					
						
							|  |  |  |  |         g_signal_connect (action, "change-state", | 
					
						
							|  |  |  |  |                           G_CALLBACK (entry->change_state), user_data); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       g_action_map_add_action (action_map, G_ACTION (action)); | 
					
						
							|  |  |  |  |       g_object_unref (action); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-05-24 16:00:30 +02:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * g_action_map_remove_action_entries: | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * @action_map: The [iface@Gio.ActionMap] | 
					
						
							| 
									
										
										
										
											2023-05-24 16:00:30 +02:00
										 |  |  |  |  * @entries: (array length=n_entries) (element-type GActionEntry): a pointer to | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  *   the first item in an array of [struct@Gio.ActionEntry] structs | 
					
						
							|  |  |  |  |  * @n_entries: the length of @entries, or -1 if @entries is `NULL`-terminated | 
					
						
							| 
									
										
										
										
											2023-05-24 16:00:30 +02:00
										 |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * Remove actions from a [iface@Gio.ActionMap]. This is meant as the reverse of | 
					
						
							|  |  |  |  |  * [method@Gio.ActionMap.add_action_entries]. | 
					
						
							| 
									
										
										
										
											2023-05-24 16:00:30 +02:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * ```c | 
					
						
							| 
									
										
										
										
											2023-05-24 16:00:30 +02:00
										 |  |  |  |  * 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)); | 
					
						
							|  |  |  |  |  * } | 
					
						
							| 
									
										
										
										
											2024-05-30 16:11:37 +02:00
										 |  |  |  |  * ``` | 
					
						
							| 
									
										
										
										
											2023-05-24 16:00:30 +02:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * 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); | 
					
						
							|  |  |  |  | } |