Gtk.ApplicationWindow

g GObject.GInterface GObject.GInterface Gio.ActionGroup Gio.ActionGroup GObject.GInterface->Gio.ActionGroup Gio.ActionMap Gio.ActionMap GObject.GInterface->Gio.ActionMap Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget Gtk.Native Gtk.Native GObject.GInterface->Gtk.Native Gtk.Root Gtk.Root GObject.GInterface->Gtk.Root Gtk.ShortcutManager Gtk.ShortcutManager GObject.GInterface->Gtk.ShortcutManager GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.ApplicationWindow Gtk.ApplicationWindow Gio.ActionGroup->Gtk.ApplicationWindow Gio.ActionMap->Gtk.ApplicationWindow Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Window Gtk.Window Gtk.Native->Gtk.Window Gtk.Root->Gtk.Window Gtk.ShortcutManager->Gtk.Window Gtk.Widget->Gtk.Window Gtk.Window->Gtk.ApplicationWindow

Subclasses:

None

Methods

Inherited:

Gtk.Window (62), Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Native (6), Gtk.Root (3), Gio.ActionGroup (14), Gio.ActionMap (5)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new (application)

get_help_overlay ()

get_id ()

get_show_menubar ()

set_help_overlay (help_overlay)

set_show_menubar (show_menubar)

Virtual Methods

Inherited:

Gtk.Window (5), Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.ShortcutManager (2), Gio.ActionGroup (14), Gio.ActionMap (3)

Properties

Inherited:

Gtk.Window (25), Gtk.Widget (34), Gtk.Accessible (1)

Name

Type

Flags

Short Description

show-menubar

bool

r/w/c/en

Signals

Inherited:

Gtk.Window (5), Gtk.Widget (13), GObject.Object (1), Gio.ActionGroup (4)

Fields

Inherited:

Gtk.Window (5), Gtk.Widget (13), GObject.Object (1), Gio.ActionGroup (4)

Name

Type

Access

Description

parent_instance

Gtk.Window

r

Class Details

class Gtk.ApplicationWindow(*args, **kwargs)
Bases:

Gtk.Window, Gio.ActionGroup, Gio.ActionMap

Abstract:

No

Structure:

Gtk.ApplicationWindowClass

GtkApplicationWindow is a GtkWindow subclass that integrates with GtkApplication.

Notably, GtkApplicationWindow can handle an application menubar.

This class implements the GActionGroup and GActionMap interfaces, to let you add window-specific actions that will be exported by the associated [class`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 GMenuModel.

Note that widgets that are placed inside a GtkApplicationWindow can also activate these actions, if they implement the [iface`Gtk`.Actionable] interface.

The settings [property`Gtk`.Settings:gtk-shell-shows-app-menu] and [property`Gtk`.Settings: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.

If the desktop environment does not display the menubar, then GtkApplicationWindow will automatically show a menubar for it. This behaviour can be overridden with the [property`Gtk`.ApplicationWindow:show-menubar] property. If the desktop environment does not display the application menu, then it will automatically be included in the menubar or in the windows client-side decorations.

See [class`Gtk`.PopoverMenu] for information about the XML language used by GtkBuilder for menu models.

See also: [method`Gtk`.Application.set_menubar].

A Gtk.ApplicationWindow with a menubar

The code sample below shows how to set up a GtkApplicationWindow with a menu bar defined on the [class`Gtk`.Application]:

```c Gtk.Application *app = Gtk.Application.new (“org.gtk.test”, 0);

Gtk.Builder *builder = Gtk.Builder.new_from_string ( “” “ ” “ <submenu>” “ _Edit</attribute>” “ <item>” “ _Copy</attribute>” “ win.copy</attribute>” “ </item>” “ <item>” “ _Paste</attribute>” “ win.paste</attribute>” “ </item>” “ </submenu>” “ </menu>” “”, -1); Gio.MenuModel *menubar = G_MENU_MODEL (Gtk.Builder.get_object (builder, “menubar”)); Gtk.Application.set_menubar (GTK_APPLICATION (app), menubar); GObject.Object.unref (builder);

// …

Gtk.Widget *window = Gtk.ApplicationWindow.new (app); ```

classmethod new(application)[source]
Parameters:

application (Gtk.Application) – a GtkApplication

Returns:

a newly created GtkApplicationWindow

Return type:

Gtk.Widget

Creates a new GtkApplicationWindow.

get_help_overlay()[source]
Returns:

the help overlay associated with self

Return type:

Gtk.ShortcutsWindow or None

Gets the GtkShortcutsWindow that is associated with self.

See [method`Gtk`.ApplicationWindow.set_help_overlay].

get_id()[source]
Returns:

the unique ID for self, or 0 if the window has not yet been added to a GtkApplication

Return type:

int

Returns the unique ID of the window.

If the window has not yet been added to a GtkApplication, returns 0.

get_show_menubar()[source]
Returns:

True if self will display a menubar when needed

Return type:

bool

Returns whether the window will display a menubar for the app menu and menubar as needed.

set_help_overlay(help_overlay)[source]
Parameters:

help_overlay (Gtk.ShortcutsWindow or None) – a GtkShortcutsWindow

Associates a shortcuts window with the application window.

Additionally, sets up an action with the name win.show-help-overlay to present it.

self takes responsibility for destroying help_overlay.

set_show_menubar(show_menubar)[source]
Parameters:

show_menubar (bool) – whether to show a menubar when needed

Sets whether the window will display a menubar for the app menu and menubar as needed.

Property Details

Gtk.ApplicationWindow.props.show_menubar
Name:

show-menubar

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY

If this property is True, the window will display a menubar unless it is shown by the desktop shell.

See [method`Gtk`.Application.set_menubar].

If False, the window will not display a menubar, regardless of whether the desktop shell is showing it or not.