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 	protected override void setStruct(GObject* obj)
68 	{
69 		gtkMenuBar = cast(GtkMenuBar*)obj;
70 		super.setStruct(obj);
71 	}
72 
73 	/**
74 	 * Sets our main struct and passes it to the parent class.
75 	 */
76 	public this (GtkMenuBar* gtkMenuBar, bool ownedRef = false)
77 	{
78 		this.gtkMenuBar = gtkMenuBar;
79 		super(cast(GtkMenuShell*)gtkMenuBar, ownedRef);
80 	}
81 
82 	/** */
83 	Menu append(string label, bool rightJustify=false)
84 	{
85 		MenuItem item = new MenuItem(label);
86 		super.append(item);
87 		item.setRightJustified(rightJustify);
88 		Menu menu= new Menu();
89 		item.setSubmenu(menu);
90 		return menu;
91 	}
92 
93 	/** */
94 	public override void append(MenuItem item)
95 	{
96 		super.append(item);
97 	}
98 
99 	/**
100 	 */
101 
102 	/** */
103 	public static GType getType()
104 	{
105 		return gtk_menu_bar_get_type();
106 	}
107 
108 	/**
109 	 * Creates a new #GtkMenuBar
110 	 *
111 	 * Returns: the new menu bar, as a #GtkWidget
112 	 *
113 	 * Throws: ConstructionException GTK+ fails to create the object.
114 	 */
115 	public this()
116 	{
117 		auto p = gtk_menu_bar_new();
118 
119 		if(p is null)
120 		{
121 			throw new ConstructionException("null returned by new");
122 		}
123 
124 		this(cast(GtkMenuBar*) p);
125 	}
126 
127 	/**
128 	 * Creates a new #GtkMenuBar and populates it with menu items
129 	 * and submenus according to @model.
130 	 *
131 	 * The created menu items are connected to actions found in the
132 	 * #GtkApplicationWindow to which the menu bar belongs - typically
133 	 * by means of being contained within the #GtkApplicationWindows
134 	 * widget hierarchy.
135 	 *
136 	 * Params:
137 	 *     model = a #GMenuModel
138 	 *
139 	 * Returns: a new #GtkMenuBar
140 	 *
141 	 * Since: 3.4
142 	 *
143 	 * Throws: ConstructionException GTK+ fails to create the object.
144 	 */
145 	public this(MenuModel model)
146 	{
147 		auto p = gtk_menu_bar_new_from_model((model is null) ? null : model.getMenuModelStruct());
148 
149 		if(p is null)
150 		{
151 			throw new ConstructionException("null returned by new_from_model");
152 		}
153 
154 		this(cast(GtkMenuBar*) p);
155 	}
156 
157 	/**
158 	 * Retrieves the current child pack direction of the menubar.
159 	 * See gtk_menu_bar_set_child_pack_direction().
160 	 *
161 	 * Returns: the child pack direction
162 	 *
163 	 * Since: 2.8
164 	 */
165 	public GtkPackDirection getChildPackDirection()
166 	{
167 		return gtk_menu_bar_get_child_pack_direction(gtkMenuBar);
168 	}
169 
170 	/**
171 	 * Retrieves the current pack direction of the menubar.
172 	 * See gtk_menu_bar_set_pack_direction().
173 	 *
174 	 * Returns: the pack direction
175 	 *
176 	 * Since: 2.8
177 	 */
178 	public GtkPackDirection getPackDirection()
179 	{
180 		return gtk_menu_bar_get_pack_direction(gtkMenuBar);
181 	}
182 
183 	/**
184 	 * Sets how widgets should be packed inside the children of a menubar.
185 	 *
186 	 * Params:
187 	 *     childPackDir = a new #GtkPackDirection
188 	 *
189 	 * Since: 2.8
190 	 */
191 	public void setChildPackDirection(GtkPackDirection childPackDir)
192 	{
193 		gtk_menu_bar_set_child_pack_direction(gtkMenuBar, childPackDir);
194 	}
195 
196 	/**
197 	 * Sets how items should be packed inside a menubar.
198 	 *
199 	 * Params:
200 	 *     packDir = a new #GtkPackDirection
201 	 *
202 	 * Since: 2.8
203 	 */
204 	public void setPackDirection(GtkPackDirection packDir)
205 	{
206 		gtk_menu_bar_set_pack_direction(gtkMenuBar, packDir);
207 	}
208 }