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.MenuBar;
26 
27 private import gio.MenuModel;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import gtk.Menu;
31 private import gtk.MenuItem;
32 private import gtk.MenuShell;
33 private import gtk.Widget;
34 private import gtk.c.functions;
35 public  import gtk.c.types;
36 public  import gtkc.gtktypes;
37 
38 
39 /**
40  * The #GtkMenuBar is a subclass of #GtkMenuShell which contains one or
41  * more #GtkMenuItems. The result is a standard menu bar which can hold
42  * many menu items.
43  * 
44  * # CSS nodes
45  * 
46  * GtkMenuBar has a single CSS node with name menubar.
47  */
48 public class MenuBar : MenuShell
49 {
50 	/** the main Gtk struct */
51 	protected GtkMenuBar* gtkMenuBar;
52 
53 	/** Get the main Gtk struct */
54 	public GtkMenuBar* getMenuBarStruct(bool transferOwnership = false)
55 	{
56 		if (transferOwnership)
57 			ownedRef = false;
58 		return gtkMenuBar;
59 	}
60 
61 	/** the main Gtk struct as a void* */
62 	protected override void* getStruct()
63 	{
64 		return cast(void*)gtkMenuBar;
65 	}
66 
67 	/**
68 	 * Sets our main struct and passes it to the parent class.
69 	 */
70 	public this (GtkMenuBar* gtkMenuBar, bool ownedRef = false)
71 	{
72 		this.gtkMenuBar = gtkMenuBar;
73 		super(cast(GtkMenuShell*)gtkMenuBar, ownedRef);
74 	}
75 
76 	/** */
77 	Menu append(string label, bool rightJustify=false)
78 	{
79 		MenuItem item = new MenuItem(label);
80 		super.append(item);
81 		item.setRightJustified(rightJustify);
82 		Menu menu= new Menu();
83 		item.setSubmenu(menu);
84 		return menu;
85 	}
86 
87 	/** */
88 	public override void append(MenuItem item)
89 	{
90 		super.append(item);
91 	}
92 
93 	/**
94 	 */
95 
96 	/** */
97 	public static GType getType()
98 	{
99 		return gtk_menu_bar_get_type();
100 	}
101 
102 	/**
103 	 * Creates a new #GtkMenuBar
104 	 *
105 	 * Returns: the new menu bar, as a #GtkWidget
106 	 *
107 	 * Throws: ConstructionException GTK+ fails to create the object.
108 	 */
109 	public this()
110 	{
111 		auto p = gtk_menu_bar_new();
112 
113 		if(p is null)
114 		{
115 			throw new ConstructionException("null returned by new");
116 		}
117 
118 		this(cast(GtkMenuBar*) p);
119 	}
120 
121 	/**
122 	 * Creates a new #GtkMenuBar and populates it with menu items
123 	 * and submenus according to @model.
124 	 *
125 	 * The created menu items are connected to actions found in the
126 	 * #GtkApplicationWindow to which the menu bar belongs - typically
127 	 * by means of being contained within the #GtkApplicationWindows
128 	 * widget hierarchy.
129 	 *
130 	 * Params:
131 	 *     model = a #GMenuModel
132 	 *
133 	 * Returns: a new #GtkMenuBar
134 	 *
135 	 * Since: 3.4
136 	 *
137 	 * Throws: ConstructionException GTK+ fails to create the object.
138 	 */
139 	public this(MenuModel model)
140 	{
141 		auto p = gtk_menu_bar_new_from_model((model is null) ? null : model.getMenuModelStruct());
142 
143 		if(p is null)
144 		{
145 			throw new ConstructionException("null returned by new_from_model");
146 		}
147 
148 		this(cast(GtkMenuBar*) p);
149 	}
150 
151 	/**
152 	 * Retrieves the current child pack direction of the menubar.
153 	 * See gtk_menu_bar_set_child_pack_direction().
154 	 *
155 	 * Returns: the child pack direction
156 	 *
157 	 * Since: 2.8
158 	 */
159 	public GtkPackDirection getChildPackDirection()
160 	{
161 		return gtk_menu_bar_get_child_pack_direction(gtkMenuBar);
162 	}
163 
164 	/**
165 	 * Retrieves the current pack direction of the menubar.
166 	 * See gtk_menu_bar_set_pack_direction().
167 	 *
168 	 * Returns: the pack direction
169 	 *
170 	 * Since: 2.8
171 	 */
172 	public GtkPackDirection getPackDirection()
173 	{
174 		return gtk_menu_bar_get_pack_direction(gtkMenuBar);
175 	}
176 
177 	/**
178 	 * Sets how widgets should be packed inside the children of a menubar.
179 	 *
180 	 * Params:
181 	 *     childPackDir = a new #GtkPackDirection
182 	 *
183 	 * Since: 2.8
184 	 */
185 	public void setChildPackDirection(GtkPackDirection childPackDir)
186 	{
187 		gtk_menu_bar_set_child_pack_direction(gtkMenuBar, childPackDir);
188 	}
189 
190 	/**
191 	 * Sets how items should be packed inside a menubar.
192 	 *
193 	 * Params:
194 	 *     packDir = a new #GtkPackDirection
195 	 *
196 	 * Since: 2.8
197 	 */
198 	public void setPackDirection(GtkPackDirection packDir)
199 	{
200 		gtk_menu_bar_set_pack_direction(gtkMenuBar, packDir);
201 	}
202 }