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 	protected override void setStruct(GObject* obj)
131 	{
132 		gtkPopoverMenu = cast(GtkPopoverMenu*)obj;
133 		super.setStruct(obj);
134 	}
135 
136 	/**
137 	 * Sets our main struct and passes it to the parent class.
138 	 */
139 	public this (GtkPopoverMenu* gtkPopoverMenu, bool ownedRef = false)
140 	{
141 		this.gtkPopoverMenu = gtkPopoverMenu;
142 		super(cast(GtkPopover*)gtkPopoverMenu, ownedRef);
143 	}
144 
145 
146 	/** */
147 	public static GType getType()
148 	{
149 		return gtk_popover_menu_get_type();
150 	}
151 
152 	/**
153 	 * Creates a new popover menu.
154 	 *
155 	 * Returns: a new #GtkPopoverMenu
156 	 *
157 	 * Since: 3.16
158 	 *
159 	 * Throws: ConstructionException GTK+ fails to create the object.
160 	 */
161 	public this()
162 	{
163 		auto p = gtk_popover_menu_new();
164 
165 		if(p is null)
166 		{
167 			throw new ConstructionException("null returned by new");
168 		}
169 
170 		this(cast(GtkPopoverMenu*) p);
171 	}
172 
173 	/**
174 	 * Opens a submenu of the @popover. The @name
175 	 * must be one of the names given to the submenus
176 	 * of @popover with #GtkPopoverMenu:submenu, or
177 	 * "main" to switch back to the main menu.
178 	 *
179 	 * #GtkModelButton will open submenus automatically
180 	 * when the #GtkModelButton:menu-name property is set,
181 	 * so this function is only needed when you are using
182 	 * other kinds of widgets to initiate menu changes.
183 	 *
184 	 * Params:
185 	 *     name = the name of the menu to switch to
186 	 *
187 	 * Since: 3.16
188 	 */
189 	public void openSubmenu(string name)
190 	{
191 		gtk_popover_menu_open_submenu(gtkPopoverMenu, Str.toStringz(name));
192 	}
193 }