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