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 * This behaviour can be overridden with the #GtkApplicationWindow:show-menubar 74 * property. If the desktop environment does not display the application 75 * menu, then it will automatically be included in the menubar or in the 76 * windows client-side decorations. 77 * 78 * ## A GtkApplicationWindow with a menubar 79 * 80 * |[<!-- language="C" --> 81 * app = gtk_application_new (); 82 * 83 * builder = gtk_builder_new_from_string ( 84 * "<interface>" 85 * " <menu id='menubar'>" 86 * " <submenu label='_Edit'>" 87 * " <item label='_Copy' action='win.copy'/>" 88 * " <item label='_Paste' action='win.paste'/>" 89 * " </submenu>" 90 * " </menu>" 91 * "</interface>", 92 * -1); 93 * 94 * menubar = G_MENU_MODEL (gtk_builder_get_object (builder, 95 * "menubar")); 96 * gtk_application_set_menubar (G_APPLICATION (app), menubar); 97 * g_object_unref (builder); 98 * 99 * ... 100 * 101 * window = gtk_application_window_new (app); 102 * ]| 103 * 104 * ## Handling fallback yourself 105 * 106 * [A simple example](https://git.gnome.org/browse/gtk+/tree/examples/sunny.c) 107 * 108 * The XML format understood by #GtkBuilder for #GMenuModel consists 109 * of a toplevel `<menu>` element, which contains one or more `<item>` 110 * elements. Each `<item>` element contains `<attribute>` and `<link>` 111 * elements with a mandatory name attribute. `<link>` elements have the 112 * same content model as `<menu>`. Instead of `<link name="submenu>` or 113 * `<link name="section">`, you can use `<submenu>` or `<section>` 114 * elements. 115 * 116 * Attribute values can be translated using gettext, like other #GtkBuilder 117 * content. `<attribute>` elements can be marked for translation with a 118 * `translatable="yes"` attribute. It is also possible to specify message 119 * context and translator comments, using the context and comments attributes. 120 * To make use of this, the #GtkBuilder must have been given the gettext 121 * domain to use. 122 * 123 * The following attributes are used when constructing menu items: 124 * - "label": a user-visible string to display 125 * - "action": the prefixed name of the action to trigger 126 * - "target": the parameter to use when activating the action 127 * - "icon" and "verb-icon": names of icons that may be displayed 128 * - "submenu-action": name of an action that may be used to determine 129 * if a submenu can be opened 130 * - "hidden-when": a string used to determine when the item will be hidden. 131 * Possible values include "action-disabled", "action-missing", "macos-menubar". 132 * 133 * The following attributes are used when constructing sections: 134 * - "label": a user-visible string to use as section heading 135 * - "display-hint": a string used to determine special formatting for the section. 136 * Possible values include "horizontal-buttons". 137 * 138 * The following attributes are used when constructing submenus: 139 * - "label": a user-visible string to display 140 * - "icon": icon name to display 141 */ 142 public class ApplicationWindow : Window, ActionGroupIF, ActionMapIF 143 { 144 /** the main Gtk struct */ 145 protected GtkApplicationWindow* gtkApplicationWindow; 146 147 /** Get the main Gtk struct */ 148 public GtkApplicationWindow* getApplicationWindowStruct() 149 { 150 return gtkApplicationWindow; 151 } 152 153 /** the main Gtk struct as a void* */ 154 protected override void* getStruct() 155 { 156 return cast(void*)gtkApplicationWindow; 157 } 158 159 protected override void setStruct(GObject* obj) 160 { 161 gtkApplicationWindow = cast(GtkApplicationWindow*)obj; 162 super.setStruct(obj); 163 } 164 165 /** 166 * Sets our main struct and passes it to the parent class. 167 */ 168 public this (GtkApplicationWindow* gtkApplicationWindow, bool ownedRef = false) 169 { 170 this.gtkApplicationWindow = gtkApplicationWindow; 171 super(cast(GtkWindow*)gtkApplicationWindow, ownedRef); 172 } 173 174 // add the ActionGroup capabilities 175 mixin ActionGroupT!(GtkApplicationWindow); 176 177 // add the ActionMap capabilities 178 mixin ActionMapT!(GtkApplicationWindow); 179 180 181 /** */ 182 public static GType getType() 183 { 184 return gtk_application_window_get_type(); 185 } 186 187 /** 188 * Creates a new #GtkApplicationWindow. 189 * 190 * Params: 191 * application = a #GtkApplication 192 * 193 * Return: a newly created #GtkApplicationWindow 194 * 195 * Since: 3.4 196 * 197 * Throws: ConstructionException GTK+ fails to create the object. 198 */ 199 public this(Application application) 200 { 201 auto p = gtk_application_window_new((application is null) ? null : application.getGtkApplicationStruct()); 202 203 if(p is null) 204 { 205 throw new ConstructionException("null returned by new"); 206 } 207 208 this(cast(GtkApplicationWindow*) p); 209 } 210 211 /** 212 * Returns the unique ID of the window. If the window has not yet been added to 213 * a #GtkApplication, returns `0`. 214 * 215 * Return: the unique ID for @window, or `0` if the window 216 * has not yet been added to a #GtkApplication 217 * 218 * Since: 3.6 219 */ 220 public uint getId() 221 { 222 return gtk_application_window_get_id(gtkApplicationWindow); 223 } 224 225 /** 226 * Returns whether the window will display a menubar for the app menu 227 * and menubar as needed. 228 * 229 * Return: %TRUE if @window will display a menubar when needed 230 * 231 * Since: 3.4 232 */ 233 public bool getShowMenubar() 234 { 235 return gtk_application_window_get_show_menubar(gtkApplicationWindow) != 0; 236 } 237 238 /** 239 * Sets whether the window will display a menubar for the app menu 240 * and menubar as needed. 241 * 242 * Params: 243 * showMenubar = whether to show a menubar when needed 244 * 245 * Since: 3.4 246 */ 247 public void setShowMenubar(bool showMenubar) 248 { 249 gtk_application_window_set_show_menubar(gtkApplicationWindow, showMenubar); 250 } 251 }