1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GtkRadioAction.html
27  * outPack = gtk
28  * outFile = RadioAction
29  * strct   = GtkRadioAction
30  * realStrct=
31  * ctorStrct=
32  * clss    = RadioAction
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_radio_action_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ListSG
48  * structWrap:
49  * 	- GSList* -> ListSG
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gtk.RadioAction;
56 
57 public  import gtkc.gtktypes;
58 
59 private import gtkc.gtk;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 private import gobject.Signals;
64 public  import gtkc.gdktypes;
65 
66 private import glib.Str;
67 private import glib.ListSG;
68 
69 
70 
71 private import gtk.ToggleAction;
72 
73 /**
74  * A GtkRadioAction is similar to GtkRadioMenuItem. A number of radio
75  * actions can be linked together so that only one may be active at any
76  * one time.
77  */
78 public class RadioAction : ToggleAction
79 {
80 	
81 	/** the main Gtk struct */
82 	protected GtkRadioAction* gtkRadioAction;
83 	
84 	
85 	public GtkRadioAction* getRadioActionStruct()
86 	{
87 		return gtkRadioAction;
88 	}
89 	
90 	
91 	/** the main Gtk struct as a void* */
92 	protected override void* getStruct()
93 	{
94 		return cast(void*)gtkRadioAction;
95 	}
96 	
97 	/**
98 	 * Sets our main struct and passes it to the parent class
99 	 */
100 	public this (GtkRadioAction* gtkRadioAction)
101 	{
102 		super(cast(GtkToggleAction*)gtkRadioAction);
103 		this.gtkRadioAction = gtkRadioAction;
104 	}
105 	
106 	protected override void setStruct(GObject* obj)
107 	{
108 		super.setStruct(obj);
109 		gtkRadioAction = cast(GtkRadioAction*)obj;
110 	}
111 	
112 	/**
113 	 * Creates a new GtkRadioAction object. To add the action to
114 	 * a GtkActionGroup and set the accelerator for the action,
115 	 * call gtk_action_group_add_action_with_accel().
116 	 * Since 2.4
117 	 * Params:
118 	 * name =  A unique name for the action
119 	 * label =  The label displayed in menu items and on buttons, or NULL
120 	 * tooltip =  A tooltip for this action, or NULL
121 	 * stockId =  The stock icon to display in widgets representing this
122 	 *  action, or NULL
123 	 * value =  The value which gtk_radio_action_get_current_value() should
124 	 *  return if this action is selected.
125 	 * Throws: ConstructionException GTK+ fails to create the object.
126 	 */
127 	public this (string name, string label, string tooltip, StockID stockId, int value)
128 	{
129 		this(name, label, tooltip, StockDesc[stockId], value);
130 	}
131 	
132 	/**
133 	 */
134 	int[string] connectedSignals;
135 	
136 	void delegate(GtkRadioAction*, RadioAction)[] onChangedListeners;
137 	/**
138 	 * Warning
139 	 * GtkRadioAction::changed is deprecated and should not be used in newly-written code. 3.10
140 	 * The ::changed signal is emitted on every member of a radio group when the
141 	 * active member is changed. The signal gets emitted after the ::activate signals
142 	 * for the previous and current active members.
143 	 * Since 2.4
144 	 */
145 	void addOnChanged(void delegate(GtkRadioAction*, RadioAction) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
146 	{
147 		if ( !("changed" in connectedSignals) )
148 		{
149 			Signals.connectData(
150 			getStruct(),
151 			"changed",
152 			cast(GCallback)&callBackChanged,
153 			cast(void*)this,
154 			null,
155 			connectFlags);
156 			connectedSignals["changed"] = 1;
157 		}
158 		onChangedListeners ~= dlg;
159 	}
160 	extern(C) static void callBackChanged(GtkRadioAction* actionStruct, GtkRadioAction* current, RadioAction _radioAction)
161 	{
162 		foreach ( void delegate(GtkRadioAction*, RadioAction) dlg ; _radioAction.onChangedListeners )
163 		{
164 			dlg(current, _radioAction);
165 		}
166 	}
167 	
168 	
169 	/**
170 	 * Warning
171 	 * gtk_radio_action_new is deprecated and should not be used in newly-written code. 3.10
172 	 * Creates a new GtkRadioAction object. To add the action to
173 	 * a GtkActionGroup and set the accelerator for the action,
174 	 * call gtk_action_group_add_action_with_accel().
175 	 * Since 2.4
176 	 * Params:
177 	 * name = A unique name for the action
178 	 * label = The label displayed in menu items and on buttons,
179 	 * or NULL. [allow-none]
180 	 * tooltip = A tooltip for this action, or NULL. [allow-none]
181 	 * stockId = The stock icon to display in widgets representing
182 	 * this action, or NULL. [allow-none]
183 	 * value = The value which gtk_radio_action_get_current_value() should
184 	 * return if this action is selected.
185 	 * Throws: ConstructionException GTK+ fails to create the object.
186 	 */
187 	public this (string name, string label, string tooltip, string stockId, int value)
188 	{
189 		// GtkRadioAction * gtk_radio_action_new (const gchar *name,  const gchar *label,  const gchar *tooltip,  const gchar *stock_id,  gint value);
190 		auto p = gtk_radio_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId), value);
191 		if(p is null)
192 		{
193 			throw new ConstructionException("null returned by gtk_radio_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId), value)");
194 		}
195 		this(cast(GtkRadioAction*) p);
196 	}
197 	
198 	/**
199 	 * Warning
200 	 * gtk_radio_action_get_group is deprecated and should not be used in newly-written code. 3.10
201 	 * Returns the list representing the radio group for this object.
202 	 * Note that the returned list is only valid until the next change
203 	 * to the group.
204 	 * Since 2.4
205 	 * Returns: the list representing the radio group for this object. [element-type GtkRadioAction][transfer none]
206 	 */
207 	public ListSG getGroup()
208 	{
209 		// GSList * gtk_radio_action_get_group (GtkRadioAction *action);
210 		auto p = gtk_radio_action_get_group(gtkRadioAction);
211 		
212 		if(p is null)
213 		{
214 			return null;
215 		}
216 		
217 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
218 	}
219 	
220 	/**
221 	 * Warning
222 	 * gtk_radio_action_set_group is deprecated and should not be used in newly-written code. 3.10
223 	 * Sets the radio group for the radio action object.
224 	 * Since 2.4
225 	 * Params:
226 	 * group = a list representing a radio group. [element-type GtkRadioAction]
227 	 */
228 	public void setGroup(ListSG group)
229 	{
230 		// void gtk_radio_action_set_group (GtkRadioAction *action,  GSList *group);
231 		gtk_radio_action_set_group(gtkRadioAction, (group is null) ? null : group.getListSGStruct());
232 	}
233 	
234 	/**
235 	 * Warning
236 	 * gtk_radio_action_join_group is deprecated and should not be used in newly-written code. 3.10
237 	 * Joins a radio action object to the group of another radio action object.
238 	 * Use this in language bindings instead of the gtk_radio_action_get_group()
239 	 * and gtk_radio_action_set_group() methods
240 	 * Params:
241 	 * groupSource = a radio action object whos group we are
242 	 * joining, or NULL to remove the radio action from its group. [allow-none]
243 	 * Since 3.0
244 	 */
245 	public void joinGroup(GtkRadioAction* groupSource)
246 	{
247 		// void gtk_radio_action_join_group (GtkRadioAction *action,  GtkRadioAction *group_source);
248 		gtk_radio_action_join_group(gtkRadioAction, groupSource);
249 	}
250 	
251 	/**
252 	 * Warning
253 	 * gtk_radio_action_get_current_value is deprecated and should not be used in newly-written code. 3.10
254 	 * Obtains the value property of the currently active member of
255 	 * the group to which action belongs.
256 	 * Since 2.4
257 	 * Returns: The value of the currently active group member
258 	 */
259 	public int getCurrentValue()
260 	{
261 		// gint gtk_radio_action_get_current_value (GtkRadioAction *action);
262 		return gtk_radio_action_get_current_value(gtkRadioAction);
263 	}
264 	
265 	/**
266 	 * Warning
267 	 * gtk_radio_action_set_current_value is deprecated and should not be used in newly-written code. 3.10
268 	 * Sets the currently active group member to the member with value
269 	 * property current_value.
270 	 * Since 2.10
271 	 * Params:
272 	 * currentValue = the new value
273 	 */
274 	public void setCurrentValue(int currentValue)
275 	{
276 		// void gtk_radio_action_set_current_value (GtkRadioAction *action,  gint current_value);
277 		gtk_radio_action_set_current_value(gtkRadioAction, currentValue);
278 	}
279 }