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  = GtkImageMenuItem.html
27  * outPack = gtk
28  * outFile = ImageMenuItem
29  * strct   = GtkImageMenuItem
30  * realStrct=
31  * ctorStrct=
32  * clss    = ImageMenuItem
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_image_menu_item_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gtk_image_menu_item_new_with_label
45  * 	- gtk_image_menu_item_new_with_mnemonic
46  * 	- gtk_image_menu_item_new_from_stock
47  * omit signals:
48  * imports:
49  * 	- glib.Str
50  * 	- gtk.AccelGroup
51  * 	- gtk.Widget
52  * structWrap:
53  * 	- GtkAccelGroup* -> AccelGroup
54  * 	- GtkWidget* -> Widget
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gtk.ImageMenuItem;
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 glib.Str;
69 private import gtk.AccelGroup;
70 private import gtk.Widget;
71 
72 
73 private import gtk.MenuItem;
74 
75 /**
76  * A GtkImageMenuItem is a menu item which has an icon next to the text label.
77  *
78  * Note that the user can disable display of menu icons, so make sure to still
79  * fill in the text label.
80  */
81 public class ImageMenuItem : MenuItem
82 {
83 	
84 	/** the main Gtk struct */
85 	protected GtkImageMenuItem* gtkImageMenuItem;
86 	
87 	
88 	/** Get the main Gtk struct */
89 	public GtkImageMenuItem* getImageMenuItemStruct()
90 	{
91 		return gtkImageMenuItem;
92 	}
93 	
94 	
95 	/** the main Gtk struct as a void* */
96 	protected override void* getStruct()
97 	{
98 		return cast(void*)gtkImageMenuItem;
99 	}
100 	
101 	/**
102 	 * Sets our main struct and passes it to the parent class
103 	 */
104 	public this (GtkImageMenuItem* gtkImageMenuItem)
105 	{
106 		super(cast(GtkMenuItem*)gtkImageMenuItem);
107 		this.gtkImageMenuItem = gtkImageMenuItem;
108 	}
109 	
110 	protected override void setStruct(GObject* obj)
111 	{
112 		super.setStruct(obj);
113 		gtkImageMenuItem = cast(GtkImageMenuItem*)obj;
114 	}
115 	
116 	/**
117 	 * Creates a new GtkImageMenuItem containing a label.
118 	 * If mnemonic it true the label will be created using
119 	 * gtk_label_new_with_mnemonic(), so underscores
120 	 * in label indicate the mnemonic for the menu item.
121 	 * Params:
122 	 *  label = the text of the menu item.
123 	 * Throws: ConstructionException GTK+ fails to create the object.
124 	 */
125 	public this (string label, bool mnemonic=true)
126 	{
127 		GtkImageMenuItem* p;
128 		
129 		if ( mnemonic )
130 		{
131 			// GtkWidget* gtk_image_menu_item_new_with_mnemonic  (const gchar *label);
132 			p = cast(GtkImageMenuItem*)gtk_image_menu_item_new_with_mnemonic(Str.toStringz(label));
133 		}
134 		else
135 		{
136 			// GtkWidget* gtk_image_menu_item_new_with_label  (const gchar *label);
137 			p = cast(GtkImageMenuItem*)gtk_image_menu_item_new_with_label(Str.toStringz(label));
138 		}
139 		
140 		if(p is null)
141 		{
142 			throw new ConstructionException("null returned by gtk_image_menu_item_new_with_");
143 		}
144 		
145 		this(p);
146 	}
147 	
148 	/**
149 	 * Creates a new GtkImageMenuItem containing the image and text from a
150 	 * stock item.
151 	 * If you want this menu item to have changeable accelerators, then pass in
152 	 * null for accelGroup. Next call setAccelPath() with an appropriate path
153 	 * for the menu item, use gtk.StockItem.StockItem.lookup() to look up the
154 	 * standard accelerator for the stock item, and if one is found, call
155 	 * gtk.AccelMap.AccelMap.addEntry() to register it.
156 	 * Params:
157 	 *   StockID    = the name of the stock item
158 	 *   accelGroup = the GtkAccelGroup to add the menu items accelerator to,
159 	 *                or NULL.
160 	 * Throws: ConstructionException GTK+ fails to create the object.
161 	 */
162 	public this (StockID stockID, AccelGroup accelGroup)
163 	{
164 		// GtkWidget* gtk_image_menu_item_new_from_stock (const gchar *stock_id,  GtkAccelGroup *accel_group);
165 		auto p = gtk_image_menu_item_new_from_stock(Str.toStringz(StockDesc[stockID]), (accelGroup is null) ? null : accelGroup.getAccelGroupStruct());
166 		if(p is null)
167 		{
168 			throw new ConstructionException("null returned by gtk_image_menu_item_new_from_stock");
169 		}
170 		this(cast(GtkImageMenuItem*) p);
171 	}
172 	
173 	/**
174 	 */
175 	
176 	/**
177 	 * Warning
178 	 * gtk_image_menu_item_set_image is deprecated and should not be used in newly-written code. 3.10
179 	 * Sets the image of image_menu_item to the given widget.
180 	 * Note that it depends on the show-menu-images setting whether
181 	 * the image will be displayed or not.
182 	 * Params:
183 	 * image = a widget to set as the image for the menu item. [allow-none]
184 	 */
185 	public void setImage(Widget image)
186 	{
187 		// void gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,  GtkWidget *image);
188 		gtk_image_menu_item_set_image(gtkImageMenuItem, (image is null) ? null : image.getWidgetStruct());
189 	}
190 	
191 	/**
192 	 * Warning
193 	 * gtk_image_menu_item_get_image is deprecated and should not be used in newly-written code. 3.10
194 	 * Gets the widget that is currently set as the image of image_menu_item.
195 	 * See gtk_image_menu_item_set_image().
196 	 * Returns: the widget set as image of image_menu_item. [transfer none]
197 	 */
198 	public Widget getImage()
199 	{
200 		// GtkWidget * gtk_image_menu_item_get_image (GtkImageMenuItem *image_menu_item);
201 		auto p = gtk_image_menu_item_get_image(gtkImageMenuItem);
202 		
203 		if(p is null)
204 		{
205 			return null;
206 		}
207 		
208 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
209 	}
210 	
211 	/**
212 	 * Warning
213 	 * gtk_image_menu_item_new has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_menu_item_new() instead.
214 	 * Creates a new GtkImageMenuItem with an empty label.
215 	 * Throws: ConstructionException GTK+ fails to create the object.
216 	 */
217 	public this ()
218 	{
219 		// GtkWidget * gtk_image_menu_item_new (void);
220 		auto p = gtk_image_menu_item_new();
221 		if(p is null)
222 		{
223 			throw new ConstructionException("null returned by gtk_image_menu_item_new()");
224 		}
225 		this(cast(GtkImageMenuItem*) p);
226 	}
227 	
228 	/**
229 	 * Warning
230 	 * gtk_image_menu_item_get_use_stock is deprecated and should not be used in newly-written code. 3.10
231 	 * Checks whether the label set in the menuitem is used as a
232 	 * stock id to select the stock item for the item.
233 	 * Since 2.16
234 	 * Returns: TRUE if the label set in the menuitem is used as a stock id to select the stock item for the item
235 	 */
236 	public int getUseStock()
237 	{
238 		// gboolean gtk_image_menu_item_get_use_stock (GtkImageMenuItem *image_menu_item);
239 		return gtk_image_menu_item_get_use_stock(gtkImageMenuItem);
240 	}
241 	
242 	/**
243 	 * Warning
244 	 * gtk_image_menu_item_set_use_stock is deprecated and should not be used in newly-written code. 3.10
245 	 * If TRUE, the label set in the menuitem is used as a
246 	 * stock id to select the stock item for the item.
247 	 * Since 2.16
248 	 * Params:
249 	 * useStock = TRUE if the menuitem should use a stock item
250 	 */
251 	public void setUseStock(int useStock)
252 	{
253 		// void gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item,  gboolean use_stock);
254 		gtk_image_menu_item_set_use_stock(gtkImageMenuItem, useStock);
255 	}
256 	
257 	/**
258 	 * Warning
259 	 * gtk_image_menu_item_get_always_show_image is deprecated and should not be used in newly-written code. 3.10
260 	 * Returns whether the menu item will always show the image, if available.
261 	 * Since 2.16
262 	 * Returns: TRUE if the menu item will always show the image
263 	 */
264 	public int getAlwaysShowImage()
265 	{
266 		// gboolean gtk_image_menu_item_get_always_show_image  (GtkImageMenuItem *image_menu_item);
267 		return gtk_image_menu_item_get_always_show_image(gtkImageMenuItem);
268 	}
269 	
270 	/**
271 	 * Warning
272 	 * gtk_image_menu_item_set_always_show_image is deprecated and should not be used in newly-written code. 3.10
273 	 * If TRUE, the menu item will always show the image, if available.
274 	 * Use this property if the menuitem would be useless or hard to use
275 	 * without the image.
276 	 * Since 2.16
277 	 * Params:
278 	 * alwaysShow = TRUE if the menuitem should always show the image
279 	 */
280 	public void setAlwaysShowImage(int alwaysShow)
281 	{
282 		// void gtk_image_menu_item_set_always_show_image  (GtkImageMenuItem *image_menu_item,  gboolean always_show);
283 		gtk_image_menu_item_set_always_show_image(gtkImageMenuItem, alwaysShow);
284 	}
285 	
286 	/**
287 	 * Warning
288 	 * gtk_image_menu_item_set_accel_group is deprecated and should not be used in newly-written code. 3.10
289 	 * Specifies an accel_group to add the menu items accelerator to
290 	 * (this only applies to stock items so a stock item must already
291 	 * be set, make sure to call gtk_image_menu_item_set_use_stock()
292 	 * and gtk_menu_item_set_label() with a valid stock item first).
293 	 * If you want this menu item to have changeable accelerators then
294 	 * you shouldnt need this (see gtk_image_menu_item_new_from_stock()).
295 	 * Since 2.16
296 	 * Params:
297 	 * accelGroup = the GtkAccelGroup
298 	 */
299 	public void setAccelGroup(AccelGroup accelGroup)
300 	{
301 		// void gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,  GtkAccelGroup *accel_group);
302 		gtk_image_menu_item_set_accel_group(gtkImageMenuItem, (accelGroup is null) ? null : accelGroup.getAccelGroupStruct());
303 	}
304 }