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