source: appstream-generator/build/girepo/gio/ActionMapT.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

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