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
|
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(
|
def _on_key_pressed(
|
||||||
self,
|
self,
|
||||||
controller: Gtk.EventControllerKey,
|
controller: Gtk.EventControllerKey,
|
||||||
|
@ -321,10 +333,11 @@ class MainWindow(Gtk.ApplicationWindow):
|
||||||
keycode: int,
|
keycode: int,
|
||||||
state: Gdk.ModifierType,
|
state: Gdk.ModifierType,
|
||||||
) -> bool:
|
) -> 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":
|
if self.stack.get_visible_child_name() == "overlay":
|
||||||
return self._on_video_key_pressed(keyval, keycode, state)
|
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:
|
def _seek_relative(self, offset: int) -> None:
|
||||||
"""Seek relative to current position by offset seconds"""
|
"""Seek relative to current position by offset seconds"""
|
||||||
|
|
Loading…
Reference in a new issue