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
51 * - GClosure* -> Closure
53 * - GtkAccelGroup* -> AccelGroup
54 * - GtkWidget* -> Widget
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
;
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
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)
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
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()
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
) )
142 cast(GCallback
)&callBackActivate
,
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
)
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
171 * A unique name for the action
173 * the label displayed in menu items and on buttons
175 * a tooltip for the action
177 * the stock icon to display in widgets representing the action
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.
193 * the name of the action. The string belongs to GTK+ and should not
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.
208 * TRUE if the action and its associated action group
209 * are both sensitive.
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()
225 * TRUE if the action itself is sensitive.
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()
242 * TRUE to make the action sensitive
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.
256 * TRUE if the action and its associated action group
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()
273 * TRUE if the action itself is visible.
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()
290 * TRUE to make the action visible
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
303 * It can also be used to manually activate an action.
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.
320 * the size of the icon that should be created.
322 * a widget that displays the icon for this action.
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.
336 * a menu item connected to the action.
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.
350 * a toolbar item connected to the action.
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
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.
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().
399 * a GSList of proxy widgets. The list is owned by GTK+
400 * and must not be modified.
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.
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().
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.
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.
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.
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.
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.
496 * the accelerator path
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.
510 * the accel closure for this action. The returned closure is
511 * owned by GTK+ and must not be unreffed or modified.
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
526 * a GtkAccelGroup or NULL
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());