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