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