Gtk.ApplicationWindow
const Gtk = imports.gi.Gtk;
let application_window = new Gtk.ApplicationWindow({
show_menubar: value,
});
GtkApplicationWindow is a Gtk.Window subclass that offers some extra functionality for better integration with Gtk.Application features. Notably, it can handle both the application menu as well as the menubar. See Gtk.Application.prototype.set_app_menu and Gtk.Application.prototype.set_menubar.
This class implements the Gio.ActionGroup and Gio.ActionMap interfaces, to let you add window-specific actions that will be exported by the associated Gtk.Application, together with its application-wide actions. Window-specific actions are prefixed with the "win." prefix and application-wide actions are prefixed with the "app." prefix. Actions must be addressed with the prefixed name when referring to them from a Gio.MenuModel.
Note that widgets that are placed inside a GtkApplicationWindow can also activate these actions, if they implement the GtkActionable interface.
As with Gtk.Application, the GDK lock will be acquired when processing actions arriving from other processes and should therefore be held when activating actions locally (if GDK threads are enabled).
The settings Gtk.gtk-shell-shows-app-menu and Gtk.gtk-shell-shows-menubar tell GTK+ whether the desktop environment is showing the application menu and menubar models outside the application as part of the desktop shell. For instance, on OS X, both menus will be displayed remotely; on Windows neither will be. gnome-shell (starting with version 3.4) will display the application menu, but not the menubar.
If the desktop environment does not display the menubar, then Gtk.ApplicationWindow will automatically show a Gtk.MenuBar for it. (see the Gtk.Application docs for some screenshots of how this looks on different platforms). This behaviour can be overridden with the Gtk.show-menubar property. If the desktop environment does not display the application menu, then it will automatically be included in the menubar.
<example><title>A GtkApplicationWindow with a menubar</title> <programlisting><![CDATA[ app = gtk_application_new ();
builder = gtk_builder_new (); gtk_builder_add_from_string (builder, "<interface>" " <menu id='menubar'>" " <submenu label='_Edit'>" " <item label='_Copy' action='win.copy'/>" " <item label='_Paste' action='win.paste'/>" " </submenu>" " </menu>" "</interface>"); gtk_application_set_menubar (G_APPLICATION (app), G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"))); g_object_unref (builder);
...
window = gtk_application_window_new (app); ]]> </programlisting> </example>
<example><title>Handling fallback yourself</title> <programlisting> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/sunny.c"> <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> </xi:include> </programlisting> </example>
The XML format understood by Gtk.Builder for Gio.MenuModel consists of a toplevel <tag class="starttag">menu</tag> element, which contains one or more <tag class="starttag">item</tag> elements. Each <tag class="starttag">item</tag> element contains <tag class="starttag">attribute</tag> and <tag class="starttag">link</tag> elements with a mandatory name attribute. <tag class="starttag">link</tag> elements have the same content model as <tag class="starttag">menu</tag>.
Attribute values can be translated using gettext, like other Gtk.Builder content. <tag class="starttag">attribute</tag> elements can be marked for translation with a <literal>translatable="yes"</literal> attribute. It is also possible to specify message context and translator comments, using the context and comments attributes. To make use of this, the Gtk.Builder must have been given the gettext domain to use.
Hierarchy
-
GObject.Object
-
GObject.InitiallyUnowned
-
Gtk.Widget
-
Gtk.Container
-
Gtk.Bin
-
Gtk.Window
- Gtk.ApplicationWindow
-
-
-
-
-