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.PopoverMenuBar;
26 
27 private import gio.MenuModel;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 
35 
36 /**
37  * `GtkPopoverMenuBar` presents a horizontal bar of items that pop
38  * up popover menus when clicked.
39  * 
40  * ![An example GtkPopoverMenuBar](menubar.png)
41  * 
42  * The only way to create instances of `GtkPopoverMenuBar` is
43  * from a `GMenuModel`.
44  * 
45  * # CSS nodes
46  * 
47  * ```
48  * menubar
49  * ├── item[.active]
50  * ┊   ╰── popover
51  * ╰── item
52  * ╰── popover
53  * ```
54  * 
55  * `GtkPopoverMenuBar` has a single CSS node with name menubar, below which
56  * each item has its CSS node, and below that the corresponding popover.
57  * 
58  * The item whose popover is currently open gets the .active
59  * style class.
60  * 
61  * # Accessibility
62  * 
63  * `GtkPopoverMenuBar` uses the %GTK_ACCESSIBLE_ROLE_MENU_BAR role,
64  * the menu items use the %GTK_ACCESSIBLE_ROLE_MENU_ITEM role and
65  * the menus use the %GTK_ACCESSIBLE_ROLE_MENU role.
66  */
67 public class PopoverMenuBar : Widget
68 {
69 	/** the main Gtk struct */
70 	protected GtkPopoverMenuBar* gtkPopoverMenuBar;
71 
72 	/** Get the main Gtk struct */
73 	public GtkPopoverMenuBar* getPopoverMenuBarStruct(bool transferOwnership = false)
74 	{
75 		if (transferOwnership)
76 			ownedRef = false;
77 		return gtkPopoverMenuBar;
78 	}
79 
80 	/** the main Gtk struct as a void* */
81 	protected override void* getStruct()
82 	{
83 		return cast(void*)gtkPopoverMenuBar;
84 	}
85 
86 	/**
87 	 * Sets our main struct and passes it to the parent class.
88 	 */
89 	public this (GtkPopoverMenuBar* gtkPopoverMenuBar, bool ownedRef = false)
90 	{
91 		this.gtkPopoverMenuBar = gtkPopoverMenuBar;
92 		super(cast(GtkWidget*)gtkPopoverMenuBar, ownedRef);
93 	}
94 
95 
96 	/** */
97 	public static GType getType()
98 	{
99 		return gtk_popover_menu_bar_get_type();
100 	}
101 
102 	/**
103 	 * Creates a `GtkPopoverMenuBar` from a `GMenuModel`.
104 	 *
105 	 * Params:
106 	 *     model = a `GMenuModel`, or %NULL
107 	 *
108 	 * Returns: a new `GtkPopoverMenuBar`
109 	 *
110 	 * Throws: ConstructionException GTK+ fails to create the object.
111 	 */
112 	public this(MenuModel model)
113 	{
114 		auto __p = gtk_popover_menu_bar_new_from_model((model is null) ? null : model.getMenuModelStruct());
115 
116 		if(__p is null)
117 		{
118 			throw new ConstructionException("null returned by new_from_model");
119 		}
120 
121 		this(cast(GtkPopoverMenuBar*) __p);
122 	}
123 
124 	/**
125 	 * Adds a custom widget to a generated menubar.
126 	 *
127 	 * For this to work, the menu model of @bar must have an
128 	 * item with a `custom` attribute that matches @id.
129 	 *
130 	 * Params:
131 	 *     child = the `GtkWidget` to add
132 	 *     id = the ID to insert @child at
133 	 *
134 	 * Returns: %TRUE if @id was found and the widget added
135 	 */
136 	public bool addChild(Widget child, string id)
137 	{
138 		return gtk_popover_menu_bar_add_child(gtkPopoverMenuBar, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(id)) != 0;
139 	}
140 
141 	/**
142 	 * Returns the model from which the contents of @bar are taken.
143 	 *
144 	 * Returns: a `GMenuModel`
145 	 */
146 	public MenuModel getMenuModel()
147 	{
148 		auto __p = gtk_popover_menu_bar_get_menu_model(gtkPopoverMenuBar);
149 
150 		if(__p is null)
151 		{
152 			return null;
153 		}
154 
155 		return ObjectG.getDObject!(MenuModel)(cast(GMenuModel*) __p);
156 	}
157 
158 	/**
159 	 * Removes a widget that has previously been added with
160 	 * gtk_popover_menu_bar_add_child().
161 	 *
162 	 * Params:
163 	 *     child = the #GtkWidget to remove
164 	 *
165 	 * Returns: %TRUE if the widget was removed
166 	 */
167 	public bool removeChild(Widget child)
168 	{
169 		return gtk_popover_menu_bar_remove_child(gtkPopoverMenuBar, (child is null) ? null : child.getWidgetStruct()) != 0;
170 	}
171 
172 	/**
173 	 * Sets a menu model from which @bar should take
174 	 * its contents.
175 	 *
176 	 * Params:
177 	 *     model = a `GMenuModel`, or %NULL
178 	 */
179 	public void setMenuModel(MenuModel model)
180 	{
181 		gtk_popover_menu_bar_set_menu_model(gtkPopoverMenuBar, (model is null) ? null : model.getMenuModelStruct());
182 	}
183 }