1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.ActionMapT;
26 
27 public  import gio.Action;
28 public  import gio.ActionIF;
29 public  import glib.Str;
30 public  import gobject.ObjectG;
31 public  import gtkc.gio;
32 public  import gtkc.giotypes;
33 
34 
35 /**
36  * The GActionMap interface is implemented by #GActionGroup
37  * implementations that operate by containing a number of
38  * named #GAction instances, such as #GSimpleActionGroup.
39  * 
40  * One useful application of this interface is to map the
41  * names of actions from various action groups to unique,
42  * prefixed names (e.g. by prepending "app." or "win.").
43  * This is the motivation for the 'Map' part of the interface
44  * name.
45  */
46 public template ActionMapT(TStruct)
47 {
48 	/** Get the main Gtk struct */
49 	public GActionMap* getActionMapStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return cast(GActionMap*)getStruct();
54 	}
55 
56 
57 	/**
58 	 * Adds an action to the @action_map.
59 	 *
60 	 * If the action map already contains an action with the same name
61 	 * as @action then the old action is dropped from the action map.
62 	 *
63 	 * The action map takes its own reference on @action.
64 	 *
65 	 * Params:
66 	 *     action = a #GAction
67 	 *
68 	 * Since: 2.32
69 	 */
70 	public void addAction(ActionIF action)
71 	{
72 		g_action_map_add_action(getActionMapStruct(), (action is null) ? null : action.getActionStruct());
73 	}
74 
75 	/**
76 	 * A convenience function for creating multiple #GSimpleAction instances
77 	 * and adding them to a #GActionMap.
78 	 *
79 	 * Each action is constructed as per one #GActionEntry.
80 	 *
81 	 * |[<!-- language="C" -->
82 	 * static void
83 	 * activate_quit (GSimpleAction *simple,
84 	 * GVariant      *parameter,
85 	 * gpointer       user_data)
86 	 * {
87 	 * exit (0);
88 	 * }
89 	 *
90 	 * static void
91 	 * activate_print_string (GSimpleAction *simple,
92 	 * GVariant      *parameter,
93 	 * gpointer       user_data)
94 	 * {
95 	 * g_print ("%s\n", g_variant_get_string (parameter, NULL));
96 	 * }
97 	 *
98 	 * static GActionGroup *
99 	 * create_action_group (void)
100 	 * {
101 	 * const GActionEntry entries[] = {
102 	 * { "quit",         activate_quit              },
103 	 * { "print-string", activate_print_string, "s" }
104 	 * };
105 	 * GSimpleActionGroup *group;
106 	 *
107 	 * group = g_simple_action_group_new ();
108 	 * g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), NULL);
109 	 *
110 	 * return G_ACTION_GROUP (group);
111 	 * }
112 	 * ]|
113 	 *
114 	 * Params:
115 	 *     entries = a pointer to
116 	 *         the first item in an array of #GActionEntry structs
117 	 *     nEntries = the length of @entries, or -1 if @entries is %NULL-terminated
118 	 *     userData = the user data for signal connections
119 	 *
120 	 * Since: 2.32
121 	 */
122 	public void addActionEntries(GActionEntry[] entries, void* userData)
123 	{
124 		g_action_map_add_action_entries(getActionMapStruct(), entries.ptr, cast(int)entries.length, userData);
125 	}
126 
127 	/**
128 	 * Looks up the action with the name @action_name in @action_map.
129 	 *
130 	 * If no such action exists, returns %NULL.
131 	 *
132 	 * Params:
133 	 *     actionName = the name of an action
134 	 *
135 	 * Returns: a #GAction, or %NULL
136 	 *
137 	 * Since: 2.32
138 	 */
139 	public ActionIF lookupAction(string actionName)
140 	{
141 		auto p = g_action_map_lookup_action(getActionMapStruct(), Str.toStringz(actionName));
142 		
143 		if(p is null)
144 		{
145 			return null;
146 		}
147 		
148 		return ObjectG.getDObject!(Action, ActionIF)(cast(GAction*) p);
149 	}
150 
151 	/**
152 	 * Removes the named action from the action map.
153 	 *
154 	 * If no action of this name is in the map then nothing happens.
155 	 *
156 	 * Params:
157 	 *     actionName = the name of the action
158 	 *
159 	 * Since: 2.32
160 	 */
161 	public void removeAction(string actionName)
162 	{
163 		g_action_map_remove_action(getActionMapStruct(), Str.toStringz(actionName));
164 	}
165 }