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.ShortcutsWindow;
35 private import gtk.Widget;
36 private import gtk.Window;
37 private import gtkc.gtk;
38 public  import gtkc.gtktypes;
39 
40 
41 /**
42  * GtkApplicationWindow is a #GtkWindow subclass that offers some
43  * extra functionality for better integration with #GtkApplication
44  * features.  Notably, it can handle both the application menu as well
45  * as the menubar. See gtk_application_set_app_menu() and
46  * gtk_application_set_menubar().
47  * 
48  * This class implements the #GActionGroup and #GActionMap interfaces,
49  * to let you add window-specific actions that will be exported by the
50  * associated #GtkApplication, together with its application-wide
51  * actions.  Window-specific actions are prefixed with the “win.”
52  * prefix and application-wide actions are prefixed with the “app.”
53  * prefix.  Actions must be addressed with the prefixed name when
54  * referring to them from a #GMenuModel.
55  * 
56  * Note that widgets that are placed inside a GtkApplicationWindow
57  * can also activate these actions, if they implement the
58  * GtkActionable interface.
59  * 
60  * As with #GtkApplication, the GDK lock will be acquired when
61  * processing actions arriving from other processes and should therefore
62  * be held when activating actions locally (if GDK threads are enabled).
63  * 
64  * The settings #GtkSettings:gtk-shell-shows-app-menu and
65  * #GtkSettings:gtk-shell-shows-menubar tell GTK+ whether the
66  * desktop environment is showing the application menu and menubar
67  * models outside the application as part of the desktop shell.
68  * For instance, on OS X, both menus will be displayed remotely;
69  * on Windows neither will be. gnome-shell (starting with version 3.4)
70  * will display the application menu, but not the menubar.
71  * 
72  * If the desktop environment does not display the menubar, then
73  * #GtkApplicationWindow will automatically show a #GtkMenuBar for it.
74  * This behaviour can be overridden with the #GtkApplicationWindow:show-menubar
75  * property. If the desktop environment does not display the application
76  * menu, then it will automatically be included in the menubar or in the
77  * windows client-side decorations.
78  * 
79  * ## A GtkApplicationWindow with a menubar
80  * 
81  * |[<!-- language="C" -->
82  * app = gtk_application_new ();
83  * 
84  * builder = gtk_builder_new_from_string (
85  * "<interface>"
86  * "  <menu id='menubar'>"
87  * "    <submenu label='_Edit'>"
88  * "      <item label='_Copy' action='win.copy'/>"
89  * "      <item label='_Paste' action='win.paste'/>"
90  * "    </submenu>"
91  * "  </menu>"
92  * "</interface>",
93  * -1);
94  * 
95  * menubar = G_MENU_MODEL (gtk_builder_get_object (builder,
96  * "menubar"));
97  * gtk_application_set_menubar (G_APPLICATION (app), menubar);
98  * g_object_unref (builder);
99  * 
100  * ...
101  * 
102  * window = gtk_application_window_new (app);
103  * ]|
104  * 
105  * ## Handling fallback yourself
106  * 
107  * [A simple example](https://git.gnome.org/browse/gtk+/tree/examples/sunny.c)
108  * 
109  * The XML format understood by #GtkBuilder for #GMenuModel consists
110  * of a toplevel `<menu>` element, which contains one or more `<item>`
111  * elements. Each `<item>` element contains `<attribute>` and `<link>`
112  * elements with a mandatory name attribute. `<link>` elements have the
113  * same content model as `<menu>`. Instead of `<link name="submenu>` or
114  * `<link name="section">`, you can use `<submenu>` or `<section>`
115  * elements.
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  * The following attributes are used when constructing menu items:
125  * - "label": a user-visible string to display
126  * - "action": the prefixed name of the action to trigger
127  * - "target": the parameter to use when activating the action
128  * - "icon" and "verb-icon": names of icons that may be displayed
129  * - "submenu-action": name of an action that may be used to determine
130  * if a submenu can be opened
131  * - "hidden-when": a string used to determine when the item will be hidden.
132  * Possible values include "action-disabled", "action-missing", "macos-menubar".
133  * 
134  * The following attributes are used when constructing sections:
135  * - "label": a user-visible string to use as section heading
136  * - "display-hint": a string used to determine special formatting for the section.
137  * Possible values include "horizontal-buttons".
138  * 
139  * The following attributes are used when constructing submenus:
140  * - "label": a user-visible string to display
141  * - "icon": icon name to display
142  */
143 public class ApplicationWindow : Window, ActionGroupIF, ActionMapIF
144 {
145 	/** the main Gtk struct */
146 	protected GtkApplicationWindow* gtkApplicationWindow;
147 
148 	/** Get the main Gtk struct */
149 	public GtkApplicationWindow* getApplicationWindowStruct()
150 	{
151 		return gtkApplicationWindow;
152 	}
153 
154 	/** the main Gtk struct as a void* */
155 	protected override void* getStruct()
156 	{
157 		return cast(void*)gtkApplicationWindow;
158 	}
159 
160 	protected override void setStruct(GObject* obj)
161 	{
162 		gtkApplicationWindow = cast(GtkApplicationWindow*)obj;
163 		super.setStruct(obj);
164 	}
165 
166 	/**
167 	 * Sets our main struct and passes it to the parent class.
168 	 */
169 	public this (GtkApplicationWindow* gtkApplicationWindow, bool ownedRef = false)
170 	{
171 		this.gtkApplicationWindow = gtkApplicationWindow;
172 		super(cast(GtkWindow*)gtkApplicationWindow, ownedRef);
173 	}
174 
175 	// add the ActionGroup capabilities
176 	mixin ActionGroupT!(GtkApplicationWindow);
177 
178 	// add the ActionMap capabilities
179 	mixin ActionMapT!(GtkApplicationWindow);
180 
181 
182 	/** */
183 	public static GType getType()
184 	{
185 		return gtk_application_window_get_type();
186 	}
187 
188 	/**
189 	 * Creates a new #GtkApplicationWindow.
190 	 *
191 	 * Params:
192 	 *     application = a #GtkApplication
193 	 *
194 	 * Return: a newly created #GtkApplicationWindow
195 	 *
196 	 * Since: 3.4
197 	 *
198 	 * Throws: ConstructionException GTK+ fails to create the object.
199 	 */
200 	public this(Application application)
201 	{
202 		auto p = gtk_application_window_new((application is null) ? null : application.getGtkApplicationStruct());
203 		
204 		if(p is null)
205 		{
206 			throw new ConstructionException("null returned by new");
207 		}
208 		
209 		this(cast(GtkApplicationWindow*) p);
210 	}
211 
212 	/**
213 	 * Gets the #GtkShortcutsWindow that has been set up with
214 	 * a prior call to gtk_application_window_set_help_overlay().
215 	 *
216 	 * Return: the help overlay associated with @window, or %NULL
217 	 *
218 	 * Since: 3.20
219 	 */
220 	public ShortcutsWindow getHelpOverlay()
221 	{
222 		auto p = gtk_application_window_get_help_overlay(gtkApplicationWindow);
223 		
224 		if(p is null)
225 		{
226 			return null;
227 		}
228 		
229 		return ObjectG.getDObject!(ShortcutsWindow)(cast(GtkShortcutsWindow*) p);
230 	}
231 
232 	/**
233 	 * Returns the unique ID of the window. If the window has not yet been added to
234 	 * a #GtkApplication, returns `0`.
235 	 *
236 	 * Return: the unique ID for @window, or `0` if the window
237 	 *     has not yet been added to a #GtkApplication
238 	 *
239 	 * Since: 3.6
240 	 */
241 	public uint getId()
242 	{
243 		return gtk_application_window_get_id(gtkApplicationWindow);
244 	}
245 
246 	/**
247 	 * Returns whether the window will display a menubar for the app menu
248 	 * and menubar as needed.
249 	 *
250 	 * Return: %TRUE if @window will display a menubar when needed
251 	 *
252 	 * Since: 3.4
253 	 */
254 	public bool getShowMenubar()
255 	{
256 		return gtk_application_window_get_show_menubar(gtkApplicationWindow) != 0;
257 	}
258 
259 	/**
260 	 * Associates a shortcuts window with the application window, and
261 	 * sets up an action with the name win.show-help-overlay to present
262 	 * it.
263 	 *
264 	 * Params:
265 	 *     helpOverlay = a #GtkShortcutsWindow
266 	 *
267 	 * Since: 3.20
268 	 */
269 	public void setHelpOverlay(ShortcutsWindow helpOverlay)
270 	{
271 		gtk_application_window_set_help_overlay(gtkApplicationWindow, (helpOverlay is null) ? null : helpOverlay.getShortcutsWindowStruct());
272 	}
273 
274 	/**
275 	 * Sets whether the window will display a menubar for the app menu
276 	 * and menubar as needed.
277 	 *
278 	 * Params:
279 	 *     showMenubar = whether to show a menubar when needed
280 	 *
281 	 * Since: 3.4
282 	 */
283 	public void setShowMenubar(bool showMenubar)
284 	{
285 		gtk_application_window_set_show_menubar(gtkApplicationWindow, showMenubar);
286 	}
287 }