Wrote the README_GIT file to be a proper tutorial on git, repo.or.cz and gtkD.
[gtkD.git] / gtkD / src / gtk / ActionGroup.d
blob7bf5d2625ced8f8466ef2e895ad2176a117ad68c
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 * module aliases:
52 * local aliases:
55 module gtk.ActionGroup;
57 version(noAssert)
59 version(Tango)
61 import tango.io.Stdout; // use the tango loging?
65 private import gtkc.gtktypes;
67 private import gtkc.gtk;
70 private import glib.Str;
71 private import gtk.Action;
72 private import glib.ListG;
77 /**
78 * Description
79 * Actions are organised into groups. An action group is essentially a
80 * map from names to GtkAction objects.
81 * All actions that would make sense to use in a particular context
82 * should be in a single group. Multiple action groups may be used for a
83 * particular user interface. In fact, it is expected that most nontrivial
84 * applications will make use of multiple groups. For example, in an application
85 * that can edit multiple documents, one group holding global actions
86 * (e.g. quit, about, new), and one group per document holding actions that
87 * act on that document (eg. save, cut/copy/paste, etc). Each window's menus
88 * would be constructed from a combination of two action groups.
89 * Accelerators are handled by the GTK+ accelerator map. All actions are assigned an
90 * accelerator path (which normally has the form
91 * <Actions>/group-name/action-name)
92 * and a shortcut is associated with this accelerator path. All menuitems and
93 * toolitems take on this accelerator path. The GTK+ accelerator map code makes
94 * sure that the correct shortcut is displayed next to the menu item.
96 private import gobject.ObjectG;
97 public class ActionGroup : ObjectG
100 /** the main Gtk struct */
101 protected GtkActionGroup* gtkActionGroup;
104 public GtkActionGroup* getActionGroupStruct()
106 return gtkActionGroup;
110 /** the main Gtk struct as a void* */
111 protected void* getStruct()
113 return cast(void*)gtkActionGroup;
117 * Sets our main struct and passes it to the parent class
119 public this (GtkActionGroup* gtkActionGroup)
121 version(noAssert)
123 if ( gtkActionGroup is null )
125 int zero = 0;
126 version(Tango)
128 Stdout("struct gtkActionGroup is null on constructor").newline;
130 else
132 printf("struct gtkActionGroup is null on constructor");
134 zero = zero / zero;
137 else
139 assert(gtkActionGroup !is null, "struct gtkActionGroup is null on constructor");
141 super(cast(GObject*)gtkActionGroup);
142 this.gtkActionGroup = gtkActionGroup;
148 // imports for the signal processing
149 private import gobject.Signals;
150 private import gtkc.gdktypes;
151 int[char[]] connectedSignals;
153 void delegate(Action, GtkWidget*, ActionGroup)[] onConnectProxyListeners;
154 void addOnConnectProxy(void delegate(Action, GtkWidget*, ActionGroup) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
156 if ( !("connect-proxy" in connectedSignals) )
158 Signals.connectData(
159 getStruct(),
160 "connect-proxy",
161 cast(GCallback)&callBackConnectProxy,
162 cast(void*)this,
163 null,
164 connectFlags);
165 connectedSignals["connect-proxy"] = 1;
167 onConnectProxyListeners ~= dlg;
169 extern(C) static void callBackConnectProxy(GtkActionGroup* actionGroupStruct, GtkAction* action, GtkWidget* proxy, ActionGroup actionGroup)
171 bool consumed = false;
173 foreach ( void delegate(Action, GtkWidget*, ActionGroup) dlg ; actionGroup.onConnectProxyListeners )
175 dlg(new Action(action), proxy, actionGroup);
178 return consumed;
181 void delegate(Action, GtkWidget*, ActionGroup)[] onDisconnectProxyListeners;
182 void addOnDisconnectProxy(void delegate(Action, GtkWidget*, ActionGroup) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
184 if ( !("disconnect-proxy" in connectedSignals) )
186 Signals.connectData(
187 getStruct(),
188 "disconnect-proxy",
189 cast(GCallback)&callBackDisconnectProxy,
190 cast(void*)this,
191 null,
192 connectFlags);
193 connectedSignals["disconnect-proxy"] = 1;
195 onDisconnectProxyListeners ~= dlg;
197 extern(C) static void callBackDisconnectProxy(GtkActionGroup* actionGroupStruct, GtkAction* action, GtkWidget* proxy, ActionGroup actionGroup)
199 bool consumed = false;
201 foreach ( void delegate(Action, GtkWidget*, ActionGroup) dlg ; actionGroup.onDisconnectProxyListeners )
203 dlg(new Action(action), proxy, actionGroup);
206 return consumed;
209 void delegate(Action, ActionGroup)[] onPostActivateListeners;
210 void addOnPostActivate(void delegate(Action, ActionGroup) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
212 if ( !("post-activate" in connectedSignals) )
214 Signals.connectData(
215 getStruct(),
216 "post-activate",
217 cast(GCallback)&callBackPostActivate,
218 cast(void*)this,
219 null,
220 connectFlags);
221 connectedSignals["post-activate"] = 1;
223 onPostActivateListeners ~= dlg;
225 extern(C) static void callBackPostActivate(GtkActionGroup* actionGroupStruct, GtkAction* action, ActionGroup actionGroup)
227 bool consumed = false;
229 foreach ( void delegate(Action, ActionGroup) dlg ; actionGroup.onPostActivateListeners )
231 dlg(new Action(action), actionGroup);
234 return consumed;
237 void delegate(Action, ActionGroup)[] onPreActivateListeners;
238 void addOnPreActivate(void delegate(Action, ActionGroup) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
240 if ( !("pre-activate" in connectedSignals) )
242 Signals.connectData(
243 getStruct(),
244 "pre-activate",
245 cast(GCallback)&callBackPreActivate,
246 cast(void*)this,
247 null,
248 connectFlags);
249 connectedSignals["pre-activate"] = 1;
251 onPreActivateListeners ~= dlg;
253 extern(C) static void callBackPreActivate(GtkActionGroup* actionGroupStruct, GtkAction* action, ActionGroup actionGroup)
255 bool consumed = false;
257 foreach ( void delegate(Action, ActionGroup) dlg ; actionGroup.onPreActivateListeners )
259 dlg(new Action(action), actionGroup);
262 return consumed;
268 * Creates a new GtkActionGroup object. The name of the action group
269 * is used when associating keybindings
270 * with the actions.
271 * name:
272 * the name of the action group.
273 * Returns:
274 * the new GtkActionGroup
275 * Since 2.4
277 public this (char[] name)
279 // GtkActionGroup* gtk_action_group_new (const gchar *name);
280 this(cast(GtkActionGroup*)gtk_action_group_new(Str.toStringz(name)) );
284 * Gets the name of the action group.
285 * action_group:
286 * the action group
287 * Returns:
288 * the name of the action group.
289 * Since 2.4
291 public char[] getName()
293 // const gchar* gtk_action_group_get_name (GtkActionGroup *action_group);
294 return Str.toString(gtk_action_group_get_name(gtkActionGroup) );
298 * Returns TRUE if the group is sensitive. The constituent actions
299 * can only be logically sensitive (see gtk_action_is_sensitive()) if
300 * they are sensitive (see gtk_action_get_sensitive()) and their group
301 * is sensitive.
302 * action_group:
303 * the action group
304 * Returns:
305 * TRUE if the group is sensitive.
306 * Since 2.4
308 public int getSensitive()
310 // gboolean gtk_action_group_get_sensitive (GtkActionGroup *action_group);
311 return gtk_action_group_get_sensitive(gtkActionGroup);
315 * Changes the sensitivity of action_group
316 * action_group:
317 * the action group
318 * sensitive:
319 * new sensitivity
320 * Since 2.4
322 public void setSensitive(int sensitive)
324 // void gtk_action_group_set_sensitive (GtkActionGroup *action_group, gboolean sensitive);
325 gtk_action_group_set_sensitive(gtkActionGroup, sensitive);
329 * Returns TRUE if the group is visible. The constituent actions
330 * can only be logically visible (see gtk_action_is_visible()) if
331 * they are visible (see gtk_action_get_visible()) and their group
332 * is visible.
333 * action_group:
334 * the action group
335 * Returns:
336 * TRUE if the group is visible.
337 * Since 2.4
339 public int getVisible()
341 // gboolean gtk_action_group_get_visible (GtkActionGroup *action_group);
342 return gtk_action_group_get_visible(gtkActionGroup);
346 * Changes the visible of action_group.
347 * action_group:
348 * the action group
349 * visible:
350 * new visiblity
351 * Since 2.4
353 public void setVisible(int visible)
355 // void gtk_action_group_set_visible (GtkActionGroup *action_group, gboolean visible);
356 gtk_action_group_set_visible(gtkActionGroup, visible);
360 * Looks up an action in the action group by name.
361 * action_group:
362 * the action group
363 * action_name:
364 * the name of the action
365 * Returns:
366 * the action, or NULL if no action by that name exists
367 * Since 2.4
369 public Action getAction(char[] actionName)
371 // GtkAction* gtk_action_group_get_action (GtkActionGroup *action_group, const gchar *action_name);
372 return new Action( gtk_action_group_get_action(gtkActionGroup, Str.toStringz(actionName)) );
376 * Lists the actions in the action group.
377 * action_group:
378 * the action group
379 * Returns:
380 * an allocated list of the action objects in the action group
381 * Since 2.4
383 public ListG listActions()
385 // GList* gtk_action_group_list_actions (GtkActionGroup *action_group);
386 return new ListG( gtk_action_group_list_actions(gtkActionGroup) );
390 * Adds an action object to the action group. Note that this function
391 * does not set up the accel path of the action, which can lead to problems
392 * if a user tries to modify the accelerator of a menuitem associated with
393 * the action. Therefore you must either set the accel path yourself with
394 * gtk_action_set_accel_path(), or use
395 * gtk_action_group_add_action_with_accel (..., NULL).
396 * action_group:
397 * the action group
398 * action:
399 * an action
400 * Since 2.4
402 public void addAction(Action action)
404 // void gtk_action_group_add_action (GtkActionGroup *action_group, GtkAction *action);
405 gtk_action_group_add_action(gtkActionGroup, (action is null) ? null : action.getActionStruct());
409 * Adds an action object to the action group and sets up the accelerator.
410 * If accelerator is NULL, attempts to use the accelerator associated
411 * with the stock_id of the action.
412 * Accel paths are set to
413 * <Actions>/group-name/action-name.
414 * action_group:
415 * the action group
416 * action:
417 * the action to add
418 * accelerator:
419 * the accelerator for the action, in
420 * the format understood by gtk_accelerator_parse(), or "" for no accelerator, or
421 * NULL to use the stock accelerator
422 * Since 2.4
424 public void addActionWithAccel(Action action, char[] accelerator)
426 // void gtk_action_group_add_action_with_accel (GtkActionGroup *action_group, GtkAction *action, const gchar *accelerator);
427 gtk_action_group_add_action_with_accel(gtkActionGroup, (action is null) ? null : action.getActionStruct(), Str.toStringz(accelerator));
431 * Removes an action object from the action group.
432 * action_group:
433 * the action group
434 * action:
435 * an action
436 * Since 2.4
438 public void removeAction(Action action)
440 // void gtk_action_group_remove_action (GtkActionGroup *action_group, GtkAction *action);
441 gtk_action_group_remove_action(gtkActionGroup, (action is null) ? null : action.getActionStruct());
446 * This is a convenience function to create a number of actions and add them
447 * to the action group.
448 * The "activate" signals of the actions are connected to the callbacks and
449 * their accel paths are set to
450 * <Actions>/group-name/action-name.
451 * action_group:
452 * the action group
453 * entries:
454 * an array of action descriptions
455 * n_entries:
456 * the number of entries
457 * user_data:
458 * data to pass to the action callbacks
459 * Since 2.4
461 public void addActions(GtkActionEntry* entries, uint nEntries, void* userData)
463 // void gtk_action_group_add_actions (GtkActionGroup *action_group, const GtkActionEntry *entries, guint n_entries, gpointer user_data);
464 gtk_action_group_add_actions(gtkActionGroup, entries, nEntries, userData);
468 * This variant of gtk_action_group_add_actions() adds a GDestroyNotify
469 * callback for user_data.
470 * action_group:
471 * the action group
472 * entries:
473 * an array of action descriptions
474 * n_entries:
475 * the number of entries
476 * user_data:
477 * data to pass to the action callbacks
478 * destroy:
479 * destroy notification callback for user_data
480 * Since 2.4
482 public void addActionsFull(GtkActionEntry* entries, uint nEntries, void* userData, GDestroyNotify destroy)
484 // void gtk_action_group_add_actions_full (GtkActionGroup *action_group, const GtkActionEntry *entries, guint n_entries, gpointer user_data, GDestroyNotify destroy);
485 gtk_action_group_add_actions_full(gtkActionGroup, entries, nEntries, userData, destroy);
490 * This is a convenience function to create a number of toggle actions and add them
491 * to the action group.
492 * The "activate" signals of the actions are connected to the callbacks and
493 * their accel paths are set to
494 * <Actions>/group-name/action-name.
495 * action_group:
496 * the action group
497 * entries:
498 * an array of toggle action descriptions
499 * n_entries:
500 * the number of entries
501 * user_data:
502 * data to pass to the action callbacks
503 * Since 2.4
505 public void addToggleActions(GtkToggleActionEntry* entries, uint nEntries, void* userData)
507 // void gtk_action_group_add_toggle_actions (GtkActionGroup *action_group, const GtkToggleActionEntry *entries, guint n_entries, gpointer user_data);
508 gtk_action_group_add_toggle_actions(gtkActionGroup, entries, nEntries, userData);
512 * This variant of gtk_action_group_add_toggle_actions() adds a
513 * GDestroyNotify callback for user_data.
514 * action_group:
515 * the action group
516 * entries:
517 * an array of toggle action descriptions
518 * n_entries:
519 * the number of entries
520 * user_data:
521 * data to pass to the action callbacks
522 * destroy:
523 * destroy notification callback for user_data
524 * Since 2.4
526 public void addToggleActionsFull(GtkToggleActionEntry* entries, uint nEntries, void* userData, GDestroyNotify destroy)
528 // void gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, const GtkToggleActionEntry *entries, guint n_entries, gpointer user_data, GDestroyNotify destroy);
529 gtk_action_group_add_toggle_actions_full(gtkActionGroup, entries, nEntries, userData, destroy);
534 * This is a convenience routine to create a group of radio actions and
535 * add them to the action group.
536 * The "changed" signal of the first radio action is connected to the
537 * on_change callback and the accel paths of the actions are set to
538 * <Actions>/group-name/action-name.
539 * action_group:
540 * the action group
541 * entries:
542 * an array of radio action descriptions
543 * n_entries:
544 * the number of entries
545 * value:
546 * the value of the action to activate initially, or -1 if
547 * no action should be activated
548 * on_change:
549 * the callback to connect to the changed signal
550 * user_data:
551 * data to pass to the action callbacks
552 * Since 2.4
554 public void addRadioActions(GtkRadioActionEntry* entries, uint nEntries, int value, GCallback onChange, void* userData)
556 // void gtk_action_group_add_radio_actions (GtkActionGroup *action_group, const GtkRadioActionEntry *entries, guint n_entries, gint value, GCallback on_change, gpointer user_data);
557 gtk_action_group_add_radio_actions(gtkActionGroup, entries, nEntries, value, onChange, userData);
561 * This variant of gtk_action_group_add_radio_actions() adds a
562 * GDestroyNotify callback for user_data.
563 * action_group:
564 * the action group
565 * entries:
566 * an array of radio action descriptions
567 * n_entries:
568 * the number of entries
569 * value:
570 * the value of the action to activate initially, or -1 if
571 * no action should be activated
572 * on_change:
573 * the callback to connect to the changed signal
574 * user_data:
575 * data to pass to the action callbacks
576 * destroy:
577 * destroy notification callback for user_data
578 * Since 2.4
580 public void addRadioActionsFull(GtkRadioActionEntry* entries, uint nEntries, int value, GCallback onChange, void* userData, GDestroyNotify destroy)
582 // 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);
583 gtk_action_group_add_radio_actions_full(gtkActionGroup, entries, nEntries, value, onChange, userData, destroy);
587 * Sets a function to be used for translating the label and tooltip of
588 * GtkActionGroupEntrys added by gtk_action_group_add_actions().
589 * If you're using gettext(), it is enough to set the translation domain
590 * with gtk_action_group_set_translation_domain().
591 * action_group:
592 * a GtkActionGroup
593 * func:
594 * a GtkTranslateFunc
595 * data:
596 * data to be passed to func and notify
597 * notify:
598 * a GtkDestroyNotify function to be called when action_group is
599 * destroyed and when the translation function is changed again
600 * Since 2.4
602 public void setTranslateFunc(GtkTranslateFunc func, void* data, GtkDestroyNotify notify)
604 // void gtk_action_group_set_translate_func (GtkActionGroup *action_group, GtkTranslateFunc func, gpointer data, GtkDestroyNotify notify);
605 gtk_action_group_set_translate_func(gtkActionGroup, func, data, notify);
609 * Sets the translation domain and uses dgettext() for translating the
610 * label and tooltip of GtkActionEntrys added by
611 * gtk_action_group_add_actions().
612 * If you're not using gettext() for localization, see
613 * gtk_action_group_set_translate_func().
614 * action_group:
615 * a GtkActionGroup
616 * domain:
617 * the translation domain to use for dgettext() calls
618 * Since 2.4
620 public void setTranslationDomain(char[] domain)
622 // void gtk_action_group_set_translation_domain (GtkActionGroup *action_group, const gchar *domain);
623 gtk_action_group_set_translation_domain(gtkActionGroup, Str.toStringz(domain));
627 * Translates a string using the specified translate_func(). This
628 * is mainly intended for language bindings.
629 * action_group:
630 * a GtkActionGroup
631 * string:
632 * a string
633 * Returns:
634 * the translation of string
635 * Since 2.6
636 * Property Details
637 * The "name" property
638 * "name" gchararray : Read / Write / Construct Only
639 * A name for the action group.
640 * Default value: NULL
642 public char[] translateString(char[] string)
644 // const gchar* gtk_action_group_translate_string (GtkActionGroup *action_group, const gchar *string);
645 return Str.toString(gtk_action_group_translate_string(gtkActionGroup, Str.toStringz(string)) );