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 gtk.c.functions;
38 public  import gtk.c.types;
39 
40 
41 /**
42  * `GtkApplicationWindow` is a `GtkWindow` subclass that integrates with
43  * `GtkApplication`.
44  * 
45  * Notably, `GtkApplicationWindow` can handle an application 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 [class@Gtk.Application], 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  * [iface@Gtk.Actionable] interface.
58  * 
59  * The settings [property@Gtk.Settings:gtk-shell-shows-app-menu] and
60  * [property@Gtk.Settings:gtk-shell-shows-menubar] tell GTK whether the
61  * desktop environment is showing the application menu and menubar
62  * models outside the application as part of the desktop shell.
63  * For instance, on OS X, both menus will be displayed remotely;
64  * on Windows neither will be.
65  * 
66  * If the desktop environment does not display the menubar, then
67  * `GtkApplicationWindow` will automatically show a menubar for it.
68  * This behaviour can be overridden with the
69  * [property@Gtk.ApplicationWindow:show-menubar] property. If the
70  * desktop environment does not display the application menu, then
71  * it will automatically be included in the menubar or in the windows
72  * client-side decorations.
73  * 
74  * See [class@Gtk.PopoverMenu] for information about the XML language
75  * used by `GtkBuilder` for menu models.
76  * 
77  * See also: [method@Gtk.Application.set_menubar].
78  * 
79  * ## A GtkApplicationWindow with a menubar
80  * 
81  * The code sample below shows how to set up a `GtkApplicationWindow`
82  * with a menu bar defined on the [class@Gtk.Application]:
83  * 
84  * ```c
85  * GtkApplication *app = gtk_application_new ("org.gtk.test", 0);
86  * 
87  * GtkBuilder *builder = gtk_builder_new_from_string (
88  * "<interface>"
89  * "  <menu id='menubar'>"
90  * "    <submenu>"
91  * "      <attribute name='label' translatable='yes'>_Edit</attribute>"
92  * "      <item>"
93  * "        <attribute name='label' translatable='yes'>_Copy</attribute>"
94  * "        <attribute name='action'>win.copy</attribute>"
95  * "      </item>"
96  * "      <item>"
97  * "        <attribute name='label' translatable='yes'>_Paste</attribute>"
98  * "        <attribute name='action'>win.paste</attribute>"
99  * "      </item>"
100  * "    </submenu>"
101  * "  </menu>"
102  * "</interface>",
103  * -1);
104  * 
105  * GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"));
106  * gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
107  * g_object_unref (builder);
108  * 
109  * // ...
110  * 
111  * GtkWidget *window = gtk_application_window_new (app);
112  * ```
113  */
114 public class ApplicationWindow : Window, ActionGroupIF, ActionMapIF
115 {
116 	/** the main Gtk struct */
117 	protected GtkApplicationWindow* gtkApplicationWindow;
118 
119 	/** Get the main Gtk struct */
120 	public GtkApplicationWindow* getApplicationWindowStruct(bool transferOwnership = false)
121 	{
122 		if (transferOwnership)
123 			ownedRef = false;
124 		return gtkApplicationWindow;
125 	}
126 
127 	/** the main Gtk struct as a void* */
128 	protected override void* getStruct()
129 	{
130 		return cast(void*)gtkApplicationWindow;
131 	}
132 
133 	/**
134 	 * Sets our main struct and passes it to the parent class.
135 	 */
136 	public this (GtkApplicationWindow* gtkApplicationWindow, bool ownedRef = false)
137 	{
138 		this.gtkApplicationWindow = gtkApplicationWindow;
139 		super(cast(GtkWindow*)gtkApplicationWindow, ownedRef);
140 	}
141 
142 	// add the ActionGroup capabilities
143 	mixin ActionGroupT!(GtkApplicationWindow);
144 
145 	// add the ActionMap capabilities
146 	mixin ActionMapT!(GtkApplicationWindow);
147 
148 
149 	/** */
150 	public static GType getType()
151 	{
152 		return gtk_application_window_get_type();
153 	}
154 
155 	/**
156 	 * Creates a new `GtkApplicationWindow`.
157 	 *
158 	 * Params:
159 	 *     application = a `GtkApplication`
160 	 *
161 	 * Returns: a newly created `GtkApplicationWindow`
162 	 *
163 	 * Throws: ConstructionException GTK+ fails to create the object.
164 	 */
165 	public this(Application application)
166 	{
167 		auto __p = gtk_application_window_new((application is null) ? null : application.getGtkApplicationStruct());
168 
169 		if(__p is null)
170 		{
171 			throw new ConstructionException("null returned by new");
172 		}
173 
174 		this(cast(GtkApplicationWindow*) __p);
175 	}
176 
177 	/**
178 	 * Gets the `GtkShortcutsWindow` that is associated with @window.
179 	 *
180 	 * See [method@Gtk.ApplicationWindow.set_help_overlay].
181 	 *
182 	 * Returns: the help overlay associated
183 	 *     with @window, or %NULL
184 	 */
185 	public ShortcutsWindow getHelpOverlay()
186 	{
187 		auto __p = gtk_application_window_get_help_overlay(gtkApplicationWindow);
188 
189 		if(__p is null)
190 		{
191 			return null;
192 		}
193 
194 		return ObjectG.getDObject!(ShortcutsWindow)(cast(GtkShortcutsWindow*) __p);
195 	}
196 
197 	/**
198 	 * Returns the unique ID of the window.
199 	 *
200 	 * If the window has not yet been added to a `GtkApplication`, returns `0`.
201 	 *
202 	 * Returns: the unique ID for @window, or `0` if the window
203 	 *     has not yet been added to a `GtkApplication`
204 	 */
205 	public uint getId()
206 	{
207 		return gtk_application_window_get_id(gtkApplicationWindow);
208 	}
209 
210 	/**
211 	 * Returns whether the window will display a menubar for the app menu
212 	 * and menubar as needed.
213 	 *
214 	 * Returns: %TRUE if @window will display a menubar when needed
215 	 */
216 	public bool getShowMenubar()
217 	{
218 		return gtk_application_window_get_show_menubar(gtkApplicationWindow) != 0;
219 	}
220 
221 	/**
222 	 * Associates a shortcuts window with the application window.
223 	 *
224 	 * Additionally, sets up an action with the name
225 	 * `win.show-help-overlay` to present it.
226 	 *
227 	 * @window takes responsibility for destroying @help_overlay.
228 	 *
229 	 * Params:
230 	 *     helpOverlay = a `GtkShortcutsWindow`
231 	 */
232 	public void setHelpOverlay(ShortcutsWindow helpOverlay)
233 	{
234 		gtk_application_window_set_help_overlay(gtkApplicationWindow, (helpOverlay is null) ? null : helpOverlay.getShortcutsWindowStruct());
235 	}
236 
237 	/**
238 	 * Sets whether the window will display a menubar for the app menu
239 	 * and menubar as needed.
240 	 *
241 	 * Params:
242 	 *     showMenubar = whether to show a menubar when needed
243 	 */
244 	public void setShowMenubar(bool showMenubar)
245 	{
246 		gtk_application_window_set_show_menubar(gtkApplicationWindow, showMenubar);
247 	}
248 }