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  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ListSG
49  * structWrap:
50  * 	- GSList* -> ListSG
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gtk.RadioAction;
57 
58 public  import gtkc.gtktypes;
59 
60 private import gtkc.gtk;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 private import gobject.Signals;
65 public  import gtkc.gdktypes;
66 
67 private import glib.Str;
68 private import glib.ListSG;
69 
70 
71 
72 private import gtk.ToggleAction;
73 
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.
79  */
80 public class RadioAction : ToggleAction
81 {
82 	
83 	/** the main Gtk struct */
84 	protected GtkRadioAction* gtkRadioAction;
85 	
86 	
87 	public GtkRadioAction* getRadioActionStruct()
88 	{
89 		return gtkRadioAction;
90 	}
91 	
92 	
93 	/** the main Gtk struct as a void* */
94 	protected override void* getStruct()
95 	{
96 		return cast(void*)gtkRadioAction;
97 	}
98 	
99 	/**
100 	 * Sets our main struct and passes it to the parent class
101 	 */
102 	public this (GtkRadioAction* gtkRadioAction)
103 	{
104 		super(cast(GtkToggleAction*)gtkRadioAction);
105 		this.gtkRadioAction = gtkRadioAction;
106 	}
107 	
108 	protected override void setStruct(GObject* obj)
109 	{
110 		super.setStruct(obj);
111 		gtkRadioAction = cast(GtkRadioAction*)obj;
112 	}
113 	
114 	/**
115 	 * Creates a new GtkRadioAction object. To add the action to
116 	 * a GtkActionGroup and set the accelerator for the action,
117 	 * call gtk_action_group_add_action_with_accel().
118 	 * Since 2.4
119 	 * Params:
120 	 * name =  A unique name for the action
121 	 * label =  The label displayed in menu items and on buttons, or NULL
122 	 * tooltip =  A tooltip for this action, or NULL
123 	 * stockId =  The stock icon to display in widgets representing this
124 	 *  action, or NULL
125 	 * value =  The value which gtk_radio_action_get_current_value() should
126 	 *  return if this action is selected.
127 	 * Throws: ConstructionException GTK+ fails to create the object.
128 	 */
129 	public this (string name, string label, string tooltip, StockID stockId, int value)
130 	{
131 		this(name, label, tooltip, StockDesc[stockId], value);
132 	}
133 	
134 	/**
135 	 */
136 	int[string] connectedSignals;
137 	
138 	void delegate(GtkRadioAction*, RadioAction)[] onChangedListeners;
139 	/**
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 	 * Creates a new GtkRadioAction object. To add the action to
171 	 * a GtkActionGroup and set the accelerator for the action,
172 	 * call gtk_action_group_add_action_with_accel().
173 	 * Since 2.4
174 	 * Params:
175 	 * name = A unique name for the action
176 	 * label = The label displayed in menu items and on buttons, or NULL. [allow-none]
177 	 * tooltip = A tooltip for this action, or NULL. [allow-none]
178 	 * stockId = The stock icon to display in widgets representing this
179 	 * action, or NULL
180 	 * value = The value which gtk_radio_action_get_current_value() should
181 	 * return if this action is selected.
182 	 * Throws: ConstructionException GTK+ fails to create the object.
183 	 */
184 	public this (string name, string label, string tooltip, string stockId, int value)
185 	{
186 		// GtkRadioAction * gtk_radio_action_new (const gchar *name,  const gchar *label,  const gchar *tooltip,  const gchar *stock_id,  gint value);
187 		auto p = gtk_radio_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId), value);
188 		if(p is null)
189 		{
190 			throw new ConstructionException("null returned by gtk_radio_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId), value)");
191 		}
192 		this(cast(GtkRadioAction*) p);
193 	}
194 	
195 	/**
196 	 * Returns the list representing the radio group for this object.
197 	 * Note that the returned list is only valid until the next change
198 	 * to the group.
199 	 * Since 2.4
200 	 * Returns: the list representing the radio group for this object. [element-type GtkAction][transfer none]
201 	 */
202 	public ListSG getGroup()
203 	{
204 		// GSList * gtk_radio_action_get_group (GtkRadioAction *action);
205 		auto p = gtk_radio_action_get_group(gtkRadioAction);
206 		
207 		if(p is null)
208 		{
209 			return null;
210 		}
211 		
212 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
213 	}
214 	
215 	/**
216 	 * Sets the radio group for the radio action object.
217 	 * Since 2.4
218 	 * Params:
219 	 * group = a list representing a radio group
220 	 */
221 	public void setGroup(ListSG group)
222 	{
223 		// void gtk_radio_action_set_group (GtkRadioAction *action,  GSList *group);
224 		gtk_radio_action_set_group(gtkRadioAction, (group is null) ? null : group.getListSGStruct());
225 	}
226 	
227 	/**
228 	 * Obtains the value property of the currently active member of
229 	 * the group to which action belongs.
230 	 * Since 2.4
231 	 * Returns: The value of the currently active group member
232 	 */
233 	public int getCurrentValue()
234 	{
235 		// gint gtk_radio_action_get_current_value (GtkRadioAction *action);
236 		return gtk_radio_action_get_current_value(gtkRadioAction);
237 	}
238 	
239 	/**
240 	 * Sets the currently active group member to the member with value
241 	 * property current_value.
242 	 * Since 2.10
243 	 * Params:
244 	 * currentValue = the new value
245 	 */
246 	public void setCurrentValue(int currentValue)
247 	{
248 		// void gtk_radio_action_set_current_value (GtkRadioAction *action,  gint current_value);
249 		gtk_radio_action_set_current_value(gtkRadioAction, currentValue);
250 	}
251 }