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 = GMenu.html 27 * outPack = gio 28 * outFile = Menu 29 * strct = GMenu 30 * realStrct= 31 * ctorStrct= 32 * clss = Menu 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_menu_ 41 * omit structs: 42 * omit prefixes: 43 * - g_menu_item_ 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gio.MenuItem 49 * - gio.MenuModel 50 * structWrap: 51 * - GMenuItem* -> MenuItem 52 * - GMenuModel* -> MenuModel 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gio.Menu; 59 60 public import gtkc.giotypes; 61 62 private import gtkc.gio; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 private import glib.Str; 67 private import gio.MenuItem; 68 private import gio.MenuModel; 69 70 71 private import gio.MenuModel; 72 73 /** 74 * GMenu is a simple implementation of GMenuModel. 75 * You populate a GMenu by adding GMenuItem instances to it. 76 * 77 * There are some convenience functions to allow you to directly 78 * add items (avoiding GMenuItem) for the common cases. To add 79 * a regular item, use g_menu_insert(). To add a section, use 80 * g_menu_insert_section(). To add a submenu, use 81 * g_menu_insert_submenu(). 82 */ 83 public class Menu : MenuModel 84 { 85 86 /** the main Gtk struct */ 87 protected GMenu* gMenu; 88 89 90 /** Get the main Gtk struct */ 91 public GMenu* getMenuStruct() 92 { 93 return gMenu; 94 } 95 96 97 /** the main Gtk struct as a void* */ 98 protected override void* getStruct() 99 { 100 return cast(void*)gMenu; 101 } 102 103 /** 104 * Sets our main struct and passes it to the parent class 105 */ 106 public this (GMenu* gMenu) 107 { 108 super(cast(GMenuModel*)gMenu); 109 this.gMenu = gMenu; 110 } 111 112 protected override void setStruct(GObject* obj) 113 { 114 super.setStruct(obj); 115 gMenu = cast(GMenu*)obj; 116 } 117 118 /** 119 */ 120 121 /** 122 * Creates a new GMenu. 123 * The new menu has no items. 124 * Since 2.32 125 * Throws: ConstructionException GTK+ fails to create the object. 126 */ 127 public this () 128 { 129 // GMenu * g_menu_new (void); 130 auto p = g_menu_new(); 131 if(p is null) 132 { 133 throw new ConstructionException("null returned by g_menu_new()"); 134 } 135 this(cast(GMenu*) p); 136 } 137 138 /** 139 * Marks menu as frozen. 140 * After the menu is frozen, it is an error to attempt to make any 141 * changes to it. In effect this means that the GMenu API must no 142 * longer be used. 143 * This function causes g_menu_model_is_mutable() to begin returning 144 * FALSE, which has some positive performance implications. 145 * Since 2.32 146 */ 147 public void freeze() 148 { 149 // void g_menu_freeze (GMenu *menu); 150 g_menu_freeze(gMenu); 151 } 152 153 /** 154 * Convenience function for inserting a normal menu item into menu. 155 * Combine g_menu_item_new() and g_menu_insert_item() for a more flexible 156 * alternative. 157 * Since 2.32 158 * Params: 159 * position = the position at which to insert the item 160 * label = the section label, or NULL. [allow-none] 161 * detailedAction = the detailed action string, or NULL. [allow-none] 162 */ 163 public void insert(int position, string label, string detailedAction) 164 { 165 // void g_menu_insert (GMenu *menu, gint position, const gchar *label, const gchar *detailed_action); 166 g_menu_insert(gMenu, position, Str.toStringz(label), Str.toStringz(detailedAction)); 167 } 168 169 /** 170 * Convenience function for prepending a normal menu item to the start 171 * of menu. Combine g_menu_item_new() and g_menu_insert_item() for a more 172 * flexible alternative. 173 * Since 2.32 174 * Params: 175 * label = the section label, or NULL. [allow-none] 176 * detailedAction = the detailed action string, or NULL. [allow-none] 177 */ 178 public void prepend(string label, string detailedAction) 179 { 180 // void g_menu_prepend (GMenu *menu, const gchar *label, const gchar *detailed_action); 181 g_menu_prepend(gMenu, Str.toStringz(label), Str.toStringz(detailedAction)); 182 } 183 184 /** 185 * Convenience function for appending a normal menu item to the end of 186 * menu. Combine g_menu_item_new() and g_menu_insert_item() for a more 187 * flexible alternative. 188 * Since 2.32 189 * Params: 190 * label = the section label, or NULL. [allow-none] 191 * detailedAction = the detailed action string, or NULL. [allow-none] 192 */ 193 public void append(string label, string detailedAction) 194 { 195 // void g_menu_append (GMenu *menu, const gchar *label, const gchar *detailed_action); 196 g_menu_append(gMenu, Str.toStringz(label), Str.toStringz(detailedAction)); 197 } 198 199 /** 200 * Inserts item into menu. 201 * The "insertion" is actually done by copying all of the attribute and 202 * link values of item and using them to form a new item within menu. 203 * As such, item itself is not really inserted, but rather, a menu item 204 * that is exactly the same as the one presently described by item. 205 * This means that item is essentially useless after the insertion 206 * occurs. Any changes you make to it are ignored unless it is inserted 207 * again (at which point its updated values will be copied). 208 * You should probably just free item once you're done. 209 * There are many convenience functions to take care of common cases. 210 * See g_menu_insert(), g_menu_insert_section() and 211 * g_menu_insert_submenu() as well as "prepend" and "append" variants of 212 * each of these functions. 213 * Since 2.32 214 * Params: 215 * position = the position at which to insert the item 216 * item = the GMenuItem to insert 217 */ 218 public void insertItem(int position, MenuItem item) 219 { 220 // void g_menu_insert_item (GMenu *menu, gint position, GMenuItem *item); 221 g_menu_insert_item(gMenu, position, (item is null) ? null : item.getMenuItemStruct()); 222 } 223 224 /** 225 * Appends item to the end of menu. 226 * See g_menu_insert_item() for more information. 227 * Since 2.32 228 * Params: 229 * item = a GMenuItem to append 230 */ 231 public void appendItem(MenuItem item) 232 { 233 // void g_menu_append_item (GMenu *menu, GMenuItem *item); 234 g_menu_append_item(gMenu, (item is null) ? null : item.getMenuItemStruct()); 235 } 236 237 /** 238 * Prepends item to the start of menu. 239 * See g_menu_insert_item() for more information. 240 * Since 2.32 241 * Params: 242 * item = a GMenuItem to prepend 243 */ 244 public void prependItem(MenuItem item) 245 { 246 // void g_menu_prepend_item (GMenu *menu, GMenuItem *item); 247 g_menu_prepend_item(gMenu, (item is null) ? null : item.getMenuItemStruct()); 248 } 249 250 /** 251 * Convenience function for inserting a section menu item into menu. 252 * Combine g_menu_item_new_section() and g_menu_insert_item() for a more 253 * flexible alternative. 254 * Since 2.32 255 * Params: 256 * position = the position at which to insert the item 257 * label = the section label, or NULL. [allow-none] 258 * section = a GMenuModel with the items of the section 259 */ 260 public void insertSection(int position, string label, MenuModel section) 261 { 262 // void g_menu_insert_section (GMenu *menu, gint position, const gchar *label, GMenuModel *section); 263 g_menu_insert_section(gMenu, position, Str.toStringz(label), (section is null) ? null : section.getMenuModelStruct()); 264 } 265 266 /** 267 * Convenience function for prepending a section menu item to the start 268 * of menu. Combine g_menu_item_new_section() and g_menu_insert_item() for 269 * a more flexible alternative. 270 * Since 2.32 271 * Params: 272 * label = the section label, or NULL. [allow-none] 273 * section = a GMenuModel with the items of the section 274 */ 275 public void prependSection(string label, MenuModel section) 276 { 277 // void g_menu_prepend_section (GMenu *menu, const gchar *label, GMenuModel *section); 278 g_menu_prepend_section(gMenu, Str.toStringz(label), (section is null) ? null : section.getMenuModelStruct()); 279 } 280 281 /** 282 * Convenience function for appending a section menu item to the end of 283 * menu. Combine g_menu_item_new_section() and g_menu_insert_item() for a 284 * more flexible alternative. 285 * Since 2.32 286 * Params: 287 * label = the section label, or NULL. [allow-none] 288 * section = a GMenuModel with the items of the section 289 */ 290 public void appendSection(string label, MenuModel section) 291 { 292 // void g_menu_append_section (GMenu *menu, const gchar *label, GMenuModel *section); 293 g_menu_append_section(gMenu, Str.toStringz(label), (section is null) ? null : section.getMenuModelStruct()); 294 } 295 296 /** 297 * Convenience function for appending a submenu menu item to the end of 298 * menu. Combine g_menu_item_new_submenu() and g_menu_insert_item() for a 299 * more flexible alternative. 300 * Since 2.32 301 * Params: 302 * menu = a GMenu 303 * label = the section label, or NULL. [allow-none] 304 * submenu = a GMenuModel with the items of the submenu 305 */ 306 public void appendSubmenu(string label, MenuModel submenu) 307 { 308 // void g_menu_append_submenu (GMenu *menu, const gchar *label, GMenuModel *submenu); 309 g_menu_append_submenu(gMenu, Str.toStringz(label), (submenu is null) ? null : submenu.getMenuModelStruct()); 310 } 311 312 /** 313 * Convenience function for inserting a submenu menu item into menu. 314 * Combine g_menu_item_new_submenu() and g_menu_insert_item() for a more 315 * flexible alternative. 316 * Since 2.32 317 * Params: 318 * menu = a GMenu 319 * position = the position at which to insert the item 320 * label = the section label, or NULL. [allow-none] 321 * submenu = a GMenuModel with the items of the submenu 322 */ 323 public void insertSubmenu(int position, string label, MenuModel submenu) 324 { 325 // void g_menu_insert_submenu (GMenu *menu, gint position, const gchar *label, GMenuModel *submenu); 326 g_menu_insert_submenu(gMenu, position, Str.toStringz(label), (submenu is null) ? null : submenu.getMenuModelStruct()); 327 } 328 329 /** 330 * Convenience function for prepending a submenu menu item to the start 331 * of menu. Combine g_menu_item_new_submenu() and g_menu_insert_item() for 332 * a more flexible alternative. 333 * Since 2.32 334 * Params: 335 * menu = a GMenu 336 * label = the section label, or NULL. [allow-none] 337 * submenu = a GMenuModel with the items of the submenu 338 */ 339 public void prependSubmenu(string label, MenuModel submenu) 340 { 341 // void g_menu_prepend_submenu (GMenu *menu, const gchar *label, GMenuModel *submenu); 342 g_menu_prepend_submenu(gMenu, Str.toStringz(label), (submenu is null) ? null : submenu.getMenuModelStruct()); 343 } 344 345 /** 346 * Removes an item from the menu. 347 * position gives the index of the item to remove. 348 * It is an error if position is not in range the range from 0 to one 349 * less than the number of items in the menu. 350 * It is not possible to remove items by identity since items are added 351 * Since 2.32 352 * Params: 353 * position = the position of the item to remove 354 */ 355 public void remove(int position) 356 { 357 // void g_menu_remove (GMenu *menu, gint position); 358 g_menu_remove(gMenu, position); 359 } 360 361 /** 362 * Removes all items in the menu. 363 * Since 2.38 364 */ 365 public void removeAll() 366 { 367 // void g_menu_remove_all (GMenu *menu); 368 g_menu_remove_all(gMenu); 369 } 370 }