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:
class |
|
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
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 |
r |
Class Details¶
- class Gtk.ApplicationWindow(*args, **kwargs)¶
- Bases:
- Abstract:
No
- Structure:
GtkApplicationWindow
is aGtkWindow
subclass that integrates withGtkApplication
.Notably,
GtkApplicationWindow
can handle an application menubar.This class implements the
GActionGroup
andGActionMap
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 aGMenuModel
.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
) – aGtkApplication
- Returns:
a newly created
GtkApplicationWindow
- Return type:
Creates a new
GtkApplicationWindow
.
- get_help_overlay()[source]¶
- Returns:
the help overlay associated with self
- Return type:
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 aGtkApplication
- Return type:
Returns the unique ID of the window.
If the window has not yet been added to a
GtkApplication
, returns0
.
-
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
orNone
) – aGtkShortcutsWindow
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.
- 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¶
- Name:
show-menubar
- Type:
- Default Value:
- Flags:
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.