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), 100 * menubar); 101 * g_object_unref (builder); 102 * 103 * ... 104 * 105 * window = gtk_application_window_new (app); 106 * ]| 107 * 108 * ## Handling fallback yourself 109 * 110 * [A simple example](https://git.gnome.org/browse/gtk+/tree/examples/sunny.c) 111 * 112 * The XML format understood by #GtkBuilder for #GMenuModel consists 113 * of a toplevel `<menu>` element, which contains one or more `<item>` 114 * elements. Each `<item>` element contains `<attribute>` and `<link>` 115 * elements with a mandatory name attribute. `<link>` elements have the 116 * same content model as `<menu>`. 117 * 118 * Attribute values can be translated using gettext, like other #GtkBuilder 119 * content. `<attribute>` elements can be marked for translation with a 120 * `translatable="yes"` attribute. It is also possible to specify message 121 * context and translator comments,using the context and comments attributes. 122 * To make use of this, the #GtkBuilder must have been given the gettext 123 * domain to use. 124 */ 125 public class ApplicationWindow : Window, ActionGroupIF, ActionMapIF 126 { 127 /** the main Gtk struct */ 128 protected GtkApplicationWindow* gtkApplicationWindow; 129 130 /** Get the main Gtk struct */ 131 public GtkApplicationWindow* getApplicationWindowStruct() 132 { 133 return gtkApplicationWindow; 134 } 135 136 /** the main Gtk struct as a void* */ 137 protected override void* getStruct() 138 { 139 return cast(void*)gtkApplicationWindow; 140 } 141 142 protected override void setStruct(GObject* obj) 143 { 144 gtkApplicationWindow = cast(GtkApplicationWindow*)obj; 145 super.setStruct(obj); 146 } 147 148 /** 149 * Sets our main struct and passes it to the parent class. 150 */ 151 public this (GtkApplicationWindow* gtkApplicationWindow, bool ownedRef = false) 152 { 153 this.gtkApplicationWindow = gtkApplicationWindow; 154 super(cast(GtkWindow*)gtkApplicationWindow, ownedRef); 155 } 156 157 // add the ActionGroup capabilities 158 mixin ActionGroupT!(GtkApplicationWindow); 159 160 // add the ActionMap capabilities 161 mixin ActionMapT!(GtkApplicationWindow); 162 163 /** 164 */ 165 166 public static GType getType() 167 { 168 return gtk_application_window_get_type(); 169 } 170 171 /** 172 * Creates a new #GtkApplicationWindow. 173 * 174 * Params: 175 * application = a #GtkApplication 176 * 177 * Return: a newly created #GtkApplicationWindow 178 * 179 * Since: 3.4 180 * 181 * Throws: ConstructionException GTK+ fails to create the object. 182 */ 183 public this(Application application) 184 { 185 auto p = gtk_application_window_new((application is null) ? null : application.getGtkApplicationStruct()); 186 187 if(p is null) 188 { 189 throw new ConstructionException("null returned by new"); 190 } 191 192 this(cast(GtkApplicationWindow*) p); 193 } 194 195 /** 196 * Returns the unique ID of the window. If the window has not yet been added to 197 * a #GtkApplication, returns `0`. 198 * 199 * Return: the unique ID for @window, or `0` if the window 200 * has not yet been added to a #GtkApplication 201 * 202 * Since: 3.6 203 */ 204 public uint getId() 205 { 206 return gtk_application_window_get_id(gtkApplicationWindow); 207 } 208 209 /** 210 * Returns whether the window will display a menubar for the app menu 211 * and menubar as needed. 212 * 213 * Return: %TRUE if @window will display a menubar when needed 214 * 215 * Since: 3.4 216 */ 217 public bool getShowMenubar() 218 { 219 return gtk_application_window_get_show_menubar(gtkApplicationWindow) != 0; 220 } 221 222 /** 223 * Sets whether the window will display a menubar for the app menu 224 * and menubar as needed. 225 * 226 * Params: 227 * showMenubar = whether to show a menubar when needed 228 * 229 * Since: 3.4 230 */ 231 public void setShowMenubar(bool showMenubar) 232 { 233 gtk_application_window_set_show_menubar(gtkApplicationWindow, showMenubar); 234 } 235 }