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  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * 	- gtk_radio_menu_item_new_with_label
46  * 	- gtk_radio_menu_item_new_with_mnemonic
47  * 	- gtk_radio_menu_item_new_with_mnemonic_from_widget
48  * 	- gtk_radio_menu_item_new_with_label_from_widget
49  * omit signals:
50  * imports:
51  * 	- glib.Str
52  * 	- glib.ListSG
53  * structWrap:
54  * 	- GSList* -> ListSG
55  * 	- GtkRadioMenuItem* -> RadioMenuItem
56  * module aliases:
57  * local aliases:
58  * overrides:
59  */
60 
61 module gtk.RadioMenuItem;
62 
63 public  import gtkc.gtktypes;
64 
65 private import gtkc.gtk;
66 private import glib.ConstructionException;
67 private import gobject.ObjectG;
68 
69 private import gobject.Signals;
70 public  import gtkc.gdktypes;
71 
72 private import glib.Str;
73 private import glib.ListSG;
74 
75 
76 
77 private import gtk.CheckMenuItem;
78 
79 /**
80  * Description
81  * A radio menu item is a check menu item that belongs to a group. At each
82  * instant exactly one of the radio menu items from a group is selected.
83  * The group list does not need to be freed, as each GtkRadioMenuItem will
84  * remove itself and its list item when it is destroyed.
85  * The correct way to create a group of radio menu items is approximatively
86  * this:
87  * $(DDOC_COMMENT example)
88  */
89 public class RadioMenuItem : CheckMenuItem
90 {
91 	
92 	/** the main Gtk struct */
93 	protected GtkRadioMenuItem* gtkRadioMenuItem;
94 	
95 	
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
203 	 * because a radio menu item is a menu item.
204 	 * GtkCheckMenuItem
205 	 * to know how to handle the check.
206 	 */
207 	void addOnGroupChanged(void delegate(RadioMenuItem) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
208 	{
209 		if ( !("group-changed" in connectedSignals) )
210 		{
211 			Signals.connectData(
212 			getStruct(),
213 			"group-changed",
214 			cast(GCallback)&callBackGroupChanged,
215 			cast(void*)this,
216 			null,
217 			connectFlags);
218 			connectedSignals["group-changed"] = 1;
219 		}
220 		onGroupChangedListeners ~= dlg;
221 	}
222 	extern(C) static void callBackGroupChanged(GtkRadioMenuItem* radiomenuitemStruct, RadioMenuItem _radioMenuItem)
223 	{
224 		foreach ( void delegate(RadioMenuItem) dlg ; _radioMenuItem.onGroupChangedListeners )
225 		{
226 			dlg(_radioMenuItem);
227 		}
228 	}
229 	
230 	
231 	/**
232 	 * Creates a new GtkRadioMenuItem.
233 	 * Params:
234 	 * group = the group to which the radio menu item is to be attached
235 	 * Throws: ConstructionException GTK+ fails to create the object.
236 	 */
237 	public this (ListSG group)
238 	{
239 		// GtkWidget * gtk_radio_menu_item_new (GSList *group);
240 		auto p = gtk_radio_menu_item_new((group is null) ? null : group.getListSGStruct());
241 		if(p is null)
242 		{
243 			throw new ConstructionException("null returned by gtk_radio_menu_item_new((group is null) ? null : group.getListSGStruct())");
244 		}
245 		this(cast(GtkRadioMenuItem*) p);
246 	}
247 	
248 	/**
249 	 * Creates a new GtkRadioMenuItem adding it to the same group as group.
250 	 * Since 2.4
251 	 * Params:
252 	 * group = An existing GtkRadioMenuItem
253 	 * Throws: ConstructionException GTK+ fails to create the object.
254 	 */
255 	public this (RadioMenuItem group)
256 	{
257 		// GtkWidget * gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group);
258 		auto p = gtk_radio_menu_item_new_from_widget((group is null) ? null : group.getRadioMenuItemStruct());
259 		if(p is null)
260 		{
261 			throw new ConstructionException("null returned by gtk_radio_menu_item_new_from_widget((group is null) ? null : group.getRadioMenuItemStruct())");
262 		}
263 		this(cast(GtkRadioMenuItem*) p);
264 	}
265 	
266 	/**
267 	 * Sets the group of a radio menu item, or changes it.
268 	 * Params:
269 	 * group = the new group.
270 	 */
271 	public void setGroup(ListSG group)
272 	{
273 		// void gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item,  GSList *group);
274 		gtk_radio_menu_item_set_group(gtkRadioMenuItem, (group is null) ? null : group.getListSGStruct());
275 	}
276 	
277 	/**
278 	 * Returns the group to which the radio menu item belongs, as a GList of
279 	 * GtkRadioMenuItem. The list belongs to GTK+ and should not be freed.
280 	 * Returns the group to which the radio menu item belongs, as a GList of
281 	 * GtkRadioMenuItem. The list belongs to GTK+ and should not be freed.
282 	 * Returns: the group of radio_menu_item. [transfer none]
283 	 */
284 	public ListSG getGroup()
285 	{
286 		// GSList * gtk_radio_menu_item_get_group (GtkRadioMenuItem *radio_menu_item);
287 		auto p = gtk_radio_menu_item_get_group(gtkRadioMenuItem);
288 		
289 		if(p is null)
290 		{
291 			return null;
292 		}
293 		
294 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
295 	}
296 }