From e46ec34ed55bdd6692423f609b944341493e3042 Mon Sep 17 00:00:00 2001 From: Martin Wagner Date: Wed, 19 Oct 2022 11:38:52 +0200 Subject: [PATCH] reworked keybindings --- data/ShortcutsWindow.ui | 113 ++++++++++++++++++++++------------------ src/mpdevil.py | 31 +++++------ 2 files changed, 77 insertions(+), 67 deletions(-) diff --git a/data/ShortcutsWindow.ui b/data/ShortcutsWindow.ui index a0ce849..fed37d1 100644 --- a/data/ShortcutsWindow.ui +++ b/data/ShortcutsWindow.ui @@ -51,20 +51,6 @@ True Window - - - True - Cycle through profiles - <Control>p - - - - - True - Cycle through profiles in reversed order - <Shift><Control>p - - True @@ -124,35 +110,35 @@ True Stop after current title - <Control>space + <Shift><Control>s True Next title - KP_Add + <Alt>Down True Previous title - KP_Subtract + <Alt>Up True Seek forward - KP_Multiply + <Alt>Right True Seek backward - KP_Divide + <Alt>Left @@ -166,14 +152,14 @@ True Toggle random mode - <Control>s + <Control>n True Toggle single mode - <Control>1 + <Control>s @@ -185,6 +171,62 @@ + + + True + Playlist + + + True + Remove selected song + Middle-click + Delete + + + + + True + Clear playlist + <Shift>Delete + + + + + True + Show additional information + Right-click + <Control>i Menu + + + + + + + True + Profiles + + + True + Profile 1 + <Control>1 + + + + + True + Profile 2 + <Control>2 + + + + + True + Profile 3 + <Control>3 + + + + True @@ -222,35 +264,6 @@ - - - True - Playlist - - - True - Remove selected song - Middle-click - Delete - - - - - True - Clear playlist - <Shift>Delete - - - - - True - Show additional information - Right-click - <Control>i Menu - - - - diff --git a/src/mpdevil.py b/src/mpdevil.py index d2f75bd..7d98c4c 100755 --- a/src/mpdevil.py +++ b/src/mpdevil.py @@ -3312,13 +3312,16 @@ class MainWindow(Gtk.ApplicationWindow): # actions simple_actions_data=( "settings","profile-settings","stats","help","menu", - "toggle-lyrics","back-to-current-album","toggle-search", - "profile-next","profile-prev","show-info" + "toggle-lyrics","back-to-current-album","toggle-search","show-info" ) for name in simple_actions_data: action=Gio.SimpleAction.new(name, None) action.connect("activate", getattr(self, ("_on_"+name.replace("-","_")))) self.add_action(action) + for i, name in enumerate(("profile-1","profile-2","profile-3")): + action=Gio.SimpleAction.new(name, None) + action.connect("activate", self._on_profile, i) + self.add_action(action) for name in ("append","play","enqueue"): action=Gio.SimpleAction.new(name, None) action.connect("activate", self._on_add_to_playlist, name) @@ -3517,13 +3520,8 @@ class MainWindow(Gtk.ApplicationWindow): def _on_menu(self, action, param): self._menu_button.emit("clicked") - def _on_profile_next(self, action, param): - current_profile=self._settings.get_int("active-profile") - self._settings.set_int("active-profile", ((current_profile+1)%3)) - - def _on_profile_prev(self, action, param): - current_profile=self._settings.get_int("active-profile") - self._settings.set_int("active-profile", ((current_profile-1)%3)) + def _on_profile(self, action, param, profile): + self._settings.set_int("active-profile", profile) def _on_show_info(self, action, param): widget=self.get_focus() @@ -3648,14 +3646,13 @@ class mpdevil(Gtk.Application): action_accels=( ("app.quit", ["q"]),("win.mini-player", ["m"]),("win.help", ["F1"]),("win.menu", ["F10"]), ("win.show-help-overlay", ["question"]),("win.toggle-lyrics", ["l"]), - ("win.back-to-current-album", ["Escape"]),("win.toggle-search", ["f"]), - ("mpd.update", ["F5"]),("mpd.clear", ["Delete"]),("mpd.toggle-play", ["space"]), - ("mpd.stop", ["space"]),("mpd.next", ["KP_Add"]),("mpd.prev", ["KP_Subtract"]), - ("mpd.repeat", ["r"]),("mpd.random", ["s"]),("mpd.single", ["1"]), - ("mpd.consume", ["o"]),("mpd.single-oneshot", ["space"]),("mpd.seek-forward", ["KP_Multiply"]), - ("mpd.seek-backward", ["KP_Divide"]),("win.profile-next", ["p"]),("win.profile-prev", ["p"]), - ("win.show-info", ["i","Menu"]),("win.append", ["plus"]), - ("win.play", ["Return"]),("win.enqueue", ["e"]),("win.genre-filter", ["g"]) + ("win.profile-1", ["1"]),("win.profile-2", ["2"]),("win.profile-3", ["3"]), + ("win.show-info", ["i","Menu"]),("win.append", ["plus"]),("win.play", ["Return"]), + ("win.enqueue", ["e"]),("win.genre-filter", ["g"]),("win.back-to-current-album", ["Escape"]), + ("win.toggle-search", ["f"]),("mpd.update", ["F5"]),("mpd.clear", ["Delete"]),("mpd.toggle-play", ["space"]), + ("mpd.stop", ["space"]),("mpd.next", ["Down"]),("mpd.prev", ["Up"]),("mpd.repeat", ["r"]), + ("mpd.random", ["n"]),("mpd.single", ["s"]),("mpd.consume", ["o"]), + ("mpd.single-oneshot", ["s"]),("mpd.seek-forward", ["Right"]),("mpd.seek-backward", ["Left"]) ) for action, accels in action_accels: self.set_accels_for_action(action, accels)