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