GLib.Actionwhich can be used to define the primary actions of your app, assign them keyboard shortcuts, and tie them to
Actionablewidgets in your app like Buttons and Menu Items. In this section, we're going to create a Quit action for your app with an assigned keyboard shortcut and a Button that shows that shortcut in a tooltip.
Gtk.ApplicationWindowas you've done in previous examples. Once you have that set up, let's create a new
Gtk.HeaderBar. Typically your app will have a HeaderBar, at the top of the window, which will contain tool items that users will interact with to trigger your app's actions.
trueso that GTK knows to include window controls. We can then override our Window's built-in titlebar with the
Applicationfrom inside the
<Control>w". Notice that the action name is prefixed with
app; this refers to the
ActionMapbuilt in to
action_nameproperty of our Button:
tooltip_markupproperty of your HeaderBar Button: