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