Package: gtk

Class gtk-application-window

Superclasses

gtk-window, gtk-bin, gtk-container, gtk-widget, gtk-buildable, g-action-group, g-action-map, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

show-menubar
The show-menubar property of type :boolean (Read / Write / Construct)
If this property is true, the application window will display a menubar that includes the application menu and menubar, unless these are shown by the desktop shell. If false, the applicaton window will not display a menubar, regardless of whether the desktop shell is showing the menus or not.
Default value: true

Details

The gtk-application-window class 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 the gtk-application-app-menu and gtk-application-menubar functions.

This class implements the g-action-group and g-action-map interfaces, to let you add window specific actions that will be exported by the associated gtk-application instance, 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 g-menu-model object.

Note that widgets that are placed inside an application window can also activate these actions, if they implement the gtk-actionable interface.

As with the gtk-application class, 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 gtk-shell-shows-app-menu and gtk-shell-shows-menubar settings 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 the application window will automatically show a gtk-menu-bar widget for it. This behaviour can be overridden with the show-menubar property. If the desktop environment does not display the application menu, then it will automatically be included in the menubar.

Example: An application window with a menubar
 ;; Intitialize the menubar
 (let ((builder (make-instance 'gtk-builder)))
   ;; Read the menus from a string
   (gtk-builder-add-from-string
       builder
       (format nil
               "<interface> ~
                   <menu id='menubar'> ~
                     <submenu label='_Edit'> ~
                       <item label='_Copy' action='win.copy'/> ~
                       <item label='_Paste' action='win.paste'/> ~
                     </submenu> ~
                   </menu> ~
                 </interface>"))
   ;; Set the menubar
   (setf (gtk-application-menubar application)
         (gtk-builder-object builder "menubar"))
   ... )  


Handling fallback yourself
The XML format understood by the gtk-builder class for a g-menu-model object consists of a toplevel <menu> element, which contains one or more <item> elements. Each <item> element contains <attribute> and <link> elements with a mandatory name attribute. <link> elements have the same content model as <menu>. Instead of <link name="submenu"> or <link name="section">, you can use <submenu> or <section> elements.

Attribute values can be translated using GNU gettext, like other gtk-builder content. <attribute> elements can be marked for translation with a translatable = "yes" 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 object must have been given the GNU gettext domain to use.

The following attributes are used when constructing menu items:
  • label: a user visible string to display
  • action: the prefixed name of the action to trigger
  • target: the parameter to use when activating the action
  • icon and verb-icon: names of icons that may be displayed
  • submenu-action: name of an action that may be used to determine if a submenu can be opened
  • hidden-when: a string used to determine when the item will be hidden. Possible values include "action-disabled", "action-missing", "macos-menubar".
The following attributes are used when constructing sections:
  • label: a user visible string to use as section heading
  • display-hint: a string used to determine special formatting for the section. Possible values include "horizontal-buttons".
  • text-direction: a string used to determine the gtk-text-direction value to use when "display-hint" is set to "horizontal-buttons". Possible values include "rtl", "ltr", and "none".
The following attributes are used when constructing submenus:
  • label: a user visible string to display
  • icon: icon name to display
 

Slot Access Functions

Inherited Slot Access Functions

gtk-container-border-width
gtk-container-child
gtk-container-resize-mode
gtk-window-accept-focus
gtk-window-application
gtk-window-attached-to
gtk-window-decorated
gtk-window-default-height
gtk-window-default-width
gtk-window-deletable
gtk-window-destroy-with-parent
gtk-window-focus-on-map
gtk-window-focus-visible
gtk-window-gravity
gtk-window-has-resize-grip
gtk-window-has-toplevel-focus
gtk-window-hide-titlebar-when-maximized
gtk-window-icon
gtk-window-icon-name
gtk-window-is-active
gtk-window-mnemonics-visible
gtk-window-modal
gtk-window-opacity
gtk-window-resizable
gtk-window-resize-grip-visible
gtk-window-role
gtk-window-screen
gtk-window-skip-pager-hint
gtk-window-skip-taskbar-hint
gtk-window-startup-id
gtk-window-title
gtk-window-transient-for
gtk-window-type
gtk-window-type-hint
gtk-window-urgency-hint
gtk-window-window-position
gtk-widget-app-paintable
gtk-widget-can-default
gtk-widget-can-focus
gtk-widget-composite-child
gtk-widget-double-buffered
gtk-widget-events
gtk-widget-expand
gtk-widget-focus-on-click
gtk-widget-halign
gtk-widget-has-default
gtk-widget-has-focus
gtk-widget-has-tooltip
gtk-widget-height-request
gtk-widget-hexpand
gtk-widget-hexpand-set
gtk-widget-is-focus
gtk-widget-margin
gtk-widget-margin-bottom
gtk-widget-margin-end
gtk-widget-margin-left
gtk-widget-margin-right
gtk-widget-margin-start
gtk-widget-margin-top
gtk-widget-name
gtk-widget-no-show-all
gtk-widget-opacity
gtk-widget-parent
gtk-widget-receives-default
gtk-widget-scale-factor
gtk-widget-sensitive
gtk-widget-style
gtk-widget-tooltip-markup
gtk-widget-tooltip-text
gtk-widget-valign
gtk-widget-vexpand
gtk-widget-vexpand-set
gtk-widget-visible
gtk-widget-width-request
gtk-widget-window
g-object-has-reference
g-object-pointer
g-object-signal-handlers

See also

*2021-10-10