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