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  * childen 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 public class PopoverMenu : Popover
107 {
108 	/** the main Gtk struct */
109 	protected GtkPopoverMenu* gtkPopoverMenu;
110 
111 	/** Get the main Gtk struct */
112 	public GtkPopoverMenu* getPopoverMenuStruct()
113 	{
114 		return gtkPopoverMenu;
115 	}
116 
117 	/** the main Gtk struct as a void* */
118 	protected override void* getStruct()
119 	{
120 		return cast(void*)gtkPopoverMenu;
121 	}
122 
123 	protected override void setStruct(GObject* obj)
124 	{
125 		gtkPopoverMenu = cast(GtkPopoverMenu*)obj;
126 		super.setStruct(obj);
127 	}
128 
129 	/**
130 	 * Sets our main struct and passes it to the parent class.
131 	 */
132 	public this (GtkPopoverMenu* gtkPopoverMenu, bool ownedRef = false)
133 	{
134 		this.gtkPopoverMenu = gtkPopoverMenu;
135 		super(cast(GtkPopover*)gtkPopoverMenu, ownedRef);
136 	}
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 	 * Return: 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 }