I've no idea here...
[gtkD.git] / src / gtk / AccelGroup.d
blob049fdb5f40bfb41fd6d05c82e965dbc5ac2dd8ed
1 /*
2 * This file is part of duit.
4 * duit 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 2.1 of the License, or
7 * (at your option) any later version.
9 * duit 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.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gtk-Keyboard-Accelerators.html
26 * outPack = gtk
27 * outFile = AccelGroup
28 * strct = GtkAccelGroup
29 * realStrct=
30 * ctorStrct=
31 * clss = AccelGroup
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_accel_group_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gobject.Closure
47 * - gobject.ObjectG
48 * - gtk.AccelGroup
49 * - glib.ListSG
50 * structWrap:
51 * - GClosure* -> Closure
52 * - GObject* -> ObjectG
53 * - GSList* -> ListSG
54 * - GtkAccelGroup* -> AccelGroup
55 * local aliases:
58 module gtk.AccelGroup;
60 private import gtk.gtktypes;
62 private import lib.gtk;
64 private import glib.Str;
65 private import gobject.Closure;
66 private import gobject.ObjectG;
67 private import gtk.AccelGroup;
68 private import glib.ListSG;
70 /**
71 * Description
72 * A GtkAccelGroup represents a group of keyboard accelerators,
73 * typically attached to a toplevel GtkWindow (with
74 * gtk_window_add_accel_group()). Usually you won't need to create a
75 * GtkAccelGroup directly; instead, when using GtkItemFactory, GTK+
76 * automatically sets up the accelerators for your menus in the item
77 * factory's GtkAccelGroup.
78 * Note that accelerators are different from
79 * mnemonics. Accelerators are shortcuts for
80 * activating a menu item; they appear alongside the menu item they're a
81 * shortcut for. For example "Ctrl+Q" might appear alongside the "Quit"
82 * menu item. Mnemonics are shortcuts for GUI elements such as text
83 * entries or buttons; they appear as underlined characters. See
84 * gtk_label_new_with_mnemonic(). Menu items can have both accelerators
85 * and mnemonics, of course.
87 private import gobject.ObjectG;
88 public class AccelGroup : ObjectG
91 /** the main Gtk struct */
92 protected GtkAccelGroup* gtkAccelGroup;
95 public GtkAccelGroup* getAccelGroupStruct()
97 return gtkAccelGroup;
101 /** the main Gtk struct as a void* */
102 protected void* getStruct()
104 return cast(void*)gtkAccelGroup;
108 * Sets our main struct and passes it to the parent class
110 public this (GtkAccelGroup* gtkAccelGroup)
112 super(cast(GObject*)gtkAccelGroup);
113 this.gtkAccelGroup = gtkAccelGroup;
119 // imports for the signal processing
120 private import gobject.Signals;
121 private import gdk.gdktypes;
122 int[char[]] connectedSignals;
124 gboolean delegate(ObjectG, guint, GdkModifierType, AccelGroup)[] onAccelActivateListeners;
125 void addOnAccelActivate(gboolean delegate(ObjectG, guint, GdkModifierType, AccelGroup) dlg)
127 if ( !("accel-activate" in connectedSignals) )
129 Signals.connectData(
130 getStruct(),
131 "accel-activate",
132 cast(GCallback)&callBackAccelActivate,
133 this,
134 null,
135 cast(ConnectFlags)0);
136 connectedSignals["accel-activate"] = 1;
138 onAccelActivateListeners ~= dlg;
140 extern(C) static void callBackAccelActivate(GtkAccelGroup* accelGroupStruct, GObject* acceleratable, guint keyval, GdkModifierType modifier, AccelGroup accelGroup)
142 bit consumed = false;
144 foreach ( gboolean delegate(ObjectG, guint, GdkModifierType, AccelGroup) dlg ; accelGroup.onAccelActivateListeners )
146 dlg(new ObjectG(acceleratable), keyval, modifier, accelGroup);
149 return consumed;
152 void delegate(guint, GdkModifierType, Closure, AccelGroup)[] onAccelChangedListeners;
153 void addOnAccelChanged(void delegate(guint, GdkModifierType, Closure, AccelGroup) dlg)
155 if ( !("accel-changed" in connectedSignals) )
157 Signals.connectData(
158 getStruct(),
159 "accel-changed",
160 cast(GCallback)&callBackAccelChanged,
161 this,
162 null,
163 cast(ConnectFlags)0);
164 connectedSignals["accel-changed"] = 1;
166 onAccelChangedListeners ~= dlg;
168 extern(C) static void callBackAccelChanged(GtkAccelGroup* accelGroupStruct, guint keyval, GdkModifierType modifier, GClosure* accelClosure, AccelGroup accelGroup)
170 bit consumed = false;
172 foreach ( void delegate(guint, GdkModifierType, Closure, AccelGroup) dlg ; accelGroup.onAccelChangedListeners )
174 dlg(keyval, modifier, new Closure(accelClosure), accelGroup);
177 return consumed;
183 * Creates a new GtkAccelGroup.
184 * Returns:
185 * a new GtkAccelGroup object
187 public this ()
189 // GtkAccelGroup* gtk_accel_group_new (void);
190 this(cast(GtkAccelGroup*)gtk_accel_group_new() );
196 * Installs an accelerator in this group. When accel_group is being activated
197 * in response to a call to gtk_accel_groups_activate(), closure will be
198 * invoked if the accel_key and accel_mods from gtk_accel_groups_activate()
199 * match those of this connection.
200 * The signature used for the closure is that of GtkAccelGroupActivate.
201 * Note that, due to implementation details, a single closure can only be
202 * connected to one accelerator group.
203 * accel_group:
204 * the accelerator group to install an accelerator in
205 * accel_key:
206 * key value of the accelerator
207 * accel_mods:
208 * modifier combination of the accelerator
209 * accel_flags:
210 * a flag mask to configure this accelerator
211 * closure:
212 * closure to be executed upon accelerator activation
214 public void connect(uint accelKey, GdkModifierType accelMods, GtkAccelFlags accelFlags, Closure closure)
216 // void gtk_accel_group_connect (GtkAccelGroup *accel_group, guint accel_key, GdkModifierType accel_mods, GtkAccelFlags accel_flags, GClosure *closure);
217 gtk_accel_group_connect(gtkAccelGroup, accelKey, accelMods, accelFlags, (closure is null) ? null : closure.getClosureStruct());
221 * Installs an accelerator in this group, using an accelerator path to look
222 * up the appropriate key and modifiers (see gtk_accel_map_add_entry()).
223 * When accel_group is being activated in response to a call to
224 * gtk_accel_groups_activate(), closure will be invoked if the accel_key and
225 * accel_mods from gtk_accel_groups_activate() match the key and modifiers
226 * for the path.
227 * The signature used for the closure is that of GtkAccelGroupActivate.
228 * accel_group:
229 * the accelerator group to install an accelerator in
230 * accel_path:
231 * path used for determining key and modifiers.
232 * closure:
233 * closure to be executed upon accelerator activation
235 public void connectByPath(char[] accelPath, Closure closure)
237 // void gtk_accel_group_connect_by_path (GtkAccelGroup *accel_group, const gchar *accel_path, GClosure *closure);
238 gtk_accel_group_connect_by_path(gtkAccelGroup, Str.toStringz(accelPath), (closure is null) ? null : closure.getClosureStruct());
244 * Removes an accelerator previously installed through
245 * gtk_accel_group_connect().
246 * accel_group:
247 * the accelerator group to remove an accelerator from
248 * closure:
249 * the closure to remove from this accelerator group
250 * Returns:
251 * TRUE if the closure was found and got disconnected
253 public int disconnect(Closure closure)
255 // gboolean gtk_accel_group_disconnect (GtkAccelGroup *accel_group, GClosure *closure);
256 return gtk_accel_group_disconnect(gtkAccelGroup, (closure is null) ? null : closure.getClosureStruct());
260 * Removes an accelerator previously installed through
261 * gtk_accel_group_connect().
262 * accel_group:
263 * the accelerator group to install an accelerator in
264 * accel_key:
265 * key value of the accelerator
266 * accel_mods:
267 * modifier combination of the accelerator
268 * Returns:
269 * TRUE if there was an accelerator which could be
270 * removed, FALSE otherwise
272 public int disconnectKey(uint accelKey, GdkModifierType accelMods)
274 // gboolean gtk_accel_group_disconnect_key (GtkAccelGroup *accel_group, guint accel_key, GdkModifierType accel_mods);
275 return gtk_accel_group_disconnect_key(gtkAccelGroup, accelKey, accelMods);
279 * Queries an accelerator group for all entries matching accel_key and
280 * accel_mods.
281 * accel_group:
282 * the accelerator group to query
283 * accel_key:
284 * key value of the accelerator
285 * accel_mods:
286 * modifier combination of the accelerator
287 * n_entries:
288 * location to return the number of entries found, or NULL
289 * Returns:
290 * an array of n_entries GtkAccelGroupEntry elements, or NULL. The array is owned by GTK+ and must not be freed.
292 public GtkAccelGroupEntry* query(uint accelKey, GdkModifierType accelMods, uint* nEntries)
294 // GtkAccelGroupEntry* gtk_accel_group_query (GtkAccelGroup *accel_group, guint accel_key, GdkModifierType accel_mods, guint *n_entries);
295 return gtk_accel_group_query(gtkAccelGroup, accelKey, accelMods, nEntries);
299 * accel_group:
300 * accel_quark:
301 * acceleratable:
302 * accel_key:
303 * accel_mods:
304 * Returns:
306 public int activate(GQuark accelQuark, ObjectG acceleratable, uint accelKey, GdkModifierType accelMods)
308 // gboolean gtk_accel_group_activate (GtkAccelGroup *accel_group, GQuark accel_quark, GObject *acceleratable, guint accel_key, GdkModifierType accel_mods);
309 return gtk_accel_group_activate(gtkAccelGroup, accelQuark, (acceleratable is null) ? null : acceleratable.getObjectGStruct(), accelKey, accelMods);
313 * Locks the given accelerator group.
314 * Locking an acelerator group prevents the accelerators contained
315 * within it to be changed during runtime. Refer to
316 * gtk_accel_map_change_entry() about runtime accelerator changes.
317 * If called more than once, accel_group remains locked until
318 * gtk_accel_group_unlock() has been called an equivalent number
319 * of times.
320 * accel_group:
321 * a GtkAccelGroup
323 public void lock()
325 // void gtk_accel_group_lock (GtkAccelGroup *accel_group);
326 gtk_accel_group_lock(gtkAccelGroup);
330 * Undoes the last call to gtk_accel_group_lock() on this accel_group.
331 * accel_group:
332 * a GtkAccelGroup
334 public void unlock()
336 // void gtk_accel_group_unlock (GtkAccelGroup *accel_group);
337 gtk_accel_group_unlock(gtkAccelGroup);
341 * Finds the GtkAccelGroup to which closure is connected;
342 * see gtk_accel_group_connect().
343 * closure:
344 * a GClosure
345 * Returns:
346 * the GtkAccelGroup to which closure is connected, or NULL.
348 public static AccelGroup fromAccelClosure(Closure closure)
350 // GtkAccelGroup* gtk_accel_group_from_accel_closure (GClosure *closure);
351 return new AccelGroup( gtk_accel_group_from_accel_closure((closure is null) ? null : closure.getClosureStruct()) );
355 * Finds the first accelerator in any GtkAccelGroup attached
356 * to object that matches accel_key and accel_mods, and
357 * activates that accelerator.
358 * If an accelerator was activated and handled this keypress, TRUE
359 * is returned.
360 * object:
361 * the GObject, usually a GtkWindow, on which
362 * to activate the accelerator.
363 * accel_key:
364 * accelerator keyval from a key event
365 * accel_mods:
366 * keyboard state mask from a key event
367 * Returns:
368 * TRUE if the accelerator was handled, FALSE otherwise
370 public static int accelGroupsActivate(ObjectG object, uint accelKey, GdkModifierType accelMods)
372 // gboolean gtk_accel_groups_activate (GObject *object, guint accel_key, GdkModifierType accel_mods);
373 return gtk_accel_groups_activate((object is null) ? null : object.getObjectGStruct(), accelKey, accelMods);
377 * Gets a list of all accel groups which are attached to object.
378 * object:
379 * a GObject, usually a GtkWindow
380 * Returns:
381 * a list of all accel groups which are attached to object
383 public static ListSG accelGroupsFromObject(ObjectG object)
385 // GSList* gtk_accel_groups_from_object (GObject *object);
386 return new ListSG( gtk_accel_groups_from_object((object is null) ? null : object.getObjectGStruct()) );
390 * Finds the first entry in an accelerator group for which
391 * find_func returns TRUE and returns its GtkAccelKey.
392 * accel_group:
393 * a GtkAccelGroup
394 * find_func:
395 * a function to filter the entries of accel_group with
396 * data:
397 * data to pass to find_func
398 * Returns:
399 * the key of the first entry passing find_func. The key is
400 * owned by GTK+ and must not be freed.
402 public GtkAccelKey* find(GtkAccelGroupFindFunc findFunc, void* data)
404 // GtkAccelKey* gtk_accel_group_find (GtkAccelGroup *accel_group, GtkAccelGroupFindFunc find_func, gpointer data);
405 return gtk_accel_group_find(gtkAccelGroup, findFunc, data);
410 * Determines whether a given keyval and modifier mask constitute
411 * a valid keyboard accelerator. For example, the GDK_a keyval
412 * plus GDK_CONTROL_MASK is valid - this is a "Ctrl+a" accelerator.
413 * But, you can't, for instance, use the GDK_Control_L keyval
414 * as an accelerator.
415 * keyval:
416 * a GDK keyval
417 * modifiers:
418 * modifier mask
419 * Returns:
420 * TRUE if the accelerator is valid
422 public static int acceleratorValid(uint keyval, GdkModifierType modifiers)
424 // gboolean gtk_accelerator_valid (guint keyval, GdkModifierType modifiers);
425 return gtk_accelerator_valid(keyval, modifiers);
429 * Parses a string representing an accelerator. The
430 * format looks like "<Control>a" or "<Shift><Alt>F1" or
431 * "<Release>z" (the last one is for key release).
432 * The parser is fairly liberal and allows lower or upper case,
433 * and also abbreviations such as "<Ctl>" and "<Ctrl>".
434 * If the parse fails, accelerator_key and accelerator_mods will
435 * be set to 0 (zero).
436 * accelerator:
437 * string representing an accelerator
438 * accelerator_key:
439 * return location for accelerator keyval
440 * accelerator_mods:
441 * return location for accelerator modifier mask
443 public static void acceleratorParse(char[] accelerator, uint* acceleratorKey, GdkModifierType* acceleratorMods)
445 // void gtk_accelerator_parse (const gchar *accelerator, guint *accelerator_key, GdkModifierType *accelerator_mods);
446 gtk_accelerator_parse(Str.toStringz(accelerator), acceleratorKey, acceleratorMods);
450 * Converts an accelerator keyval and modifier mask
451 * into a string parseable by gtk_accelerator_parse().
452 * For example, if you pass in GDK_q and GDK_CONTROL_MASK,
453 * this function returns "<Control>q".
454 * If you need to display accelerators in the user interface,
455 * see gtk_accelerator_get_label().
456 * accelerator_key:
457 * accelerator keyval
458 * accelerator_mods:
459 * accelerator modifier mask
460 * Returns:
461 * a newly-allocated accelerator name
463 public static char[] acceleratorName(uint acceleratorKey, GdkModifierType acceleratorMods)
465 // gchar* gtk_accelerator_name (guint accelerator_key, GdkModifierType accelerator_mods);
466 return Str.toString(gtk_accelerator_name(acceleratorKey, acceleratorMods) );
470 * Converts an accelerator keyval and modifier mask into a string
471 * which can be used to represent the accelerator to the user.
472 * accelerator_key:
473 * accelerator keyval
474 * accelerator_mods:
475 * accelerator modifier mask
476 * Returns:
477 * a newly-allocated string representing the accelerator.
478 * Since 2.6
480 public static char[] acceleratorGetLabel(uint acceleratorKey, GdkModifierType acceleratorMods)
482 // gchar* gtk_accelerator_get_label (guint accelerator_key, GdkModifierType accelerator_mods);
483 return Str.toString(gtk_accelerator_get_label(acceleratorKey, acceleratorMods) );
487 * Sets the modifiers that will be considered significant for keyboard
488 * accelerators. The default mod mask is GDK_CONTROL_MASK |
489 * GDK_SHIFT_MASK | GDK_MOD1_MASK | GDK_SUPER_MASK |
490 * GDK_HYPER_MASK | GDK_META_MASK, that is, Control, Shift, Alt,
491 * Super, Hyper and Meta. Other modifiers will by default be ignored
492 * by GtkAccelGroup.
493 * You must include at least the three modifiers Control, Shift
494 * and Alt in any value you pass to this function.
495 * The default mod mask should be changed on application startup,
496 * before using any accelerator groups.
497 * default_mod_mask:
498 * accelerator modifier mask
500 public static void acceleratorSetDefaultModMask(GdkModifierType defaultModMask)
502 // void gtk_accelerator_set_default_mod_mask (GdkModifierType default_mod_mask);
503 gtk_accelerator_set_default_mod_mask(defaultModMask);
507 * Gets the value set by gtk_accelerator_set_default_mod_mask().
508 * Returns:
509 * the default accelerator modifier mask
510 * Signal Details
511 * The "accel-activate" signal
512 * gboolean user_function (GtkAccelGroup *accel_group,
513 * GObject *acceleratable,
514 * guint keyval,
515 * GdkModifierType modifier,
516 * gpointer user_data) : Has details
517 * The accel-activate signal is an implementation detail of
518 * GtkAccelGroup and not meant to be used by applications.
519 * accel_group:
520 * the GtkAccelGroup which received the signal
521 * acceleratable:
522 * the object on which the accelerator was activated
523 * keyval:
524 * the accelerator keyval
525 * modifier:
526 * the modifier combination of the accelerator
527 * user_data:
528 * user data set when the signal handler was connected.
529 * Returns:
530 * TRUE if the accelerator was activated
532 public static uint acceleratorGetDefaultModMask()
534 // guint gtk_accelerator_get_default_mod_mask (void);
535 return gtk_accelerator_get_default_mod_mask();