ShortcutsWindow

class ShortcutsWindow(*args, **kwargs)

Superclasses: Window, Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager

A GtkShortcutsWindow shows information about the keyboard shortcuts and gestures of an application.

The shortcuts can be grouped, and you can have multiple sections in this window, corresponding to the major modes of your application.

Additionally, the shortcuts can be filtered by the current view, to avoid showing information that is not relevant in the current application context.

The recommended way to construct a GtkShortcutsWindow is with Builder, by using the <child> tag to populate a GtkShortcutsWindow with one or more ShortcutsSection objects, which contain one or more ShortcutsGroup instances, which, in turn, contain ShortcutsShortcut instances.

If you need to add a section programmatically, use add_section instead of set_child, as the shortcuts window manages its children directly.

A simple example:

https://docs.gtk.org/gtk4/gedit-shortcuts.png

This example has as single section. As you can see, the shortcut groups are arranged in columns, and spread across several pages if there are too many to find on a single page.

The .ui file for this example can be found here.

An example with multiple views:

https://docs.gtk.org/gtk4/clocks-shortcuts.png

This example shows a GtkShortcutsWindow that has been configured to show only the shortcuts relevant to the “stopwatch” view.

The .ui file for this example can be found here.

An example with multiple sections:

https://docs.gtk.org/gtk4/builder-shortcuts.png

This example shows a GtkShortcutsWindow with two sections, “Editor Shortcuts” and “Terminal Shortcuts”.

The .ui file for this example can be found here.

CSS nodes

GtkShortcutsWindow has a single CSS node with the name window and style class .shortcuts.

Methods

class ShortcutsWindow
add_section(section: ShortcutsSection) None

Adds a section to the shortcuts window.

This is the programmatic equivalent to using Builder and a <child> tag to add the child.

Using set_child is not appropriate as the shortcuts window manages its children internally.

Added in version 4.14.

Parameters:

section – the GtkShortcutsSection to add

Properties

class ShortcutsWindow
props.section_name: str

The name of the section to show.

This should be the section-name of one of the GtkShortcutsSection objects that are in this shortcuts window.

props.view_name: str

The view name by which to filter the contents.

This should correspond to the view property of some of the ShortcutsGroup objects that are inside this shortcuts window.

Set this to None to show all groups.

Signals

class ShortcutsWindow.signals
close() None

Emitted when the user uses a keybinding to close the window.

This is a keybinding signal.

The default binding for this signal is the Escape key.

search() None

Emitted when the user uses a keybinding to start a search.

This is a keybinding signal.

The default binding for this signal is Control-F.