alternative to assert
[gtkD.git] / src / gtk / ActionGroup.d
blobf9aa426df806ec00c655d014213fed38a267989b
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 = GtkActionGroup.html
26 * outPack = gtk
27 * outFile = ActionGroup
28 * strct = GtkActionGroup
29 * realStrct=
30 * ctorStrct=
31 * clss = ActionGroup
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_action_group_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.Action
47 * - glib.ListG
48 * structWrap:
49 * - GList* -> ListG
50 * - GtkAction* -> Action
51 * local aliases:
54 module gtk.ActionGroup;
56 private import gtk.gtktypes;
58 private import lib.gtk;
60 private import glib.Str;
61 private import gtk.Action;
62 private import glib.ListG;
64 /**
65 * Description
66 * Actions are organised into groups. An action group is essentially a
67 * map from names to GtkAction objects.
68 * All actions that would make sense to use in a particular context
69 * should be in a single group. Multiple action groups may be used for a
70 * particular user interface. In fact, it is expected that most nontrivial
71 * applications will make use of multiple groups. For example, in an application
72 * that can edit multiple documents, one group holding global actions
73 * (e.g. quit, about, new), and one group per document holding actions that
74 * act on that document (eg. save, cut/copy/paste, etc). Each window's menus
75 * would be constructed from a combination of two action groups.
76 * Accelerators are handled by the GTK+ accelerator map. All actions are assigned an
77 * accelerator path (which normally has the form
78 * <Actions>/group-name/action-name)
79 * and a shortcut is associated with this accelerator path. All menuitems and
80 * toolitems take on this accelerator path. The GTK+ accelerator map code makes
81 * sure that the correct shortcut is displayed next to the menu item.
83 private import gobject.ObjectG;
84 public class ActionGroup : ObjectG
87 /** the main Gtk struct */
88 protected GtkActionGroup* gtkActionGroup;
91 public GtkActionGroup* getActionGroupStruct()
93 return gtkActionGroup;
97 /** the main Gtk struct as a void* */
98 protected void* getStruct()
100 return cast(void*)gtkActionGroup;
104 * Sets our main struct and passes it to the parent class
106 public this (GtkActionGroup* gtkActionGroup)
108 super(cast(GObject*)gtkActionGroup);
109 this.gtkActionGroup = gtkActionGroup;
115 // imports for the signal processing
116 private import gobject.Signals;
117 private import gdk.gdktypes;
118 int[char[]] connectedSignals;
120 void delegate(Action, GtkWidget*, ActionGroup)[] onConnectProxyListeners;
121 void addOnConnectProxy(void delegate(Action, GtkWidget*, ActionGroup) dlg)
123 if ( !("connect-proxy" in connectedSignals) )
125 Signals.connectData(
126 getStruct(),
127 "connect-proxy",
128 cast(GCallback)&callBackConnectProxy,
129 this,
130 null,
131 cast(ConnectFlags)0);
132 connectedSignals["connect-proxy"] = 1;
134 onConnectProxyListeners ~= dlg;
136 extern(C) static void callBackConnectProxy(GtkActionGroup* actionGroupStruct, GtkAction* action, GtkWidget* proxy, ActionGroup actionGroup)
138 bit consumed = false;
140 foreach ( void delegate(Action, GtkWidget*, ActionGroup) dlg ; actionGroup.onConnectProxyListeners )
142 dlg(new Action(action), proxy, actionGroup);
145 return consumed;
148 void delegate(Action, GtkWidget*, ActionGroup)[] onDisconnectProxyListeners;
149 void addOnDisconnectProxy(void delegate(Action, GtkWidget*, ActionGroup) dlg)
151 if ( !("disconnect-proxy" in connectedSignals) )
153 Signals.connectData(
154 getStruct(),
155 "disconnect-proxy",
156 cast(GCallback)&callBackDisconnectProxy,
157 this,
158 null,
159 cast(ConnectFlags)0);
160 connectedSignals["disconnect-proxy"] = 1;
162 onDisconnectProxyListeners ~= dlg;
164 extern(C) static void callBackDisconnectProxy(GtkActionGroup* actionGroupStruct, GtkAction* action, GtkWidget* proxy, ActionGroup actionGroup)
166 bit consumed = false;
168 foreach ( void delegate(Action, GtkWidget*, ActionGroup) dlg ; actionGroup.onDisconnectProxyListeners )
170 dlg(new Action(action), proxy, actionGroup);
173 return consumed;
176 void delegate(Action, ActionGroup)[] onPostActivateListeners;
177 void addOnPostActivate(void delegate(Action, ActionGroup) dlg)
179 if ( !("post-activate" in connectedSignals) )
181 Signals.connectData(
182 getStruct(),
183 "post-activate",
184 cast(GCallback)&callBackPostActivate,
185 this,
186 null,
187 cast(ConnectFlags)0);
188 connectedSignals["post-activate"] = 1;
190 onPostActivateListeners ~= dlg;
192 extern(C) static void callBackPostActivate(GtkActionGroup* actionGroupStruct, GtkAction* action, ActionGroup actionGroup)
194 bit consumed = false;
196 foreach ( void delegate(Action, ActionGroup) dlg ; actionGroup.onPostActivateListeners )
198 dlg(new Action(action), actionGroup);
201 return consumed;
204 void delegate(Action, ActionGroup)[] onPreActivateListeners;
205 void addOnPreActivate(void delegate(Action, ActionGroup) dlg)
207 if ( !("pre-activate" in connectedSignals) )
209 Signals.connectData(
210 getStruct(),
211 "pre-activate",
212 cast(GCallback)&callBackPreActivate,
213 this,
214 null,
215 cast(ConnectFlags)0);
216 connectedSignals["pre-activate"] = 1;
218 onPreActivateListeners ~= dlg;
220 extern(C) static void callBackPreActivate(GtkActionGroup* actionGroupStruct, GtkAction* action, ActionGroup actionGroup)
222 bit consumed = false;
224 foreach ( void delegate(Action, ActionGroup) dlg ; actionGroup.onPreActivateListeners )
226 dlg(new Action(action), actionGroup);
229 return consumed;
235 * Creates a new GtkActionGroup object. The name of the action group
236 * is used when associating keybindings
237 * with the actions.
238 * name:
239 * the name of the action group.
240 * Returns:
241 * the new GtkActionGroup
242 * Since 2.4
244 public this (char[] name)
246 // GtkActionGroup* gtk_action_group_new (const gchar *name);
247 this(cast(GtkActionGroup*)gtk_action_group_new(Str.toStringz(name)) );
251 * Gets the name of the action group.
252 * action_group:
253 * the action group
254 * Returns:
255 * the name of the action group.
256 * Since 2.4
258 public char[] getName()
260 // const gchar* gtk_action_group_get_name (GtkActionGroup *action_group);
261 return Str.toString(gtk_action_group_get_name(gtkActionGroup) );
265 * Returns TRUE if the group is sensitive. The constituent actions
266 * can only be logically sensitive (see gtk_action_is_sensitive()) if
267 * they are sensitive (see gtk_action_get_sensitive()) and their group
268 * is sensitive.
269 * action_group:
270 * the action group
271 * Returns:
272 * TRUE if the group is sensitive.
273 * Since 2.4
275 public int getSensitive()
277 // gboolean gtk_action_group_get_sensitive (GtkActionGroup *action_group);
278 return gtk_action_group_get_sensitive(gtkActionGroup);
282 * Changes the sensitivity of action_group
283 * action_group:
284 * the action group
285 * sensitive:
286 * new sensitivity
287 * Since 2.4
289 public void setSensitive(int sensitive)
291 // void gtk_action_group_set_sensitive (GtkActionGroup *action_group, gboolean sensitive);
292 gtk_action_group_set_sensitive(gtkActionGroup, sensitive);
296 * Returns TRUE if the group is visible. The constituent actions
297 * can only be logically visible (see gtk_action_is_visible()) if
298 * they are visible (see gtk_action_get_visible()) and their group
299 * is visible.
300 * action_group:
301 * the action group
302 * Returns:
303 * TRUE if the group is visible.
304 * Since 2.4
306 public int getVisible()
308 // gboolean gtk_action_group_get_visible (GtkActionGroup *action_group);
309 return gtk_action_group_get_visible(gtkActionGroup);
313 * Changes the visible of action_group.
314 * action_group:
315 * the action group
316 * visible:
317 * new visiblity
318 * Since 2.4
320 public void setVisible(int visible)
322 // void gtk_action_group_set_visible (GtkActionGroup *action_group, gboolean visible);
323 gtk_action_group_set_visible(gtkActionGroup, visible);
327 * Looks up an action in the action group by name.
328 * action_group:
329 * the action group
330 * action_name:
331 * the name of the action
332 * Returns:
333 * the action, or NULL if no action by that name exists
334 * Since 2.4
336 public Action getAction(char[] actionName)
338 // GtkAction* gtk_action_group_get_action (GtkActionGroup *action_group, const gchar *action_name);
339 return new Action( gtk_action_group_get_action(gtkActionGroup, Str.toStringz(actionName)) );
343 * Lists the actions in the action group.
344 * action_group:
345 * the action group
346 * Returns:
347 * an allocated list of the action objects in the action group
348 * Since 2.4
350 public ListG listActions()
352 // GList* gtk_action_group_list_actions (GtkActionGroup *action_group);
353 return new ListG( gtk_action_group_list_actions(gtkActionGroup) );
357 * Adds an action object to the action group. Note that this function
358 * does not set up the accel path of the action, which can lead to problems
359 * if a user tries to modify the accelerator of a menuitem associated with
360 * the action. Therefore you must either set the accel path yourself with
361 * gtk_action_set_accel_path(), or use
362 * gtk_action_group_add_action_with_accel (..., NULL).
363 * action_group:
364 * the action group
365 * action:
366 * an action
367 * Since 2.4
369 public void addAction(Action action)
371 // void gtk_action_group_add_action (GtkActionGroup *action_group, GtkAction *action);
372 gtk_action_group_add_action(gtkActionGroup, (action is null) ? null : action.getActionStruct());
376 * Adds an action object to the action group and sets up the accelerator.
377 * If accelerator is NULL, attempts to use the accelerator associated
378 * with the stock_id of the action.
379 * Accel paths are set to
380 * <Actions>/group-name/action-name.
381 * action_group:
382 * the action group
383 * action:
384 * the action to add
385 * accelerator:
386 * the accelerator for the action, in
387 * the format understood by gtk_accelerator_parse(), or "" for no accelerator, or
388 * NULL to use the stock accelerator
389 * Since 2.4
391 public void addActionWithAccel(Action action, char[] accelerator)
393 // void gtk_action_group_add_action_with_accel (GtkActionGroup *action_group, GtkAction *action, const gchar *accelerator);
394 gtk_action_group_add_action_with_accel(gtkActionGroup, (action is null) ? null : action.getActionStruct(), Str.toStringz(accelerator));
398 * Removes an action object from the action group.
399 * action_group:
400 * the action group
401 * action:
402 * an action
403 * Since 2.4
405 public void removeAction(Action action)
407 // void gtk_action_group_remove_action (GtkActionGroup *action_group, GtkAction *action);
408 gtk_action_group_remove_action(gtkActionGroup, (action is null) ? null : action.getActionStruct());
413 * This is a convenience function to create a number of actions and add them
414 * to the action group.
415 * The "activate" signals of the actions are connected to the callbacks and
416 * their accel paths are set to
417 * <Actions>/group-name/action-name.
418 * action_group:
419 * the action group
420 * entries:
421 * an array of action descriptions
422 * n_entries:
423 * the number of entries
424 * user_data:
425 * data to pass to the action callbacks
426 * Since 2.4
428 public void addActions(GtkActionEntry* entries, uint nEntries, void* userData)
430 // void gtk_action_group_add_actions (GtkActionGroup *action_group, const GtkActionEntry *entries, guint n_entries, gpointer user_data);
431 gtk_action_group_add_actions(gtkActionGroup, entries, nEntries, userData);
435 * This variant of gtk_action_group_add_actions() adds a GDestroyNotify
436 * callback for user_data.
437 * action_group:
438 * the action group
439 * entries:
440 * an array of action descriptions
441 * n_entries:
442 * the number of entries
443 * user_data:
444 * data to pass to the action callbacks
445 * destroy:
446 * destroy notification callback for user_data
447 * Since 2.4
449 public void addActionsFull(GtkActionEntry* entries, uint nEntries, void* userData, GDestroyNotify destroy)
451 // void gtk_action_group_add_actions_full (GtkActionGroup *action_group, const GtkActionEntry *entries, guint n_entries, gpointer user_data, GDestroyNotify destroy);
452 gtk_action_group_add_actions_full(gtkActionGroup, entries, nEntries, userData, destroy);
457 * This is a convenience function to create a number of toggle actions and add them
458 * to the action group.
459 * The "activate" signals of the actions are connected to the callbacks and
460 * their accel paths are set to
461 * <Actions>/group-name/action-name.
462 * action_group:
463 * the action group
464 * entries:
465 * an array of toggle action descriptions
466 * n_entries:
467 * the number of entries
468 * user_data:
469 * data to pass to the action callbacks
470 * Since 2.4
472 public void addToggleActions(GtkToggleActionEntry* entries, uint nEntries, void* userData)
474 // void gtk_action_group_add_toggle_actions (GtkActionGroup *action_group, const GtkToggleActionEntry *entries, guint n_entries, gpointer user_data);
475 gtk_action_group_add_toggle_actions(gtkActionGroup, entries, nEntries, userData);
479 * This variant of gtk_action_group_add_toggle_actions() adds a
480 * GDestroyNotify callback for user_data.
481 * action_group:
482 * the action group
483 * entries:
484 * an array of toggle action descriptions
485 * n_entries:
486 * the number of entries
487 * user_data:
488 * data to pass to the action callbacks
489 * destroy:
490 * destroy notification callback for user_data
491 * Since 2.4
493 public void addToggleActionsFull(GtkToggleActionEntry* entries, uint nEntries, void* userData, GDestroyNotify destroy)
495 // void gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, const GtkToggleActionEntry *entries, guint n_entries, gpointer user_data, GDestroyNotify destroy);
496 gtk_action_group_add_toggle_actions_full(gtkActionGroup, entries, nEntries, userData, destroy);
501 * This is a convenience routine to create a group of radio actions and
502 * add them to the action group.
503 * The "changed" signal of the first radio action is connected to the
504 * on_change callback and the accel paths of the actions are set to
505 * <Actions>/group-name/action-name.
506 * action_group:
507 * the action group
508 * entries:
509 * an array of radio action descriptions
510 * n_entries:
511 * the number of entries
512 * value:
513 * the value of the action to activate initially, or -1 if
514 * no action should be activated
515 * on_change:
516 * the callback to connect to the changed signal
517 * user_data:
518 * data to pass to the action callbacks
519 * Since 2.4
521 public void addRadioActions(GtkRadioActionEntry* entries, uint nEntries, int value, GCallback onChange, void* userData)
523 // void gtk_action_group_add_radio_actions (GtkActionGroup *action_group, const GtkRadioActionEntry *entries, guint n_entries, gint value, GCallback on_change, gpointer user_data);
524 gtk_action_group_add_radio_actions(gtkActionGroup, entries, nEntries, value, onChange, userData);
528 * This variant of gtk_action_group_add_radio_actions() adds a
529 * GDestroyNotify callback for user_data.
530 * action_group:
531 * the action group
532 * entries:
533 * an array of radio action descriptions
534 * n_entries:
535 * the number of entries
536 * value:
537 * the value of the action to activate initially, or -1 if
538 * no action should be activated
539 * on_change:
540 * the callback to connect to the changed signal
541 * user_data:
542 * data to pass to the action callbacks
543 * destroy:
544 * destroy notification callback for user_data
545 * Since 2.4
547 public void addRadioActionsFull(GtkRadioActionEntry* entries, uint nEntries, int value, GCallback onChange, void* userData, GDestroyNotify destroy)
549 // void gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, const GtkRadioActionEntry *entries, guint n_entries, gint value, GCallback on_change, gpointer user_data, GDestroyNotify destroy);
550 gtk_action_group_add_radio_actions_full(gtkActionGroup, entries, nEntries, value, onChange, userData, destroy);
554 * Sets a function to be used for translating the label and tooltip of
555 * GtkActionGroupEntrys added by gtk_action_group_add_actions().
556 * If you're using gettext(), it is enough to set the translation domain
557 * with gtk_action_group_set_translation_domain().
558 * action_group:
559 * a GtkActionGroup
560 * func:
561 * a GtkTranslateFunc
562 * data:
563 * data to be passed to func and notify
564 * notify:
565 * a GtkDestroyNotify function to be called when action_group is
566 * destroyed and when the translation function is changed again
567 * Since 2.4
569 public void setTranslateFunc(GtkTranslateFunc func, void* data, GtkDestroyNotify notify)
571 // void gtk_action_group_set_translate_func (GtkActionGroup *action_group, GtkTranslateFunc func, gpointer data, GtkDestroyNotify notify);
572 gtk_action_group_set_translate_func(gtkActionGroup, func, data, notify);
576 * Sets the translation domain and uses dgettext() for translating the
577 * label and tooltip of GtkActionEntrys added by
578 * gtk_action_group_add_actions().
579 * If you're not using gettext() for localization, see
580 * gtk_action_group_set_translate_func().
581 * action_group:
582 * a GtkActionGroup
583 * domain:
584 * the translation domain to use for dgettext() calls
585 * Since 2.4
587 public void setTranslationDomain(char[] domain)
589 // void gtk_action_group_set_translation_domain (GtkActionGroup *action_group, const gchar *domain);
590 gtk_action_group_set_translation_domain(gtkActionGroup, Str.toStringz(domain));
594 * Translates a string using the specified translate_func(). This
595 * is mainly intended for language bindings.
596 * action_group:
597 * a GtkActionGroup
598 * string:
599 * a string
600 * Returns:
601 * the translation of string
602 * Since 2.6
603 * Property Details
604 * The "name" property
605 * "name" gchararray : Read / Write / Construct Only
606 * A name for the action group.
607 * Default value: NULL
609 public char[] translateString(char[] string)
611 // const gchar* gtk_action_group_translate_string (GtkActionGroup *action_group, const gchar *string);
612 return Str.toString(gtk_action_group_translate_string(gtkActionGroup, Str.toStringz(string)) );