I've no idea here...
[gtkD.git] / src / gtk / Action.d
blob37bd17b002fdfce4a524d652672bd33d0f44186e
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 = GtkAction.html
26 * outPack = gtk
27 * outFile = Action
28 * strct = GtkAction
29 * realStrct=
30 * ctorStrct=
31 * clss = Action
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_action_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.Widget
47 * - glib.ListSG
48 * - gobject.Closure
49 * - gtk.AccelGroup
50 * structWrap:
51 * - GClosure* -> Closure
52 * - GSList* -> ListSG
53 * - GtkAccelGroup* -> AccelGroup
54 * - GtkWidget* -> Widget
55 * local aliases:
58 module gtk.Action;
60 private import gtk.gtktypes;
62 private import lib.gtk;
64 private import glib.Str;
65 private import gtk.Widget;
66 private import glib.ListSG;
67 private import gobject.Closure;
68 private import gtk.AccelGroup;
70 /**
71 * Description
72 * Actions represent operations that the user can be perform, along with
73 * some information how it should be presented in the interface. Each action
74 * provides methods to create icons, menu items and toolbar items representing
75 * itself.
76 * As well as the callback that is called when the action gets activated, the
77 * following also gets associated with the action:
78 * a name (not translated, for path lookup)
79 * a label (translated, for display)
80 * an accelerator
81 * whether label indicates a stock id
82 * a tooltip (optional, translated)
83 * a toolbar label (optional, shorter than label)
84 * The action will also have some state information:
85 * visible (shown/hidden)
86 * sensitive (enabled/disabled)
87 * Apart from regular actions, there are toggle
88 * actions, which can be toggled between two states and radio actions, of which only one in a group
89 * can be in the "active" state. Other actions can be implemented as GtkAction
90 * subclasses.
91 * Each action can have one or more proxy menu item, toolbar button or
92 * other proxy widgets. Proxies mirror the state of the action (text
93 * label, tooltip, icon, visible, sensitive, etc), and should change when
94 * the action's state changes. When the proxy is activated, it should
95 * activate its action.
97 private import gobject.ObjectG;
98 public class Action : ObjectG
101 /** the main Gtk struct */
102 protected GtkAction* gtkAction;
105 public GtkAction* getActionStruct()
107 return gtkAction;
111 /** the main Gtk struct as a void* */
112 protected void* getStruct()
114 return cast(void*)gtkAction;
118 * Sets our main struct and passes it to the parent class
120 public this (GtkAction* gtkAction)
122 super(cast(GObject*)gtkAction);
123 this.gtkAction = gtkAction;
129 // imports for the signal processing
130 private import gobject.Signals;
131 private import gdk.gdktypes;
132 int[char[]] connectedSignals;
134 void delegate(Action)[] onActivateListeners;
135 void addOnActivate(void delegate(Action) dlg)
137 if ( !("activate" in connectedSignals) )
139 Signals.connectData(
140 getStruct(),
141 "activate",
142 cast(GCallback)&callBackActivate,
143 this,
144 null,
145 cast(ConnectFlags)0);
146 connectedSignals["activate"] = 1;
148 onActivateListeners ~= dlg;
150 extern(C) static void callBackActivate(GtkAction* actionStruct, Action action)
152 bit consumed = false;
154 foreach ( void delegate(Action) dlg ; action.onActivateListeners )
156 dlg(action);
159 return consumed;
165 * Creates a new GtkAction object. To add the action to a
166 * GtkActionGroup and set the accelerator for the action,
167 * call gtk_action_group_add_action_with_accel().
168 * See the section called UI Definitions for information on allowed action
169 * names.
170 * name:
171 * A unique name for the action
172 * label:
173 * the label displayed in menu items and on buttons
174 * tooltip:
175 * a tooltip for the action
176 * stock_id:
177 * the stock icon to display in widgets representing the action
178 * Returns:
179 * a new GtkAction
180 * Since 2.4
182 public this (char[] name, char[] label, char[] tooltip, char[] stockId)
184 // GtkAction* gtk_action_new (const gchar *name, const gchar *label, const gchar *tooltip, const gchar *stock_id);
185 this(cast(GtkAction*)gtk_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId)) );
189 * Returns the name of the action.
190 * action:
191 * the action object
192 * Returns:
193 * the name of the action. The string belongs to GTK+ and should not
194 * be freed.
195 * Since 2.4
197 public char[] getName()
199 // const gchar* gtk_action_get_name (GtkAction *action);
200 return Str.toString(gtk_action_get_name(gtkAction) );
204 * Returns whether the action is effectively sensitive.
205 * action:
206 * the action object
207 * Returns:
208 * TRUE if the action and its associated action group
209 * are both sensitive.
210 * Since 2.4
212 public int isSensitive()
214 // gboolean gtk_action_is_sensitive (GtkAction *action);
215 return gtk_action_is_sensitive(gtkAction);
219 * Returns whether the action itself is sensitive. Note that this doesn't
220 * necessarily mean effective sensitivity. See gtk_action_is_sensitive()
221 * for that.
222 * action:
223 * the action object
224 * Returns:
225 * TRUE if the action itself is sensitive.
226 * Since 2.4
228 public int getSensitive()
230 // gboolean gtk_action_get_sensitive (GtkAction *action);
231 return gtk_action_get_sensitive(gtkAction);
235 * Sets the ::sensitive property of the action to sensitive. Note that
236 * this doesn't necessarily mean effective sensitivity. See
237 * gtk_action_is_sensitive()
238 * for that.
239 * action:
240 * the action object
241 * sensitive:
242 * TRUE to make the action sensitive
243 * Since 2.6
245 public void setSensitive(int sensitive)
247 // void gtk_action_set_sensitive (GtkAction *action, gboolean sensitive);
248 gtk_action_set_sensitive(gtkAction, sensitive);
252 * Returns whether the action is effectively visible.
253 * action:
254 * the action object
255 * Returns:
256 * TRUE if the action and its associated action group
257 * are both visible.
258 * Since 2.4
260 public int isVisible()
262 // gboolean gtk_action_is_visible (GtkAction *action);
263 return gtk_action_is_visible(gtkAction);
267 * Returns whether the action itself is visible. Note that this doesn't
268 * necessarily mean effective visibility. See gtk_action_is_sensitive()
269 * for that.
270 * action:
271 * the action object
272 * Returns:
273 * TRUE if the action itself is visible.
274 * Since 2.4
276 public int getVisible()
278 // gboolean gtk_action_get_visible (GtkAction *action);
279 return gtk_action_get_visible(gtkAction);
283 * Sets the ::visible property of the action to visible. Note that
284 * this doesn't necessarily mean effective visibility. See
285 * gtk_action_is_visible()
286 * for that.
287 * action:
288 * the action object
289 * visible:
290 * TRUE to make the action visible
291 * Since 2.6
293 public void setVisible(int visible)
295 // void gtk_action_set_visible (GtkAction *action, gboolean visible);
296 gtk_action_set_visible(gtkAction, visible);
300 * Emits the "activate" signal on the specified action, if it isn't
301 * insensitive. This gets called by the proxy widgets when they get
302 * activated.
303 * It can also be used to manually activate an action.
304 * action:
305 * the action object
306 * Since 2.4
308 public void activate()
310 // void gtk_action_activate (GtkAction *action);
311 gtk_action_activate(gtkAction);
315 * This function is intended for use by action implementations to
316 * create icons displayed in the proxy widgets.
317 * action:
318 * the action object
319 * icon_size:
320 * the size of the icon that should be created.
321 * Returns:
322 * a widget that displays the icon for this action.
323 * Since 2.4
325 public Widget createIcon(GtkIconSize iconSize)
327 // GtkWidget* gtk_action_create_icon (GtkAction *action, GtkIconSize icon_size);
328 return new Widget( gtk_action_create_icon(gtkAction, iconSize) );
332 * Creates a menu item widget that proxies for the given action.
333 * action:
334 * the action object
335 * Returns:
336 * a menu item connected to the action.
337 * Since 2.4
339 public Widget createMenuItem()
341 // GtkWidget* gtk_action_create_menu_item (GtkAction *action);
342 return new Widget( gtk_action_create_menu_item(gtkAction) );
346 * Creates a toolbar item widget that proxies for the given action.
347 * action:
348 * the action object
349 * Returns:
350 * a toolbar item connected to the action.
351 * Since 2.4
353 public Widget createToolItem()
355 // GtkWidget* gtk_action_create_tool_item (GtkAction *action);
356 return new Widget( gtk_action_create_tool_item(gtkAction) );
360 * Connects a widget to an action object as a proxy. Synchronises
361 * various properties of the action with the widget (such as label
362 * text, icon, tooltip, etc), and attaches a callback so that the
363 * action gets activated when the proxy widget does.
364 * If the widget is already connected to an action, it is disconnected
365 * first.
366 * action:
367 * the action object
368 * proxy:
369 * the proxy widget
370 * Since 2.4
372 public void connectProxy(Widget proxy)
374 // void gtk_action_connect_proxy (GtkAction *action, GtkWidget *proxy);
375 gtk_action_connect_proxy(gtkAction, (proxy is null) ? null : proxy.getWidgetStruct());
379 * Disconnects a proxy widget from an action.
380 * Does not destroy the widget, however.
381 * action:
382 * the action object
383 * proxy:
384 * the proxy widget
385 * Since 2.4
387 public void disconnectProxy(Widget proxy)
389 // void gtk_action_disconnect_proxy (GtkAction *action, GtkWidget *proxy);
390 gtk_action_disconnect_proxy(gtkAction, (proxy is null) ? null : proxy.getWidgetStruct());
394 * Returns the proxy widgets for an action.
395 * See also gtk_widget_get_action().
396 * action:
397 * the action object
398 * Returns:
399 * a GSList of proxy widgets. The list is owned by GTK+
400 * and must not be modified.
401 * Since 2.4
403 public ListSG getProxies()
405 // GSList* gtk_action_get_proxies (GtkAction *action);
406 return new ListSG( gtk_action_get_proxies(gtkAction) );
410 * Installs the accelerator for action if action has an
411 * accel path and group. See gtk_action_set_accel_path() and
412 * gtk_action_set_accel_group()
413 * Since multiple proxies may independently trigger the installation
414 * of the accelerator, the action counts the number of times this
415 * function has been called and doesn't remove the accelerator until
416 * gtk_action_disconnect_accelerator() has been called as many times.
417 * action:
418 * a GtkAction
419 * Since 2.4
421 public void connectAccelerator()
423 // void gtk_action_connect_accelerator (GtkAction *action);
424 gtk_action_connect_accelerator(gtkAction);
428 * Undoes the effect of one call to gtk_action_connect_accelerator().
429 * action:
430 * a GtkAction
431 * Since 2.4
433 public void disconnectAccelerator()
435 // void gtk_action_disconnect_accelerator (GtkAction *action);
436 gtk_action_disconnect_accelerator(gtkAction);
440 * Disables calls to the gtk_action_activate()
441 * function by signals on the given proxy widget. This is used to
442 * break notification loops for things like check or radio actions.
443 * This function is intended for use by action implementations.
444 * action:
445 * the action object
446 * proxy:
447 * a proxy widget
448 * Since 2.4
450 public void blockActivateFrom(Widget proxy)
452 // void gtk_action_block_activate_from (GtkAction *action, GtkWidget *proxy);
453 gtk_action_block_activate_from(gtkAction, (proxy is null) ? null : proxy.getWidgetStruct());
457 * Re-enables calls to the gtk_action_activate()
458 * function by signals on the given proxy widget. This undoes the
459 * blocking done by gtk_action_block_activate_from().
460 * This function is intended for use by action implementations.
461 * action:
462 * the action object
463 * proxy:
464 * a proxy widget
465 * Since 2.4
467 public void unblockActivateFrom(Widget proxy)
469 // void gtk_action_unblock_activate_from (GtkAction *action, GtkWidget *proxy);
470 gtk_action_unblock_activate_from(gtkAction, (proxy is null) ? null : proxy.getWidgetStruct());
474 * Returns the accel path for this action.
475 * action:
476 * the action object
477 * Returns:
478 * the accel path for this action, or NULL
479 * if none is set. The returned string is owned by GTK+
480 * and must not be freed or modified.
481 * Since 2.6
483 public char[] getAccelPath()
485 // const gchar* gtk_action_get_accel_path (GtkAction *action);
486 return Str.toString(gtk_action_get_accel_path(gtkAction) );
490 * Sets the accel path for this action. All proxy widgets associated
491 * with the action will have this accel path, so that their
492 * accelerators are consistent.
493 * action:
494 * the action object
495 * accel_path:
496 * the accelerator path
497 * Since 2.4
499 public void setAccelPath(char[] accelPath)
501 // void gtk_action_set_accel_path (GtkAction *action, const gchar *accel_path);
502 gtk_action_set_accel_path(gtkAction, Str.toStringz(accelPath));
506 * Returns the accel closure for this action.
507 * action:
508 * the action object
509 * Returns:
510 * the accel closure for this action. The returned closure is
511 * owned by GTK+ and must not be unreffed or modified.
512 * Since 2.8
514 public Closure getAccelClosure()
516 // GClosure* gtk_action_get_accel_closure (GtkAction *action);
517 return new Closure( gtk_action_get_accel_closure(gtkAction) );
521 * Sets the GtkAccelGroup in which the accelerator for this action
522 * will be installed.
523 * action:
524 * the action object
525 * accel_group:
526 * a GtkAccelGroup or NULL
527 * Since 2.4
528 * Property Details
529 * The "action-group" property
530 * "action-group" GtkActionGroup : Read / Write
531 * The GtkActionGroup this GtkAction is associated with, or NULL (for internal use).
533 public void setAccelGroup(AccelGroup accelGroup)
535 // void gtk_action_set_accel_group (GtkAction *action, GtkAccelGroup *accel_group);
536 gtk_action_set_accel_group(gtkAction, (accelGroup is null) ? null : accelGroup.getAccelGroupStruct());