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  * Conversion parameters:
26  * inFile  = GAction.html
27  * outPack = gio
28  * outFile = ActionT
29  * strct   = GAction
30  * realStrct=
31  * ctorStrct=
32  * clss    = ActionT
33  * interf  = ActionIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- g_action_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.Variant
49  * 	- glib.VariantType
50  * structWrap:
51  * 	- GVariant* -> Variant
52  * 	- GVariantType* -> VariantType
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gio.ActionT;
59 
60 public  import gtkc.giotypes;
61 
62 public import gtkc.gio;
63 public import glib.ConstructionException;
64 public import gobject.ObjectG;
65 
66 
67 public import glib.Str;
68 public import glib.Variant;
69 public import glib.VariantType;
70 
71 
72 
73 
74 /**
75  * Description
76  * GAction represents a single named action.
77  * The main interface to an action is that it can be activated with
78  * g_action_activate(). This results in the 'activate' signal being
79  * emitted. An activation has a GVariant parameter (which may be
80  * NULL). The correct type for the parameter is determined by a static
81  * parameter type (which is given at construction time).
82  * An action may optionally have a state, in which case the state may be
83  * set with g_action_set_state(). This call takes a GVariant. The
84  * correct type for the state is determined by a static state type
85  * (which is given at construction time).
86  * The state may have a hint associated with it, specifying its valid
87  * range.
88  * GAction is merely the interface to the concept of an action, as
89  * described above. Various implementations of actions exist, including
90  * GSimpleAction and GtkAction.
91  * In all cases, the implementing class is responsible for storing the
92  * name of the action, the parameter type, the enabled state, the
93  * optional state type and the state and emitting the appropriate
94  * signals when these change. The implementor responsible for filtering
95  * calls to g_action_activate() and g_action_set_state() for type safety
96  * and for the state being enabled.
97  * Probably the only useful thing to do with a GAction is to put it
98  * inside of a GSimpleActionGroup.
99  */
100 public template ActionT(TStruct)
101 {
102 	
103 	/** the main Gtk struct */
104 	protected GAction* gAction;
105 	
106 	
107 	public GAction* getActionTStruct()
108 	{
109 		return cast(GAction*)getStruct();
110 	}
111 	
112 	
113 	/**
114 	 */
115 	
116 	/**
117 	 * Queries the name of action.
118 	 * Since 2.28
119 	 * Returns: the name of the action
120 	 */
121 	public string getName()
122 	{
123 		// const gchar * g_action_get_name (GAction *action);
124 		return Str.toString(g_action_get_name(getActionTStruct()));
125 	}
126 	
127 	/**
128 	 * Queries the type of the parameter that must be given when activating
129 	 * action.
130 	 * When activating the action using g_action_activate(), the GVariant
131 	 * given to that function must be of the type returned by this function.
132 	 * In the case that this function returns NULL, you must not give any
133 	 * GVariant, but NULL instead.
134 	 * Since 2.28
135 	 * Returns: the parameter type. [allow-none]
136 	 */
137 	public VariantType getParameterType()
138 	{
139 		// const GVariantType * g_action_get_parameter_type (GAction *action);
140 		auto p = g_action_get_parameter_type(getActionTStruct());
141 		
142 		if(p is null)
143 		{
144 			return null;
145 		}
146 		
147 		return ObjectG.getDObject!(VariantType)(cast(GVariantType*) p);
148 	}
149 	
150 	/**
151 	 * Queries the type of the state of action.
152 	 * If the action is stateful (ie: was created with
153 	 * g_action_new_stateful()) then this function returns the GVariantType
154 	 * of the state. This is the type of the initial value given as the
155 	 * state. All calls to g_action_set_state() must give a GVariant of
156 	 * this type and g_action_get_state() will return a GVariant of the
157 	 * same type.
158 	 * If the action is not stateful (ie: created with g_action_new()) then
159 	 * this function will return NULL. In that case, g_action_get_state()
160 	 * will return NULL and you must not call g_action_set_state().
161 	 * Since 2.28
162 	 * Returns: the state type, if the action is stateful. [allow-none]
163 	 */
164 	public VariantType getStateType()
165 	{
166 		// const GVariantType * g_action_get_state_type (GAction *action);
167 		auto p = g_action_get_state_type(getActionTStruct());
168 		
169 		if(p is null)
170 		{
171 			return null;
172 		}
173 		
174 		return ObjectG.getDObject!(VariantType)(cast(GVariantType*) p);
175 	}
176 	
177 	/**
178 	 * Requests a hint about the valid range of values for the state of
179 	 * action.
180 	 * If NULL is returned it either means that the action is not stateful
181 	 * or that there is no hint about the valid range of values for the
182 	 * state of the action.
183 	 * If a GVariant array is returned then each item in the array is a
184 	 * possible value for the state. If a GVariant pair (ie: two-tuple) is
185 	 * returned then the tuple specifies the inclusive lower and upper bound
186 	 * of valid values for the state.
187 	 * In any case, the information is merely a hint. It may be possible to
188 	 * have a state value outside of the hinted range and setting a value
189 	 * within the range may fail.
190 	 * The return value (if non-NULL) should be freed with
191 	 * g_variant_unref() when it is no longer required.
192 	 * Since 2.28
193 	 * Returns: the state range hint. [transfer full]
194 	 */
195 	public Variant getStateHint()
196 	{
197 		// GVariant * g_action_get_state_hint (GAction *action);
198 		auto p = g_action_get_state_hint(getActionTStruct());
199 		
200 		if(p is null)
201 		{
202 			return null;
203 		}
204 		
205 		return ObjectG.getDObject!(Variant)(cast(GVariant*) p);
206 	}
207 	
208 	/**
209 	 * Checks if action is currently enabled.
210 	 * An action must be enabled in order to be activated or in order to
211 	 * have its state changed from outside callers.
212 	 * Since 2.28
213 	 * Returns: whether the action is enabled
214 	 */
215 	public int getEnabled()
216 	{
217 		// gboolean g_action_get_enabled (GAction *action);
218 		return g_action_get_enabled(getActionTStruct());
219 	}
220 	
221 	/**
222 	 * Queries the current state of action.
223 	 * If the action is not stateful then NULL will be returned. If the
224 	 * action is stateful then the type of the return value is the type
225 	 * given by g_action_get_state_type().
226 	 * The return value (if non-NULL) should be freed with
227 	 * g_variant_unref() when it is no longer required.
228 	 * Since 2.28
229 	 * Returns: the current state of the action. [transfer full]
230 	 */
231 	public Variant getState()
232 	{
233 		// GVariant * g_action_get_state (GAction *action);
234 		auto p = g_action_get_state(getActionTStruct());
235 		
236 		if(p is null)
237 		{
238 			return null;
239 		}
240 		
241 		return ObjectG.getDObject!(Variant)(cast(GVariant*) p);
242 	}
243 	
244 	/**
245 	 * Request for the state of action to be changed to value.
246 	 * The action must be stateful and value must be of the correct type.
247 	 * See g_action_get_state_type().
248 	 * This call merely requests a change. The action may refuse to change
249 	 * its state or may change its state to something other than value.
250 	 * See g_action_get_state_hint().
251 	 * If the value GVariant is floating, it is consumed.
252 	 * Since 2.28
253 	 * Params:
254 	 * value = the new state
255 	 */
256 	public void setState(Variant value)
257 	{
258 		// void g_action_set_state (GAction *action,  GVariant *value);
259 		g_action_set_state(getActionTStruct(), (value is null) ? null : value.getVariantStruct());
260 	}
261 	
262 	/**
263 	 * Activates the action.
264 	 * Since 2.28
265 	 * Params:
266 	 * parameter = the parameter to the activation. [allow-none]
267 	 */
268 	public void activate(Variant parameter)
269 	{
270 		// void g_action_activate (GAction *action,  GVariant *parameter);
271 		g_action_activate(getActionTStruct(), (parameter is null) ? null : parameter.getVariantStruct());
272 	}
273 }