alternative to assert
[gtkD.git] / gtkD / src / gtk / RadioAction.d
blobf982a1756591a067d93e3120f9d21240e8188aca
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 = GtkRadioAction.html
26 * outPack = gtk
27 * outFile = RadioAction
28 * strct = GtkRadioAction
29 * realStrct=
30 * ctorStrct=
31 * clss = RadioAction
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_radio_action_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - glib.ListSG
47 * structWrap:
48 * - GSList* -> ListSG
49 * module aliases:
50 * local aliases:
53 module gtk.RadioAction;
55 version(noAssert)
57 version(Tango)
59 import tango.io.Stdout; // use the tango loging?
63 private import gtkc.gtktypes;
65 private import gtkc.gtk;
68 private import glib.Str;
69 private import glib.ListSG;
74 /**
75 * Description
76 * A GtkRadioAction is similar to GtkRadioMenuItem. A number of radio
77 * actions can be linked together so that only one may be active at any
78 * one time.
80 private import gtk.ToggleAction;
81 public class RadioAction : ToggleAction
84 /** the main Gtk struct */
85 protected GtkRadioAction* gtkRadioAction;
88 public GtkRadioAction* getRadioActionStruct()
90 return gtkRadioAction;
94 /** the main Gtk struct as a void* */
95 protected void* getStruct()
97 return cast(void*)gtkRadioAction;
101 * Sets our main struct and passes it to the parent class
103 public this (GtkRadioAction* gtkRadioAction)
105 version(noAssert)
107 if ( gtkRadioAction is null )
109 int zero = 0;
110 version(Tango)
112 Stdout("struct gtkRadioAction is null on constructor").newline;
114 else
116 printf("struct gtkRadioAction is null on constructor");
118 zero = zero / zero;
121 else
123 assert(gtkRadioAction !is null, "struct gtkRadioAction is null on constructor");
125 super(cast(GtkToggleAction*)gtkRadioAction);
126 this.gtkRadioAction = gtkRadioAction;
132 // imports for the signal processing
133 private import gobject.Signals;
134 private import gtkc.gdktypes;
135 int[char[]] connectedSignals;
137 void delegate(GtkRadioAction*, RadioAction)[] onChangedListeners;
138 void addOnChanged(void delegate(GtkRadioAction*, RadioAction) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
140 if ( !("changed" in connectedSignals) )
142 Signals.connectData(
143 getStruct(),
144 "changed",
145 cast(GCallback)&callBackChanged,
146 cast(void*)this,
147 null,
148 connectFlags);
149 connectedSignals["changed"] = 1;
151 onChangedListeners ~= dlg;
153 extern(C) static void callBackChanged(GtkRadioAction* actionStruct, GtkRadioAction* current, RadioAction radioAction)
155 bool consumed = false;
157 foreach ( void delegate(GtkRadioAction*, RadioAction) dlg ; radioAction.onChangedListeners )
159 dlg(current, radioAction);
162 return consumed;
168 * Creates a new GtkRadioAction object. To add the action to
169 * a GtkActionGroup and set the accelerator for the action,
170 * call gtk_action_group_add_action_with_accel().
171 * name:
172 * A unique name for the action
173 * label:
174 * The label displayed in menu items and on buttons
175 * tooltip:
176 * A tooltip for this action
177 * stock_id:
178 * The stock icon to display in widgets representing this action
179 * value:
180 * The value which gtk_radio_action_get_current_value() should return
181 * if this action is selected.
182 * Returns:
183 * a new GtkRadioAction
184 * Since 2.4
186 public this (char[] name, char[] label, char[] tooltip, char[] stockId, int value)
188 // GtkRadioAction* gtk_radio_action_new (const gchar *name, const gchar *label, const gchar *tooltip, const gchar *stock_id, gint value);
189 this(cast(GtkRadioAction*)gtk_radio_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId), value) );
193 * Returns the list representing the radio group for this object.
194 * Note that the returned list is only valid until the next change
195 * to the group.
196 * A common way to set up a group of radio group is the following:
197 * GSList *group = NULL;
198 * GtkRadioAction *action;
199 * while (/+* more actions to add +/)
201 * action = gtk_radio_action_new (...);
202 * gtk_radio_action_set_group (action, group);
203 * group = gtk_radio_action_get_group (action);
205 * action:
206 * the action object
207 * Returns:
208 * the list representing the radio group for this object
209 * Since 2.4
211 public ListSG getGroup()
213 // GSList* gtk_radio_action_get_group (GtkRadioAction *action);
214 return new ListSG( gtk_radio_action_get_group(gtkRadioAction) );
218 * Sets the radio group for the radio action object.
219 * action:
220 * the action object
221 * group:
222 * a list representing a radio group
223 * Since 2.4
225 public void setGroup(ListSG group)
227 // void gtk_radio_action_set_group (GtkRadioAction *action, GSList *group);
228 gtk_radio_action_set_group(gtkRadioAction, (group is null) ? null : group.getListSGStruct());
232 * Obtains the value property of the currently active member of
233 * the group to which action belongs.
234 * action:
235 * a GtkRadioAction
236 * Returns:
237 * The value of the currently active group member
238 * Since 2.4
240 public int getCurrentValue()
242 // gint gtk_radio_action_get_current_value (GtkRadioAction *action);
243 return gtk_radio_action_get_current_value(gtkRadioAction);
247 * Sets the currently active group member to the member with value
248 * property current_value.
249 * action:
250 * a GtkRadioAction
251 * current_value:
252 * the new value
253 * Since 2.10
254 * Property Details
255 * The "current-value" property
256 * "current-value" gint : Read / Write
257 * The value property of the currently active member of the group to which
258 * this action belongs.
259 * Default value: 0
260 * Since 2.10
262 public void setCurrentValue(int currentValue)
264 // void gtk_radio_action_set_current_value (GtkRadioAction *action, gint current_value);
265 gtk_radio_action_set_current_value(gtkRadioAction, currentValue);