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 module gtk.PopoverMenu; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtk.Popover; 31 private import gtk.Widget; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 public import gtkc.gtktypes; 35 36 37 /** 38 * GtkPopoverMenu is a subclass of #GtkPopover that treats its 39 * children like menus and allows switching between them. It is 40 * meant to be used primarily together with #GtkModelButton, but 41 * any widget can be used, such as #GtkSpinButton or #GtkScale. 42 * In this respect, GtkPopoverMenu is more flexible than popovers 43 * that are created from a #GMenuModel with gtk_popover_new_from_model(). 44 * 45 * To add a child as a submenu, set the #GtkPopoverMenu:submenu 46 * child property to the name of the submenu. To let the user open 47 * this submenu, add a #GtkModelButton whose #GtkModelButton:menu-name 48 * property is set to the name you've given to the submenu. 49 * 50 * By convention, the first child of a submenu should be a #GtkModelButton 51 * to switch back to the parent menu. Such a button should use the 52 * #GtkModelButton:inverted and #GtkModelButton:centered properties 53 * to achieve a title-like appearance and place the submenu indicator 54 * at the opposite side. To switch back to the main menu, use "main" 55 * as the menu name. 56 * 57 * # Example 58 * 59 * |[ 60 * <object class="GtkPopoverMenu"> 61 * <child> 62 * <object class="GtkBox"> 63 * <property name="visible">True</property> 64 * <property name="margin">10</property> 65 * <child> 66 * <object class="GtkModelButton"> 67 * <property name="visible">True</property> 68 * <property name="action-name">win.frob</property> 69 * <property name="text" translatable="yes">Frob</property> 70 * </object> 71 * </child> 72 * <child> 73 * <object class="GtkModelButton"> 74 * <property name="visible">True</property> 75 * <property name="menu-name">more</property> 76 * <property name="text" translatable="yes">More</property> 77 * </object> 78 * </child> 79 * </object> 80 * </child> 81 * <child> 82 * <object class="GtkBox"> 83 * <property name="visible">True</property> 84 * <property name="margin">10</property> 85 * <child> 86 * <object class="GtkModelButton"> 87 * <property name="visible">True</property> 88 * <property name="action-name">win.foo</property> 89 * <property name="text" translatable="yes">Foo</property> 90 * </object> 91 * </child> 92 * <child> 93 * <object class="GtkModelButton"> 94 * <property name="visible">True</property> 95 * <property name="action-name">win.bar</property> 96 * <property name="text" translatable="yes">Bar</property> 97 * </object> 98 * </child> 99 * </object> 100 * <packing> 101 * <property name="submenu">more</property> 102 * </packing> 103 * </child> 104 * </object> 105 * ]| 106 * 107 * Just like normal popovers created using gtk_popover_new_from_model, 108 * #GtkPopoverMenu instances have a single css node called "popover" 109 * and get the .menu style class. 110 */ 111 public class PopoverMenu : Popover 112 { 113 /** the main Gtk struct */ 114 protected GtkPopoverMenu* gtkPopoverMenu; 115 116 /** Get the main Gtk struct */ 117 public GtkPopoverMenu* getPopoverMenuStruct(bool transferOwnership = false) 118 { 119 if (transferOwnership) 120 ownedRef = false; 121 return gtkPopoverMenu; 122 } 123 124 /** the main Gtk struct as a void* */ 125 protected override void* getStruct() 126 { 127 return cast(void*)gtkPopoverMenu; 128 } 129 130 /** 131 * Sets our main struct and passes it to the parent class. 132 */ 133 public this (GtkPopoverMenu* gtkPopoverMenu, bool ownedRef = false) 134 { 135 this.gtkPopoverMenu = gtkPopoverMenu; 136 super(cast(GtkPopover*)gtkPopoverMenu, ownedRef); 137 } 138 139 140 /** */ 141 public static GType getType() 142 { 143 return gtk_popover_menu_get_type(); 144 } 145 146 /** 147 * Creates a new popover menu. 148 * 149 * Returns: a new #GtkPopoverMenu 150 * 151 * Since: 3.16 152 * 153 * Throws: ConstructionException GTK+ fails to create the object. 154 */ 155 public this() 156 { 157 auto p = gtk_popover_menu_new(); 158 159 if(p is null) 160 { 161 throw new ConstructionException("null returned by new"); 162 } 163 164 this(cast(GtkPopoverMenu*) p); 165 } 166 167 /** 168 * Opens a submenu of the @popover. The @name 169 * must be one of the names given to the submenus 170 * of @popover with #GtkPopoverMenu:submenu, or 171 * "main" to switch back to the main menu. 172 * 173 * #GtkModelButton will open submenus automatically 174 * when the #GtkModelButton:menu-name property is set, 175 * so this function is only needed when you are using 176 * other kinds of widgets to initiate menu changes. 177 * 178 * Params: 179 * name = the name of the menu to switch to 180 * 181 * Since: 3.16 182 */ 183 public void openSubmenu(string name) 184 { 185 gtk_popover_menu_open_submenu(gtkPopoverMenu, Str.toStringz(name)); 186 } 187 }