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