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.ApplicationWindow;
26 
27 private import gio.ActionGroupIF;
28 private import gio.ActionGroupT;
29 private import gio.ActionMapIF;
30 private import gio.ActionMapT;
31 private import glib.ConstructionException;
32 private import gobject.ObjectG;
33 private import gtk.Application;
34 private import gtk.Widget;
35 private import gtk.Window;
36 private import gtkc.gtk;
37 public  import gtkc.gtktypes;
38 
39 
40 /**
41  * GtkApplicationWindow is a #GtkWindow subclass that offers some
42  * extra functionality for better integration with #GtkApplication
43  * features.  Notably, it can handle both the application menu as well
44  * as the menubar. See gtk_application_set_app_menu() and
45  * gtk_application_set_menubar().
46  * 
47  * This class implements the #GActionGroup and #GActionMap interfaces,
48  * to let you add window-specific actions that will be exported by the
49  * associated #GtkApplication, together with its application-wide
50  * actions.  Window-specific actions are prefixed with the “win.”
51  * prefix and application-wide actions are prefixed with the “app.”
52  * prefix.  Actions must be addressed with the prefixed name when
53  * referring to them from a #GMenuModel.
54  * 
55  * Note that widgets that are placed inside a GtkApplicationWindow
56  * can also activate these actions, if they implement the
57  * GtkActionable interface.
58  * 
59  * As with #GtkApplication, the GDK lock will be acquired when
60  * processing actions arriving from other processes and should therefore
61  * be held when activating actions locally (if GDK threads are enabled).
62  * 
63  * The settings #GtkSettings:gtk-shell-shows-app-menu and
64  * #GtkSettings:gtk-shell-shows-menubar tell GTK+ whether the
65  * desktop environment is showing the application menu and menubar
66  * models outside the application as part of the desktop shell.
67  * For instance, on OS X, both menus will be displayed remotely;
68  * on Windows neither will be. gnome-shell (starting with version 3.4)
69  * will display the application menu, but not the menubar.
70  * 
71  * If the desktop environment does not display the menubar, then
72  * #GtkApplicationWindow will automatically show a #GtkMenuBar for it.
73  * (see the #GtkApplication docs for some screenshots of how this
74  * looks on different platforms).
75  * This behaviour can be overridden with the #GtkApplicationWindow:show-menubar
76  * property. If the desktop environment does not display the application
77  * menu, then it will automatically be included in the menubar. It can
78  * also be shown as part of client-side window decorations, e.g. by
79  * using gtk_header_bar_set_show_close_button().
80  * 
81  * ## A GtkApplicationWindow with a menubar
82  * 
83  * |[<!-- language="C" -->
84  * app = gtk_application_new ();
85  * 
86  * builder = gtk_builder_new_from_string (
87  * "<interface>"
88  * "  <menu id='menubar'>"
89  * "    <submenu label='_Edit'>"
90  * "      <item label='_Copy' action='win.copy'/>"
91  * "      <item label='_Paste' action='win.paste'/>"
92  * "    </submenu>"
93  * "  </menu>"
94  * "</interface>",
95  * -1);
96  * 
97  * menubar = G_MENU_MODEL (gtk_builder_get_object (builder,
98  * "menubar"));
99  * gtk_application_set_menubar (G_APPLICATION (app), menubar);
100  * g_object_unref (builder);
101  * 
102  * ...
103  * 
104  * window = gtk_application_window_new (app);
105  * ]|
106  * 
107  * ## Handling fallback yourself
108  * 
109  * [A simple example](https://git.gnome.org/browse/gtk+/tree/examples/sunny.c)
110  * 
111  * The XML format understood by #GtkBuilder for #GMenuModel consists
112  * of a toplevel `<menu>` element, which contains one or more `<item>`
113  * elements. Each `<item>` element contains `<attribute>` and `<link>`
114  * elements with a mandatory name attribute. `<link>` elements have the
115  * same content model as `<menu>`.
116  * 
117  * Attribute values can be translated using gettext, like other #GtkBuilder
118  * content. `<attribute>` elements can be marked for translation with a
119  * `translatable="yes"` attribute. It is also possible to specify message
120  * context and translator comments, using the context and comments attributes.
121  * To make use of this, the #GtkBuilder must have been given the gettext
122  * domain to use.
123  */
124 public class ApplicationWindow : Window, ActionGroupIF, ActionMapIF
125 {
126 	/** the main Gtk struct */
127 	protected GtkApplicationWindow* gtkApplicationWindow;
128 
129 	/** Get the main Gtk struct */
130 	public GtkApplicationWindow* getApplicationWindowStruct()
131 	{
132 		return gtkApplicationWindow;
133 	}
134 
135 	/** the main Gtk struct as a void* */
136 	protected override void* getStruct()
137 	{
138 		return cast(void*)gtkApplicationWindow;
139 	}
140 
141 	protected override void setStruct(GObject* obj)
142 	{
143 		gtkApplicationWindow = cast(GtkApplicationWindow*)obj;
144 		super.setStruct(obj);
145 	}
146 
147 	/**
148 	 * Sets our main struct and passes it to the parent class.
149 	 */
150 	public this (GtkApplicationWindow* gtkApplicationWindow, bool ownedRef = false)
151 	{
152 		this.gtkApplicationWindow = gtkApplicationWindow;
153 		super(cast(GtkWindow*)gtkApplicationWindow, ownedRef);
154 	}
155 
156 	// add the ActionGroup capabilities
157 	mixin ActionGroupT!(GtkApplicationWindow);
158 
159 	// add the ActionMap capabilities
160 	mixin ActionMapT!(GtkApplicationWindow);
161 
162 	/**
163 	 */
164 
165 	public static GType getType()
166 	{
167 		return gtk_application_window_get_type();
168 	}
169 
170 	/**
171 	 * Creates a new #GtkApplicationWindow.
172 	 *
173 	 * Params:
174 	 *     application = a #GtkApplication
175 	 *
176 	 * Return: a newly created #GtkApplicationWindow
177 	 *
178 	 * Since: 3.4
179 	 *
180 	 * Throws: ConstructionException GTK+ fails to create the object.
181 	 */
182 	public this(Application application)
183 	{
184 		auto p = gtk_application_window_new((application is null) ? null : application.getGtkApplicationStruct());
185 		
186 		if(p is null)
187 		{
188 			throw new ConstructionException("null returned by new");
189 		}
190 		
191 		this(cast(GtkApplicationWindow*) p);
192 	}
193 
194 	/**
195 	 * Returns the unique ID of the window. If the window has not yet been added to
196 	 * a #GtkApplication, returns `0`.
197 	 *
198 	 * Return: the unique ID for @window, or `0` if the window
199 	 *     has not yet been added to a #GtkApplication
200 	 *
201 	 * Since: 3.6
202 	 */
203 	public uint getId()
204 	{
205 		return gtk_application_window_get_id(gtkApplicationWindow);
206 	}
207 
208 	/**
209 	 * Returns whether the window will display a menubar for the app menu
210 	 * and menubar as needed.
211 	 *
212 	 * Return: %TRUE if @window will display a menubar when needed
213 	 *
214 	 * Since: 3.4
215 	 */
216 	public bool getShowMenubar()
217 	{
218 		return gtk_application_window_get_show_menubar(gtkApplicationWindow) != 0;
219 	}
220 
221 	/**
222 	 * Sets whether the window will display a menubar for the app menu
223 	 * and menubar as needed.
224 	 *
225 	 * Params:
226 	 *     showMenubar = whether to show a menubar when needed
227 	 *
228 	 * Since: 3.4
229 	 */
230 	public void setShowMenubar(bool showMenubar)
231 	{
232 		gtk_application_window_set_show_menubar(gtkApplicationWindow, showMenubar);
233 	}
234 }