Add shortcuts action to show keyboard shortcuts dialog
Create app.shortcuts action with Ctrl+? shortcut that loads and displays the shortcuts window from GResources.
This commit is contained in:
parent
7fd77b7ba3
commit
01943ecb1a
@ -37,6 +37,7 @@ class RosterApplication(Adw.Application):
|
|||||||
self.create_action('quit', lambda *_: self.quit(), ['<control>q'])
|
self.create_action('quit', lambda *_: self.quit(), ['<control>q'])
|
||||||
self.create_action('about', self.on_about_action)
|
self.create_action('about', self.on_about_action)
|
||||||
self.create_action('preferences', self.on_preferences_action)
|
self.create_action('preferences', self.on_preferences_action)
|
||||||
|
self.create_action('shortcuts', self.on_shortcuts_action, ['<control>question'])
|
||||||
|
|
||||||
def do_activate(self):
|
def do_activate(self):
|
||||||
"""Called when the application is activated.
|
"""Called when the application is activated.
|
||||||
@ -68,6 +69,13 @@ class RosterApplication(Adw.Application):
|
|||||||
"""Callback for the app.preferences action."""
|
"""Callback for the app.preferences action."""
|
||||||
print('app.preferences action activated')
|
print('app.preferences action activated')
|
||||||
|
|
||||||
|
def on_shortcuts_action(self, widget, _):
|
||||||
|
"""Callback for the app.shortcuts action."""
|
||||||
|
builder = Gtk.Builder.new_from_resource('/cz/vesp/roster/shortcuts-dialog.ui')
|
||||||
|
shortcuts_window = builder.get_object('shortcuts_dialog')
|
||||||
|
shortcuts_window.set_transient_for(self.props.active_window)
|
||||||
|
shortcuts_window.present()
|
||||||
|
|
||||||
def create_action(self, name, callback, shortcuts=None):
|
def create_action(self, name, callback, shortcuts=None):
|
||||||
"""Add an application action.
|
"""Add an application action.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user