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