Skip to content

Commit

Permalink
Cleanup keyword arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Sep 22, 2024
1 parent dbff4da commit 11d444a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
10 changes: 5 additions & 5 deletions cozy/ui/main_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ def __init_actions(self):
"""
Init all app actions.
"""
self.create_action("about", self.show_about_window, ["F1"])
self.create_action("about", self.show_about_window, ["F1"], global_shorcut=True)
self.create_action("reset_book", self.reset_book)
self.create_action("remove_book", self.remove_book)

self.create_action("mark_book_as_read", self.mark_book_as_read)
self.create_action("jump_to_book_folder", self.jump_to_book_folder)

self.create_action("prefs", self.show_preferences_window, ["<primary>comma"])
self.create_action("quit", self.quit, ["<primary>q", "<primary>w"])
self.create_action("prefs", self.show_preferences_window, ["<primary>comma"], global_shorcut=True)
self.create_action("quit", self.quit, ["<primary>q", "<primary>w"], global_shorcut=True)

self.scan_action = self.create_action("scan", self.scan)

Expand Down Expand Up @@ -136,7 +136,7 @@ def create_action(
callback: Callable[[Gio.SimpleAction, None], None],
shortcuts: list[str] | None = None,
*,
only_main_view: bool = False,
global_shorcut: bool = False,
) -> Gio.SimpleAction:
action = Gio.SimpleAction.new(name, None)
action.connect("activate", callback)
Expand All @@ -145,7 +145,7 @@ def create_action(
if shortcuts:
self.app.set_accels_for_action(f"app.{name}", shortcuts)

if only_main_view:
if not global_shorcut:
self._actions_to_disable.append(action)

return action
Expand Down
32 changes: 10 additions & 22 deletions cozy/ui/media_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,19 @@ def _set_cover_image(self, book: Book):

@inject.param("main_window", "MainWindow")
def _setup_shortcuts(self, main_window):
main_window.create_action("play_pause", self._play_clicked, ["space"], only_main_view=True)
main_window.create_action(
"seek_rewind", self._rewind_clicked, ["Left"], only_main_view=True
)
main_window.create_action(
"seek_forward", self._forward_clicked, ["Right"], only_main_view=True
)
main_window.create_action("play_pause", self._play_clicked, ["space"])
main_window.create_action("seek_rewind", self._rewind_clicked, ["Left"])
main_window.create_action("seek_forward", self._forward_clicked, ["Right"])

main_window.create_action("volume_up", self._volume_up, ["Up"], only_main_view=True)
main_window.create_action("volume_down", self._volume_down, ["Down"], only_main_view=True)
main_window.create_action("volume_up", self._volume_up, ["Up"])
main_window.create_action("volume_down", self._volume_down, ["Down"])

main_window.create_action(
"speed_up", self._speed_up, ["plus", "KP_Add", "<primary>Up"], only_main_view=True
)
main_window.create_action(
"speed_down", self._speed_down, ["minus", "KP_Subtract", "<primary>Down"], only_main_view=True
)
main_window.create_action("speed_reset", self._speed_reset, ["equal"], only_main_view=True)
main_window.create_action("speed_up", self._speed_up, ["plus", "KP_Add", "<primary>Up"])
main_window.create_action("speed_down", self._speed_down, ["minus", "KP_Subtract", "<primary>Down"])
main_window.create_action("speed_reset", self._speed_reset, ["equal"])

main_window.create_action(
"prev_chapter", self._prev_chapter, ["Page_Down", "<primary>Left"], only_main_view=True
)
main_window.create_action(
"next_chapter", self._next_chapter, ["Page_Up", "<primary>Right"], only_main_view=True
)
main_window.create_action("prev_chapter", self._prev_chapter, ["Page_Down", "<primary>Left"])
main_window.create_action("next_chapter", self._next_chapter, ["Page_Up", "<primary>Right"])

def _on_book_changed(self) -> None:
book = self._playback_control_view_model.book
Expand Down

0 comments on commit 11d444a

Please sign in to comment.