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
27 * outFile = AccelGroup
28 * strct = GtkAccelGroup
51 * - GClosure* -> Closure
52 * - GObject* -> ObjectG
54 * - GtkAccelGroup* -> AccelGroup
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
;
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()
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
) )
132 cast(GCallback
)&callBackAccelActivate
,
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
);
152 void delegate(guint
, GdkModifierType
, Closure
, AccelGroup
)[] onAccelChangedListeners
;
153 void addOnAccelChanged(void delegate(guint
, GdkModifierType
, Closure
, AccelGroup
) dlg
)
155 if ( !("accel-changed" in connectedSignals
) )
160 cast(GCallback
)&callBackAccelChanged
,
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
);
183 * Creates a new GtkAccelGroup.
185 * a new GtkAccelGroup object
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.
204 * the accelerator group to install an accelerator in
206 * key value of the accelerator
208 * modifier combination of the accelerator
210 * a flag mask to configure this accelerator
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
227 * The signature used for the closure is that of GtkAccelGroupActivate.
229 * the accelerator group to install an accelerator in
231 * path used for determining key and modifiers.
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().
247 * the accelerator group to remove an accelerator from
249 * the closure to remove from this accelerator group
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().
263 * the accelerator group to install an accelerator in
265 * key value of the accelerator
267 * modifier combination of the accelerator
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
282 * the accelerator group to query
284 * key value of the accelerator
286 * modifier combination of the accelerator
288 * location to return the number of entries found, or NULL
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
);
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
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.
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().
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
361 * the GObject, usually a GtkWindow, on which
362 * to activate the accelerator.
364 * accelerator keyval from a key event
366 * keyboard state mask from a key event
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.
379 * a GObject, usually a GtkWindow
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.
395 * a function to filter the entries of accel_group with
397 * data to pass to find_func
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
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).
437 * string representing an accelerator
439 * return location for accelerator keyval
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().
459 * accelerator modifier mask
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.
475 * accelerator modifier mask
477 * a newly-allocated string representing the accelerator.
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
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.
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().
509 * the default accelerator modifier mask
511 * The "accel-activate" signal
512 * gboolean user_function (GtkAccelGroup *accel_group,
513 * GObject *acceleratable,
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.
520 * the GtkAccelGroup which received the signal
522 * the object on which the accelerator was activated
524 * the accelerator keyval
526 * the modifier combination of the accelerator
528 * user data set when the signal handler was connected.
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();