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  * - "text-direction": a string used to determine the #GtkTextDirection to use
139  * when "display-hint" is set to "horizontal-buttons". Possible values
140  * include "rtl", "ltr", and "none".
141  * 
142  * The following attributes are used when constructing submenus:
143  * - "label": a user-visible string to display
144  * - "icon": icon name to display
145  */
146 public class ApplicationWindow : Window, ActionGroupIF, ActionMapIF
147 {
148 	/** the main Gtk struct */
149 	protected GtkApplicationWindow* gtkApplicationWindow;
150 
151 	/** Get the main Gtk struct */
152 	public GtkApplicationWindow* getApplicationWindowStruct()
153 	{
154 		return gtkApplicationWindow;
155 	}
156 
157 	/** the main Gtk struct as a void* */
158 	protected override void* getStruct()
159 	{
160 		return cast(void*)gtkApplicationWindow;
161 	}
162 
163 	protected override void setStruct(GObject* obj)
164 	{
165 		gtkApplicationWindow = cast(GtkApplicationWindow*)obj;
166 		super.setStruct(obj);
167 	}
168 
169 	/**
170 	 * Sets our main struct and passes it to the parent class.
171 	 */
172 	public this (GtkApplicationWindow* gtkApplicationWindow, bool ownedRef = false)
173 	{
174 		this.gtkApplicationWindow = gtkApplicationWindow;
175 		super(cast(GtkWindow*)gtkApplicationWindow, ownedRef);
176 	}
177 
178 	// add the ActionGroup capabilities
179 	mixin ActionGroupT!(GtkApplicationWindow);
180 
181 	// add the ActionMap capabilities
182 	mixin ActionMapT!(GtkApplicationWindow);
183 
184 
185 	/** */
186 	public static GType getType()
187 	{
188 		return gtk_application_window_get_type();
189 	}
190 
191 	/**
192 	 * Creates a new #GtkApplicationWindow.
193 	 *
194 	 * Params:
195 	 *     application = a #GtkApplication
196 	 *
197 	 * Return: a newly created #GtkApplicationWindow
198 	 *
199 	 * Since: 3.4
200 	 *
201 	 * Throws: ConstructionException GTK+ fails to create the object.
202 	 */
203 	public this(Application application)
204 	{
205 		auto p = gtk_application_window_new((application is null) ? null : application.getGtkApplicationStruct());
206 		
207 		if(p is null)
208 		{
209 			throw new ConstructionException("null returned by new");
210 		}
211 		
212 		this(cast(GtkApplicationWindow*) p);
213 	}
214 
215 	/**
216 	 * Gets the #GtkShortcutsWindow that has been set up with
217 	 * a prior call to gtk_application_window_set_help_overlay().
218 	 *
219 	 * Return: the help overlay associated with @window, or %NULL
220 	 *
221 	 * Since: 3.20
222 	 */
223 	public ShortcutsWindow getHelpOverlay()
224 	{
225 		auto p = gtk_application_window_get_help_overlay(gtkApplicationWindow);
226 		
227 		if(p is null)
228 		{
229 			return null;
230 		}
231 		
232 		return ObjectG.getDObject!(ShortcutsWindow)(cast(GtkShortcutsWindow*) p);
233 	}
234 
235 	/**
236 	 * Returns the unique ID of the window. If the window has not yet been added to
237 	 * a #GtkApplication, returns `0`.
238 	 *
239 	 * Return: the unique ID for @window, or `0` if the window
240 	 *     has not yet been added to a #GtkApplication
241 	 *
242 	 * Since: 3.6
243 	 */
244 	public uint getId()
245 	{
246 		return gtk_application_window_get_id(gtkApplicationWindow);
247 	}
248 
249 	/**
250 	 * Returns whether the window will display a menubar for the app menu
251 	 * and menubar as needed.
252 	 *
253 	 * Return: %TRUE if @window will display a menubar when needed
254 	 *
255 	 * Since: 3.4
256 	 */
257 	public bool getShowMenubar()
258 	{
259 		return gtk_application_window_get_show_menubar(gtkApplicationWindow) != 0;
260 	}
261 
262 	/**
263 	 * Associates a shortcuts window with the application window, and
264 	 * sets up an action with the name win.show-help-overlay to present
265 	 * it.
266 	 *
267 	 * @window takes resposibility for destroying @help_overlay.
268 	 *
269 	 * Params:
270 	 *     helpOverlay = a #GtkShortcutsWindow
271 	 *
272 	 * Since: 3.20
273 	 */
274 	public void setHelpOverlay(ShortcutsWindow helpOverlay)
275 	{
276 		gtk_application_window_set_help_overlay(gtkApplicationWindow, (helpOverlay is null) ? null : helpOverlay.getShortcutsWindowStruct());
277 	}
278 
279 	/**
280 	 * Sets whether the window will display a menubar for the app menu
281 	 * and menubar as needed.
282 	 *
283 	 * Params:
284 	 *     showMenubar = whether to show a menubar when needed
285 	 *
286 	 * Since: 3.4
287 	 */
288 	public void setShowMenubar(bool showMenubar)
289 	{
290 		gtk_application_window_set_show_menubar(gtkApplicationWindow, showMenubar);
291 	}
292 }