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  = GtkRadioMenuItem.html
27  * outPack = gtk
28  * outFile = RadioMenuItem
29  * strct   = GtkRadioMenuItem
30  * realStrct=
31  * ctorStrct=
32  * clss    = RadioMenuItem
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_radio_menu_item_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gtk_radio_menu_item_new_with_label
45  * 	- gtk_radio_menu_item_new_with_mnemonic
46  * 	- gtk_radio_menu_item_new_with_mnemonic_from_widget
47  * 	- gtk_radio_menu_item_new_with_label_from_widget
48  * omit signals:
49  * imports:
50  * 	- glib.Str
51  * 	- glib.ListSG
52  * structWrap:
53  * 	- GSList* -> ListSG
54  * 	- GtkRadioMenuItem* -> RadioMenuItem
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gtk.RadioMenuItem;
61 
62 public  import gtkc.gtktypes;
63 
64 private import gtkc.gtk;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 private import gobject.Signals;
69 public  import gtkc.gdktypes;
70 private import glib.Str;
71 private import glib.ListSG;
72 
73 
74 private import gtk.CheckMenuItem;
75 
76 /**
77  * A radio menu item is a check menu item that belongs to a group. At each
78  * instant exactly one of the radio menu items from a group is selected.
79  *
80  * The group list does not need to be freed, as each GtkRadioMenuItem will
81  * remove itself and its list item when it is destroyed.
82  *
83  * The correct way to create a group of radio menu items is approximatively
84  * this:
85  *
86  * $(DDOC_COMMENT example)
87  */
88 public class RadioMenuItem : CheckMenuItem
89 {
90 	
91 	/** the main Gtk struct */
92 	protected GtkRadioMenuItem* gtkRadioMenuItem;
93 	
94 	
95 	/** Get the main Gtk struct */
96 	public GtkRadioMenuItem* getRadioMenuItemStruct()
97 	{
98 		return gtkRadioMenuItem;
99 	}
100 	
101 	
102 	/** the main Gtk struct as a void* */
103 	protected override void* getStruct()
104 	{
105 		return cast(void*)gtkRadioMenuItem;
106 	}
107 	
108 	/**
109 	 * Sets our main struct and passes it to the parent class
110 	 */
111 	public this (GtkRadioMenuItem* gtkRadioMenuItem)
112 	{
113 		super(cast(GtkCheckMenuItem*)gtkRadioMenuItem);
114 		this.gtkRadioMenuItem = gtkRadioMenuItem;
115 	}
116 	
117 	protected override void setStruct(GObject* obj)
118 	{
119 		super.setStruct(obj);
120 		gtkRadioMenuItem = cast(GtkRadioMenuItem*)obj;
121 	}
122 	
123 	/**
124 	 * Creates a new GtkRadioMenuItem whose child is a simple GtkLabel.
125 	 * The new GtkRadioMenuItem is added to the same group as group.
126 	 * If mnemonic is true the label will be
127 	 * created using gtk_label_new_with_mnemonic(), so underscores in label
128 	 * indicate the mnemonic for the menu item.
129 	 * Since 2.4
130 	 * Params:
131 	 *  group = an existing GtkRadioMenuItem
132 	 *  label = the text for the label
133 	 * Throws: ConstructionException GTK+ fails to create the object.
134 	 */
135 	public this (RadioMenuItem radioMenuItem, string label, bool mnemonic=true)
136 	{
137 		GtkRadioMenuItem* p;
138 		
139 		if ( mnemonic )
140 		{
141 			// GtkWidget* gtk_radio_menu_item_new_with_mnemonic_from_widget  (GtkRadioMenuItem *group,  const gchar *label);
142 			p = cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_with_mnemonic_from_widget(
143 			radioMenuItem.getRadioMenuItemStruct(), Str.toStringz(label));
144 		}
145 		else
146 		{
147 			// GtkWidget* gtk_radio_menu_item_new_with_label_from_widget  (GtkRadioMenuItem *group,  const gchar *label);
148 			p = cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_with_label_from_widget(
149 			radioMenuItem.getRadioMenuItemStruct(), Str.toStringz(label));
150 		}
151 		
152 		if(p is null)
153 		{
154 			throw new ConstructionException("null returned by gtk_radio_menu_item_new_with_");
155 		}
156 		
157 		this(p);
158 	}
159 	
160 	/**
161 	 * Creates a new GtkRadioMenuItem whose child is a simple GtkLabel.
162 	 * Params:
163 	 *  group = the group to which the radio menu item is to be attached
164 	 *  label = the text for the label
165 	 *  mnemonic = if true the label
166 	 *  will be created using gtk_label_new_with_mnemonic(), so underscores
167 	 *  in label indicate the mnemonic for the menu item.
168 	 * Throws: ConstructionException GTK+ fails to create the object.
169 	 */
170 	public this (ListSG group, string label, bool mnemonic=true)
171 	{
172 		GtkRadioMenuItem* p;
173 		
174 		if ( mnemonic )
175 		{
176 			// GtkWidget* gtk_radio_menu_item_new_with_mnemonic  (GSList *group,  const gchar *label);
177 			p = cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_with_mnemonic(
178 			group is null ? null : group.getListSGStruct(), Str.toStringz(label));
179 		}
180 		else
181 		{
182 			// GtkWidget* gtk_radio_menu_item_new_with_label  (GSList *group,  const gchar *label);
183 			p = cast(GtkRadioMenuItem*)gtk_radio_menu_item_new_with_label(
184 			group is null ? null : group.getListSGStruct(), Str.toStringz(label));
185 		}
186 		
187 		if(p is null)
188 		{
189 			throw new ConstructionException("null returned by gtk_radio_menu_item_new_with_");
190 		}
191 		
192 		this(p);
193 	}
194 	
195 	/**
196 	 */
197 	int[string] connectedSignals;
198 	
199 	void delegate(RadioMenuItem)[] onGroupChangedListeners;
200 	/**
201 	 * See Also
202 	 * GtkMenuItem, GtkCheckMenuItem
203 	 */
204 	void addOnGroupChanged(void delegate(RadioMenuItem) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
205 	{
206 		if ( !("group-changed" in connectedSignals) )
207 		{
208 			Signals.connectData(
209 			getStruct(),
210 			"group-changed",
211 			cast(GCallback)&callBackGroupChanged,
212 			cast(void*)this,
213 			null,
214 			connectFlags);
215 			connectedSignals["group-changed"] = 1;
216 		}
217 		onGroupChangedListeners ~= dlg;
218 	}
219 	extern(C) static void callBackGroupChanged(GtkRadioMenuItem* radiomenuitemStruct, RadioMenuItem _radioMenuItem)
220 	{
221 		foreach ( void delegate(RadioMenuItem) dlg ; _radioMenuItem.onGroupChangedListeners )
222 		{
223 			dlg(_radioMenuItem);
224 		}
225 	}
226 	
227 	
228 	/**
229 	 * Creates a new GtkRadioMenuItem.
230 	 * Params:
231 	 * group = the group to which the
232 	 * radio menu item is to be attached. [element-type GtkRadioMenuItem]
233 	 * Throws: ConstructionException GTK+ fails to create the object.
234 	 */
235 	public this (ListSG group)
236 	{
237 		// GtkWidget * gtk_radio_menu_item_new (GSList *group);
238 		auto p = gtk_radio_menu_item_new((group is null) ? null : group.getListSGStruct());
239 		if(p is null)
240 		{
241 			throw new ConstructionException("null returned by gtk_radio_menu_item_new((group is null) ? null : group.getListSGStruct())");
242 		}
243 		this(cast(GtkRadioMenuItem*) p);
244 	}
245 	
246 	/**
247 	 * Creates a new GtkRadioMenuItem adding it to the same group as group.
248 	 * Since 2.4
249 	 * Params:
250 	 * group = An existing GtkRadioMenuItem
251 	 * Throws: ConstructionException GTK+ fails to create the object.
252 	 */
253 	public this (RadioMenuItem group)
254 	{
255 		// GtkWidget * gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group);
256 		auto p = gtk_radio_menu_item_new_from_widget((group is null) ? null : group.getRadioMenuItemStruct());
257 		if(p is null)
258 		{
259 			throw new ConstructionException("null returned by gtk_radio_menu_item_new_from_widget((group is null) ? null : group.getRadioMenuItemStruct())");
260 		}
261 		this(cast(GtkRadioMenuItem*) p);
262 	}
263 	
264 	/**
265 	 * Sets the group of a radio menu item, or changes it.
266 	 * Params:
267 	 * group = the new group. [element-type GtkRadioMenuItem]
268 	 */
269 	public void setGroup(ListSG group)
270 	{
271 		// void gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item,  GSList *group);
272 		gtk_radio_menu_item_set_group(gtkRadioMenuItem, (group is null) ? null : group.getListSGStruct());
273 	}
274 	
275 	/**
276 	 * Returns the group to which the radio menu item belongs, as a GList of
277 	 * GtkRadioMenuItem. The list belongs to GTK+ and should not be freed.
278 	 * Returns: the group of radio_menu_item. [element-type GtkRadioMenuItem][transfer none]
279 	 */
280 	public ListSG getGroup()
281 	{
282 		// GSList * gtk_radio_menu_item_get_group (GtkRadioMenuItem *radio_menu_item);
283 		auto p = gtk_radio_menu_item_get_group(gtkRadioMenuItem);
284 		
285 		if(p is null)
286 		{
287 			return null;
288 		}
289 		
290 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
291 	}
292 }