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