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 gtk.AccelGroup;
26 
27 private import gdk.Display;
28 private import glib.ConstructionException;
29 private import glib.ListSG;
30 private import glib.Str;
31 private import gobject.Closure;
32 private import gobject.ObjectG;
33 private import gobject.Signals;
34 private import gtkc.gtk;
35 public  import gtkc.gtktypes;
36 private import std.algorithm;
37 
38 
39 /**
40  * A #GtkAccelGroup represents a group of keyboard accelerators,
41  * typically attached to a toplevel #GtkWindow (with
42  * gtk_window_add_accel_group()). Usually you won’t need to create a
43  * #GtkAccelGroup directly; instead, when using #GtkUIManager, GTK+
44  * automatically sets up the accelerators for your menus in the ui
45  * manager’s #GtkAccelGroup.
46  * 
47  * Note that “accelerators” are different from
48  * “mnemonics”. Accelerators are shortcuts for
49  * activating a menu item; they appear alongside the menu item they’re a
50  * shortcut for. For example “Ctrl+Q” might appear alongside the “Quit”
51  * menu item. Mnemonics are shortcuts for GUI elements such as text
52  * entries or buttons; they appear as underlined characters. See
53  * gtk_label_new_with_mnemonic(). Menu items can have both accelerators
54  * and mnemonics, of course.
55  */
56 public class AccelGroup : ObjectG
57 {
58 	/** the main Gtk struct */
59 	protected GtkAccelGroup* gtkAccelGroup;
60 
61 	/** Get the main Gtk struct */
62 	public GtkAccelGroup* getAccelGroupStruct()
63 	{
64 		return gtkAccelGroup;
65 	}
66 
67 	/** the main Gtk struct as a void* */
68 	protected override void* getStruct()
69 	{
70 		return cast(void*)gtkAccelGroup;
71 	}
72 
73 	protected override void setStruct(GObject* obj)
74 	{
75 		gtkAccelGroup = cast(GtkAccelGroup*)obj;
76 		super.setStruct(obj);
77 	}
78 
79 	/**
80 	 * Sets our main struct and passes it to the parent class.
81 	 */
82 	public this (GtkAccelGroup* gtkAccelGroup, bool ownedRef = false)
83 	{
84 		this.gtkAccelGroup = gtkAccelGroup;
85 		super(cast(GObject*)gtkAccelGroup, ownedRef);
86 	}
87 
88 
89 	/** */
90 	public static GType getType()
91 	{
92 		return gtk_accel_group_get_type();
93 	}
94 
95 	/**
96 	 * Creates a new #GtkAccelGroup.
97 	 *
98 	 * Returns: a new #GtkAccelGroup object
99 	 *
100 	 * Throws: ConstructionException GTK+ fails to create the object.
101 	 */
102 	public this()
103 	{
104 		auto p = gtk_accel_group_new();
105 		
106 		if(p is null)
107 		{
108 			throw new ConstructionException("null returned by new");
109 		}
110 		
111 		this(cast(GtkAccelGroup*) p, true);
112 	}
113 
114 	/**
115 	 * Finds the #GtkAccelGroup to which @closure is connected;
116 	 * see gtk_accel_group_connect().
117 	 *
118 	 * Params:
119 	 *     closure = a #GClosure
120 	 *
121 	 * Returns: the #GtkAccelGroup to which @closure
122 	 *     is connected, or %NULL
123 	 */
124 	public static AccelGroup fromAccelClosure(Closure closure)
125 	{
126 		auto p = gtk_accel_group_from_accel_closure((closure is null) ? null : closure.getClosureStruct());
127 		
128 		if(p is null)
129 		{
130 			return null;
131 		}
132 		
133 		return ObjectG.getDObject!(AccelGroup)(cast(GtkAccelGroup*) p);
134 	}
135 
136 	/**
137 	 * Finds the first accelerator in @accel_group that matches
138 	 * @accel_key and @accel_mods, and activates it.
139 	 *
140 	 * Params:
141 	 *     accelQuark = the quark for the accelerator name
142 	 *     acceleratable = the #GObject, usually a #GtkWindow, on which
143 	 *         to activate the accelerator
144 	 *     accelKey = accelerator keyval from a key event
145 	 *     accelMods = keyboard state mask from a key event
146 	 *
147 	 * Returns: %TRUE if an accelerator was activated and handled
148 	 *     this keypress
149 	 */
150 	public bool activate(GQuark accelQuark, ObjectG acceleratable, uint accelKey, GdkModifierType accelMods)
151 	{
152 		return gtk_accel_group_activate(gtkAccelGroup, accelQuark, (acceleratable is null) ? null : acceleratable.getObjectGStruct(), accelKey, accelMods) != 0;
153 	}
154 
155 	/**
156 	 * Installs an accelerator in this group. When @accel_group is being
157 	 * activated in response to a call to gtk_accel_groups_activate(),
158 	 * @closure will be invoked if the @accel_key and @accel_mods from
159 	 * gtk_accel_groups_activate() match those of this connection.
160 	 *
161 	 * The signature used for the @closure is that of #GtkAccelGroupActivate.
162 	 *
163 	 * Note that, due to implementation details, a single closure can
164 	 * only be connected to one accelerator group.
165 	 *
166 	 * Params:
167 	 *     accelKey = key value of the accelerator
168 	 *     accelMods = modifier combination of the accelerator
169 	 *     accelFlags = a flag mask to configure this accelerator
170 	 *     closure = closure to be executed upon accelerator activation
171 	 */
172 	public void connect(uint accelKey, GdkModifierType accelMods, GtkAccelFlags accelFlags, Closure closure)
173 	{
174 		gtk_accel_group_connect(gtkAccelGroup, accelKey, accelMods, accelFlags, (closure is null) ? null : closure.getClosureStruct());
175 	}
176 
177 	/**
178 	 * Installs an accelerator in this group, using an accelerator path
179 	 * to look up the appropriate key and modifiers (see
180 	 * gtk_accel_map_add_entry()). When @accel_group is being activated
181 	 * in response to a call to gtk_accel_groups_activate(), @closure will
182 	 * be invoked if the @accel_key and @accel_mods from
183 	 * gtk_accel_groups_activate() match the key and modifiers for the path.
184 	 *
185 	 * The signature used for the @closure is that of #GtkAccelGroupActivate.
186 	 *
187 	 * Note that @accel_path string will be stored in a #GQuark. Therefore,
188 	 * if you pass a static string, you can save some memory by interning it
189 	 * first with g_intern_static_string().
190 	 *
191 	 * Params:
192 	 *     accelPath = path used for determining key and modifiers
193 	 *     closure = closure to be executed upon accelerator activation
194 	 */
195 	public void connectByPath(string accelPath, Closure closure)
196 	{
197 		gtk_accel_group_connect_by_path(gtkAccelGroup, Str.toStringz(accelPath), (closure is null) ? null : closure.getClosureStruct());
198 	}
199 
200 	/**
201 	 * Removes an accelerator previously installed through
202 	 * gtk_accel_group_connect().
203 	 *
204 	 * Since 2.20 @closure can be %NULL.
205 	 *
206 	 * Params:
207 	 *     closure = the closure to remove from this accelerator
208 	 *         group, or %NULL to remove all closures
209 	 *
210 	 * Returns: %TRUE if the closure was found and got disconnected
211 	 */
212 	public bool disconnect(Closure closure)
213 	{
214 		return gtk_accel_group_disconnect(gtkAccelGroup, (closure is null) ? null : closure.getClosureStruct()) != 0;
215 	}
216 
217 	/**
218 	 * Removes an accelerator previously installed through
219 	 * gtk_accel_group_connect().
220 	 *
221 	 * Params:
222 	 *     accelKey = key value of the accelerator
223 	 *     accelMods = modifier combination of the accelerator
224 	 *
225 	 * Returns: %TRUE if there was an accelerator which could be
226 	 *     removed, %FALSE otherwise
227 	 */
228 	public bool disconnectKey(uint accelKey, GdkModifierType accelMods)
229 	{
230 		return gtk_accel_group_disconnect_key(gtkAccelGroup, accelKey, accelMods) != 0;
231 	}
232 
233 	/**
234 	 * Finds the first entry in an accelerator group for which
235 	 * @find_func returns %TRUE and returns its #GtkAccelKey.
236 	 *
237 	 * Params:
238 	 *     findFunc = a function to filter the entries
239 	 *         of @accel_group with
240 	 *     data = data to pass to @find_func
241 	 *
242 	 * Returns: the key of the first entry passing
243 	 *     @find_func. The key is owned by GTK+ and must not be freed.
244 	 */
245 	public GtkAccelKey* find(GtkAccelGroupFindFunc findFunc, void* data)
246 	{
247 		return gtk_accel_group_find(gtkAccelGroup, findFunc, data);
248 	}
249 
250 	/**
251 	 * Locks are added and removed using gtk_accel_group_lock() and
252 	 * gtk_accel_group_unlock().
253 	 *
254 	 * Returns: %TRUE if there are 1 or more locks on the @accel_group,
255 	 *     %FALSE otherwise.
256 	 *
257 	 * Since: 2.14
258 	 */
259 	public bool getIsLocked()
260 	{
261 		return gtk_accel_group_get_is_locked(gtkAccelGroup) != 0;
262 	}
263 
264 	/**
265 	 * Gets a #GdkModifierType representing the mask for this
266 	 * @accel_group. For example, #GDK_CONTROL_MASK, #GDK_SHIFT_MASK, etc.
267 	 *
268 	 * Returns: the modifier mask for this accel group.
269 	 *
270 	 * Since: 2.14
271 	 */
272 	public GdkModifierType getModifierMask()
273 	{
274 		return gtk_accel_group_get_modifier_mask(gtkAccelGroup);
275 	}
276 
277 	/**
278 	 * Locks the given accelerator group.
279 	 *
280 	 * Locking an acelerator group prevents the accelerators contained
281 	 * within it to be changed during runtime. Refer to
282 	 * gtk_accel_map_change_entry() about runtime accelerator changes.
283 	 *
284 	 * If called more than once, @accel_group remains locked until
285 	 * gtk_accel_group_unlock() has been called an equivalent number
286 	 * of times.
287 	 */
288 	public void lock()
289 	{
290 		gtk_accel_group_lock(gtkAccelGroup);
291 	}
292 
293 	/**
294 	 * Queries an accelerator group for all entries matching @accel_key
295 	 * and @accel_mods.
296 	 *
297 	 * Params:
298 	 *     accelKey = key value of the accelerator
299 	 *     accelMods = modifier combination of the accelerator
300 	 *
301 	 * Returns: an array of
302 	 *     @n_entries #GtkAccelGroupEntry elements, or %NULL. The array
303 	 *     is owned by GTK+ and must not be freed.
304 	 */
305 	public GtkAccelGroupEntry[] query(uint accelKey, GdkModifierType accelMods)
306 	{
307 		uint nEntries;
308 		
309 		auto p = gtk_accel_group_query(gtkAccelGroup, accelKey, accelMods, &nEntries);
310 		
311 		return p[0 .. nEntries];
312 	}
313 
314 	/**
315 	 * Undoes the last call to gtk_accel_group_lock() on this @accel_group.
316 	 */
317 	public void unlock()
318 	{
319 		gtk_accel_group_unlock(gtkAccelGroup);
320 	}
321 
322 	protected class OnAccelActivateDelegateWrapper
323 	{
324 		static OnAccelActivateDelegateWrapper[] listeners;
325 		bool delegate(ObjectG, uint, GdkModifierType, AccelGroup) dlg;
326 		gulong handlerId;
327 		
328 		this(bool delegate(ObjectG, uint, GdkModifierType, AccelGroup) dlg)
329 		{
330 			this.dlg = dlg;
331 			this.listeners ~= this;
332 		}
333 		
334 		void remove(OnAccelActivateDelegateWrapper source)
335 		{
336 			foreach(index, wrapper; listeners)
337 			{
338 				if (wrapper.handlerId == source.handlerId)
339 				{
340 					listeners[index] = null;
341 					listeners = std.algorithm.remove(listeners, index);
342 					break;
343 				}
344 			}
345 		}
346 	}
347 
348 	/**
349 	 * The accel-activate signal is an implementation detail of
350 	 * #GtkAccelGroup and not meant to be used by applications.
351 	 *
352 	 * Params:
353 	 *     acceleratable = the object on which the accelerator was activated
354 	 *     keyval = the accelerator keyval
355 	 *     modifier = the modifier combination of the accelerator
356 	 *
357 	 * Returns: %TRUE if the accelerator was activated
358 	 */
359 	gulong addOnAccelActivate(bool delegate(ObjectG, uint, GdkModifierType, AccelGroup) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
360 	{
361 		auto wrapper = new OnAccelActivateDelegateWrapper(dlg);
362 		wrapper.handlerId = Signals.connectData(
363 			this,
364 			"accel-activate",
365 			cast(GCallback)&callBackAccelActivate,
366 			cast(void*)wrapper,
367 			cast(GClosureNotify)&callBackAccelActivateDestroy,
368 			connectFlags);
369 		return wrapper.handlerId;
370 	}
371 	
372 	extern(C) static int callBackAccelActivate(GtkAccelGroup* accelgroupStruct, GObject* acceleratable, uint keyval, GdkModifierType modifier, OnAccelActivateDelegateWrapper wrapper)
373 	{
374 		return wrapper.dlg(ObjectG.getDObject!(ObjectG)(acceleratable), keyval, modifier, wrapper.outer);
375 	}
376 	
377 	extern(C) static void callBackAccelActivateDestroy(OnAccelActivateDelegateWrapper wrapper, GClosure* closure)
378 	{
379 		wrapper.remove(wrapper);
380 	}
381 
382 	protected class OnAccelChangedDelegateWrapper
383 	{
384 		static OnAccelChangedDelegateWrapper[] listeners;
385 		void delegate(uint, GdkModifierType, Closure, AccelGroup) dlg;
386 		gulong handlerId;
387 		
388 		this(void delegate(uint, GdkModifierType, Closure, AccelGroup) dlg)
389 		{
390 			this.dlg = dlg;
391 			this.listeners ~= this;
392 		}
393 		
394 		void remove(OnAccelChangedDelegateWrapper source)
395 		{
396 			foreach(index, wrapper; listeners)
397 			{
398 				if (wrapper.handlerId == source.handlerId)
399 				{
400 					listeners[index] = null;
401 					listeners = std.algorithm.remove(listeners, index);
402 					break;
403 				}
404 			}
405 		}
406 	}
407 
408 	/**
409 	 * The accel-changed signal is emitted when an entry
410 	 * is added to or removed from the accel group.
411 	 *
412 	 * Widgets like #GtkAccelLabel which display an associated
413 	 * accelerator should connect to this signal, and rebuild
414 	 * their visual representation if the @accel_closure is theirs.
415 	 *
416 	 * Params:
417 	 *     keyval = the accelerator keyval
418 	 *     modifier = the modifier combination of the accelerator
419 	 *     accelClosure = the #GClosure of the accelerator
420 	 */
421 	gulong addOnAccelChanged(void delegate(uint, GdkModifierType, Closure, AccelGroup) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
422 	{
423 		auto wrapper = new OnAccelChangedDelegateWrapper(dlg);
424 		wrapper.handlerId = Signals.connectData(
425 			this,
426 			"accel-changed",
427 			cast(GCallback)&callBackAccelChanged,
428 			cast(void*)wrapper,
429 			cast(GClosureNotify)&callBackAccelChangedDestroy,
430 			connectFlags);
431 		return wrapper.handlerId;
432 	}
433 	
434 	extern(C) static void callBackAccelChanged(GtkAccelGroup* accelgroupStruct, uint keyval, GdkModifierType modifier, GClosure* accelClosure, OnAccelChangedDelegateWrapper wrapper)
435 	{
436 		wrapper.dlg(keyval, modifier, ObjectG.getDObject!(Closure)(accelClosure), wrapper.outer);
437 	}
438 	
439 	extern(C) static void callBackAccelChangedDestroy(OnAccelChangedDelegateWrapper wrapper, GClosure* closure)
440 	{
441 		wrapper.remove(wrapper);
442 	}
443 
444 	/**
445 	 * Finds the first accelerator in any #GtkAccelGroup attached
446 	 * to @object that matches @accel_key and @accel_mods, and
447 	 * activates that accelerator.
448 	 *
449 	 * Params:
450 	 *     object = the #GObject, usually a #GtkWindow, on which
451 	 *         to activate the accelerator
452 	 *     accelKey = accelerator keyval from a key event
453 	 *     accelMods = keyboard state mask from a key event
454 	 *
455 	 * Returns: %TRUE if an accelerator was activated and handled
456 	 *     this keypress
457 	 */
458 	public static bool accelGroupsActivate(ObjectG object, uint accelKey, GdkModifierType accelMods)
459 	{
460 		return gtk_accel_groups_activate((object is null) ? null : object.getObjectGStruct(), accelKey, accelMods) != 0;
461 	}
462 
463 	/**
464 	 * Gets a list of all accel groups which are attached to @object.
465 	 *
466 	 * Params:
467 	 *     object = a #GObject, usually a #GtkWindow
468 	 *
469 	 * Returns: a list of
470 	 *     all accel groups which are attached to @object
471 	 */
472 	public static ListSG accelGroupsFromObject(ObjectG object)
473 	{
474 		auto p = gtk_accel_groups_from_object((object is null) ? null : object.getObjectGStruct());
475 		
476 		if(p is null)
477 		{
478 			return null;
479 		}
480 		
481 		return new ListSG(cast(GSList*) p);
482 	}
483 
484 	/**
485 	 * Gets the modifier mask.
486 	 *
487 	 * The modifier mask determines which modifiers are considered significant
488 	 * for keyboard accelerators. See gtk_accelerator_set_default_mod_mask().
489 	 *
490 	 * Returns: the default accelerator modifier mask
491 	 */
492 	public static GdkModifierType acceleratorGetDefaultModMask()
493 	{
494 		return gtk_accelerator_get_default_mod_mask();
495 	}
496 
497 	/**
498 	 * Converts an accelerator keyval and modifier mask into a string
499 	 * which can be used to represent the accelerator to the user.
500 	 *
501 	 * Params:
502 	 *     acceleratorKey = accelerator keyval
503 	 *     acceleratorMods = accelerator modifier mask
504 	 *
505 	 * Returns: a newly-allocated string representing the accelerator.
506 	 *
507 	 * Since: 2.6
508 	 */
509 	public static string acceleratorGetLabel(uint acceleratorKey, GdkModifierType acceleratorMods)
510 	{
511 		auto retStr = gtk_accelerator_get_label(acceleratorKey, acceleratorMods);
512 		
513 		scope(exit) Str.freeString(retStr);
514 		return Str.toString(retStr);
515 	}
516 
517 	/**
518 	 * Converts an accelerator keyval and modifier mask
519 	 * into a (possibly translated) string that can be displayed to
520 	 * a user, similarly to gtk_accelerator_get_label(), but handling
521 	 * keycodes.
522 	 *
523 	 * This is only useful for system-level components, applications
524 	 * should use gtk_accelerator_parse() instead.
525 	 *
526 	 * Params:
527 	 *     display = a #GdkDisplay or %NULL to use the default display
528 	 *     acceleratorKey = accelerator keyval
529 	 *     keycode = accelerator keycode
530 	 *     acceleratorMods = accelerator modifier mask
531 	 *
532 	 * Returns: a newly-allocated string representing the accelerator.
533 	 *
534 	 * Since: 3.4
535 	 */
536 	public static string acceleratorGetLabelWithKeycode(Display display, uint acceleratorKey, uint keycode, GdkModifierType acceleratorMods)
537 	{
538 		auto retStr = gtk_accelerator_get_label_with_keycode((display is null) ? null : display.getDisplayStruct(), acceleratorKey, keycode, acceleratorMods);
539 		
540 		scope(exit) Str.freeString(retStr);
541 		return Str.toString(retStr);
542 	}
543 
544 	/**
545 	 * Converts an accelerator keyval and modifier mask into a string
546 	 * parseable by gtk_accelerator_parse(). For example, if you pass in
547 	 * #GDK_KEY_q and #GDK_CONTROL_MASK, this function returns “<Control>q”.
548 	 *
549 	 * If you need to display accelerators in the user interface,
550 	 * see gtk_accelerator_get_label().
551 	 *
552 	 * Params:
553 	 *     acceleratorKey = accelerator keyval
554 	 *     acceleratorMods = accelerator modifier mask
555 	 *
556 	 * Returns: a newly-allocated accelerator name
557 	 */
558 	public static string acceleratorName(uint acceleratorKey, GdkModifierType acceleratorMods)
559 	{
560 		auto retStr = gtk_accelerator_name(acceleratorKey, acceleratorMods);
561 		
562 		scope(exit) Str.freeString(retStr);
563 		return Str.toString(retStr);
564 	}
565 
566 	/**
567 	 * Converts an accelerator keyval and modifier mask
568 	 * into a string parseable by gtk_accelerator_parse_with_keycode(),
569 	 * similarly to gtk_accelerator_name() but handling keycodes.
570 	 * This is only useful for system-level components, applications
571 	 * should use gtk_accelerator_parse() instead.
572 	 *
573 	 * Params:
574 	 *     display = a #GdkDisplay or %NULL to use the default display
575 	 *     acceleratorKey = accelerator keyval
576 	 *     keycode = accelerator keycode
577 	 *     acceleratorMods = accelerator modifier mask
578 	 *
579 	 * Returns: a newly allocated accelerator name.
580 	 *
581 	 * Since: 3.4
582 	 */
583 	public static string acceleratorNameWithKeycode(Display display, uint acceleratorKey, uint keycode, GdkModifierType acceleratorMods)
584 	{
585 		auto retStr = gtk_accelerator_name_with_keycode((display is null) ? null : display.getDisplayStruct(), acceleratorKey, keycode, acceleratorMods);
586 		
587 		scope(exit) Str.freeString(retStr);
588 		return Str.toString(retStr);
589 	}
590 
591 	/**
592 	 * Parses a string representing an accelerator. The format looks like
593 	 * “<Control>a” or “<Shift><Alt>F1” or “<Release>z” (the last one is
594 	 * for key release).
595 	 *
596 	 * The parser is fairly liberal and allows lower or upper case, and also
597 	 * abbreviations such as “<Ctl>” and “<Ctrl>”. Key names are parsed using
598 	 * gdk_keyval_from_name(). For character keys the name is not the symbol,
599 	 * but the lowercase name, e.g. one would use “<Ctrl>minus” instead of
600 	 * “<Ctrl>-”.
601 	 *
602 	 * If the parse fails, @accelerator_key and @accelerator_mods will
603 	 * be set to 0 (zero).
604 	 *
605 	 * Params:
606 	 *     accelerator = string representing an accelerator
607 	 *     acceleratorKey = return location for accelerator
608 	 *         keyval, or %NULL
609 	 *     acceleratorMods = return location for accelerator
610 	 *         modifier mask, %NULL
611 	 */
612 	public static void acceleratorParse(string accelerator, out uint acceleratorKey, out GdkModifierType acceleratorMods)
613 	{
614 		gtk_accelerator_parse(Str.toStringz(accelerator), &acceleratorKey, &acceleratorMods);
615 	}
616 
617 	/**
618 	 * Parses a string representing an accelerator, similarly to
619 	 * gtk_accelerator_parse() but handles keycodes as well. This is only
620 	 * useful for system-level components, applications should use
621 	 * gtk_accelerator_parse() instead.
622 	 *
623 	 * If @accelerator_codes is given and the result stored in it is non-%NULL,
624 	 * the result must be freed with g_free().
625 	 *
626 	 * If a keycode is present in the accelerator and no @accelerator_codes
627 	 * is given, the parse will fail.
628 	 *
629 	 * If the parse fails, @accelerator_key, @accelerator_mods and
630 	 * @accelerator_codes will be set to 0 (zero).
631 	 *
632 	 * Params:
633 	 *     accelerator = string representing an accelerator
634 	 *     acceleratorKey = return location for accelerator
635 	 *         keyval, or %NULL
636 	 *     acceleratorCodes = return location for accelerator keycodes, or %NULL
637 	 *     acceleratorMods = return location for accelerator
638 	 *         modifier mask, %NULL
639 	 *
640 	 * Since: 3.4
641 	 */
642 	public static void acceleratorParseWithKeycode(string accelerator, out uint acceleratorKey, out uint[] acceleratorCodes, out GdkModifierType acceleratorMods)
643 	{
644 		uint* outacceleratorCodes = null;
645 		
646 		gtk_accelerator_parse_with_keycode(Str.toStringz(accelerator), &acceleratorKey, &outacceleratorCodes, &acceleratorMods);
647 		
648 		acceleratorCodes = outacceleratorCodes[0 .. getArrayLength(outacceleratorCodes)];
649 	}
650 
651 	/**
652 	 * Sets the modifiers that will be considered significant for keyboard
653 	 * accelerators. The default mod mask depends on the GDK backend in use,
654 	 * but will typically include #GDK_CONTROL_MASK | #GDK_SHIFT_MASK |
655 	 * #GDK_MOD1_MASK | #GDK_SUPER_MASK | #GDK_HYPER_MASK | #GDK_META_MASK.
656 	 * In other words, Control, Shift, Alt, Super, Hyper and Meta. Other
657 	 * modifiers will by default be ignored by #GtkAccelGroup.
658 	 *
659 	 * You must include at least the three modifiers Control, Shift
660 	 * and Alt in any value you pass to this function.
661 	 *
662 	 * The default mod mask should be changed on application startup,
663 	 * before using any accelerator groups.
664 	 *
665 	 * Params:
666 	 *     defaultModMask = accelerator modifier mask
667 	 */
668 	public static void acceleratorSetDefaultModMask(GdkModifierType defaultModMask)
669 	{
670 		gtk_accelerator_set_default_mod_mask(defaultModMask);
671 	}
672 
673 	/**
674 	 * Determines whether a given keyval and modifier mask constitute
675 	 * a valid keyboard accelerator. For example, the #GDK_KEY_a keyval
676 	 * plus #GDK_CONTROL_MASK is valid - this is a “Ctrl+a” accelerator.
677 	 * But, you can't, for instance, use the #GDK_KEY_Control_L keyval
678 	 * as an accelerator.
679 	 *
680 	 * Params:
681 	 *     keyval = a GDK keyval
682 	 *     modifiers = modifier mask
683 	 *
684 	 * Returns: %TRUE if the accelerator is valid
685 	 */
686 	public static bool acceleratorValid(uint keyval, GdkModifierType modifiers)
687 	{
688 		return gtk_accelerator_valid(keyval, modifiers) != 0;
689 	}
690 }