Add key press handler to main menu
This commit is contained in:
parent
f89623a201
commit
a511dae284
1 changed files with 15 additions and 2 deletions
|
@ -314,6 +314,18 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||
|
||||
return False
|
||||
|
||||
def _on_menu_key_pressed(
|
||||
self,
|
||||
keyval: int,
|
||||
keycode: int,
|
||||
state: Gdk.ModifierType,
|
||||
) -> bool:
|
||||
if keyval == Gdk.keyval_from_name("q"):
|
||||
self.close()
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def _on_key_pressed(
|
||||
self,
|
||||
controller: Gtk.EventControllerKey,
|
||||
|
@ -321,10 +333,11 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||
keycode: int,
|
||||
state: Gdk.ModifierType,
|
||||
) -> bool:
|
||||
# If we're showing video, handle keys differently
|
||||
# Handle keys differently based on which view is active
|
||||
if self.stack.get_visible_child_name() == "overlay":
|
||||
return self._on_video_key_pressed(keyval, keycode, state)
|
||||
return False
|
||||
else:
|
||||
return self._on_menu_key_pressed(keyval, keycode, state)
|
||||
|
||||
def _seek_relative(self, offset: int) -> None:
|
||||
"""Seek relative to current position by offset seconds"""
|
||||
|
|
Loading…
Reference in a new issue