Gtk.ApplicationWindow¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Window (62), Gtk.Widget (183), GObject.Object (37), Gtk.Accessible (17), 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:
A
GtkWindowsubclass that integrates withGtkApplication.Notably,
GtkApplicationWindowcan handle an application menubar.This class implements the [iface`Gio`.ActionGroup] and [iface`Gio`.ActionMap] 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 menu model.
Note that widgets that are placed inside a
GtkApplicationWindowcan 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, it can be shown in the
GtkApplicationWindowby setting the [property`Gtk`.ApplicationWindow:show-menubar] property to true. If the desktop environment does not display the application menu, then it will automatically be included in the menubar or in the window’s client-side decorations.See [class`Gtk`.PopoverMenu] for information about the XML language used by
GtkBuilderfor menu models.See also: [method`Gtk`.Application.set_menubar].
- A
Gtk.ApplicationWindowwith a menubar
The code sample below shows how to set up a
GtkApplicationWindowwith 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) – an application- Returns:
a newly created
GtkApplicationWindow- Return type:
Creates a new
GtkApplicationWindow.
- get_help_overlay()[source]¶
- Returns:
the help overlay associated with the window
- Return type:
Gets the
GtkShortcutsWindowthat is associated with self.See [method`Gtk`.ApplicationWindow.set_help_overlay].
Deprecated since version 4.18:
GtkShortcutsWindowwill be removed in GTK 5
- get_id()[source]¶
- Returns:
the unique ID for the window, or
0if the window has not yet been added to an application- Return type:
Returns the unique ID of the window.
If the window has not yet been added to a
GtkApplication, returns0.
- Returns:
True if the window will display a menubar when needed
- Return type:
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.ShortcutsWindoworNone) – a shortcuts window
Associates a shortcuts window with the application window.
Additionally, sets up an action with the name
win.show-help-overlayto present it.The window takes responsibility for destroying the help overlay.
Deprecated since version 4.18:
GtkShortcutsWindowwill be removed in GTK 5
- 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.