reworked keyboard shortcuts

parent 7a8c92f8
Pipeline #231981 failed with stage
in 2 minutes and 1 second
......@@ -39,37 +39,6 @@ class GApplication(Gtk.Application):
def do_startup(self):
Gtk.Application.do_startup(self)
Handy.init()
actions = [
{
'name': 'preferences',
'func': self.show_settings_window,
'accel': '<Primary>comma'
},
{
'name': 'shortcuts',
'func': self.show_shortcuts_window,
'accel': '<Primary>question'
},
{
'name': 'about',
'func': self.show_about_dialog
},
{
'name': 'quit',
'func': self.on_destroy_window,
'accel': '<Primary>q'
}
]
for a in actions:
c_action = Gio.SimpleAction.new(a['name'], None)
c_action.connect('activate', a['func'])
self.add_action(c_action)
if 'accel' in a.keys():
self.set_accels_for_action(
f'app.{a["name"]}',
[a['accel']]
)
def show_about_dialog(self, *args):
about_builder = Gtk.Builder.new_from_resource(
......@@ -116,6 +85,39 @@ class GApplication(Gtk.Application):
self.add_window(self.window)
self.window.present()
self.window.show()
actions = [
{
'name': 'preferences',
'func': self.show_settings_window,
'accel': '<Primary>comma'
},
{
'name': 'shortcuts',
'func': self.show_shortcuts_window,
'accel': '<Primary>question'
},
{
'name': 'about',
'func': self.show_about_dialog
},
{
'name': 'quit',
'func': self.on_destroy_window,
'accel': '<Primary>q'
}
]
for a in actions:
c_action = Gio.SimpleAction.new(a['name'], None)
c_action.connect('activate', a['func'])
self.add_action(c_action)
if 'accel' in a.keys():
self.set_accels_for_action(
f'app.{a["name"]}',
[a['accel']]
)
if self.confman.conf['enable_third_parties'] == 'unset':
disclaimer_dialog = Gtk.MessageDialog(
message_type=Gtk.MessageType.QUESTION,
......
......@@ -40,23 +40,25 @@ class AppWindow(Handy.ApplicationWindow):
self.confman.conf['windowsize']['height']
)
def toggle_menu():
popover = self.headerbar.menu_btn.get_popover()
popover.popup()
# TODO: close popover if open
shortcuts_l = [
{
'combo': 'F10',
'cb': lambda *args: toggle_menu()
'cb': self.toggle_menu
}
]
self.shortcut_controller = Gtk.ShortcutController()
self.shortcut_controller.set_scope(Gtk.ShortcutScope.MANAGED)
self.shortcut_controller.set_scope(Gtk.ShortcutScope.GLOBAL)
for s in shortcuts_l:
self.add_accelerator(s['combo'], s['cb'])
self.add_controller(self.shortcut_controller)
def toggle_menu(self, *args):
popover = self.headerbar.menu_btn.get_popover()
if popover.get_visible():
popover.popdown()
else:
popover.popup()
def on_main_stack_change(self, *args):
self.headerbar.nobox.set_text(
self.main_stack.get_visible_child_name()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment