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