[gnome-music] Implement new keyboard shortcuts



commit f8a1b71cdc1f7e725656d532509d7103b1594b13
Author: Evandro Giovanini <efgiovanini gmail com>
Date:   Wed Jul 13 14:09:08 2016 -0300

    Implement new keyboard shortcuts
    
    This patch implements new keyboard shortcuts for playback:
      Ctrl+N: Next Song
      Ctrl+B: Previous Song
      Ctrl+R: Toggle Repeat
      Ctrl+S: Toggle Shuffle
    
    As well as new shortcuts for navigation: Ctrl+[1-4] switches between
    views.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=758637

 gnomemusic/window.py |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index fa5c5f0..a32a7c3 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -36,7 +36,7 @@ from gettext import gettext as _, ngettext
 
 from gnomemusic import TrackerWrapper
 from gnomemusic.toolbar import Toolbar, ToolbarState
-from gnomemusic.player import Player, SelectionToolbar
+from gnomemusic.player import Player, SelectionToolbar, RepeatType
 from gnomemusic.query import Query
 import gnomemusic.view as Views
 import gnomemusic.widgets as Widgets
@@ -395,12 +395,55 @@ class Window(Gtk.ApplicationWindow):
             if (event.keyval == Gdk.KEY_f and
                     event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
                 self.toolbar.searchbar.toggle_bar()
+            # Play / Pause on Ctrl + P
+            if (event.keyval == Gdk.KEY_p
+                    or event.keyval == Gdk.KEY_space
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                 self.player.play_pause()
+            # Play previous on Ctrl + B
+            if (event.keyval == Gdk.KEY_b
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                self.player.play_previous()
+            # Play next on Ctrl + N
+            if (event.keyval == Gdk.KEY_n
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                self.player.play_next()
+            # Toggle repeat on Ctrl + R
+            if (event.keyval == Gdk.KEY_r
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                if self.player.get_repeat_mode() == RepeatType.SONG:
+                    self.player.set_repeat_mode(RepeatType.NONE)
+                else:
+                    self.player.set_repeat_mode(RepeatType.SONG)
+            # Toggle shuffle on Ctrl + S
+            if (event.keyval == Gdk.KEY_s
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                if self.player.get_repeat_mode() == RepeatType.SHUFFLE:
+                    self.player.set_repeat_mode(RepeatType.NONE)
+                else:
+                    self.player.set_repeat_mode(RepeatType.SHUFFLE)
             # Go back from Album view on Alt + Left
             if (event.keyval == Gdk.KEY_Left and
                     event_and_modifiers == Gdk.ModifierType.MOD1_MASK):
                 if (self.toolbar._state != ToolbarState.MAIN):
                     self.curr_view.set_visible_child(self.curr_view._grid)
                     self.toolbar.set_state(ToolbarState.MAIN)
+            # Go to Albums view on Ctrl + 1
+            if (event.keyval == Gdk.KEY_1
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                self._toggle_view(0, 0)
+            # Go to Artists view on Ctrl + 2
+            if (event.keyval == Gdk.KEY_2
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                self._toggle_view(0, 1)
+            # Go to Songs view on Ctrl + 3
+            if (event.keyval == Gdk.KEY_3
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                self._toggle_view(0, 2)
+            # Go to Playlists view on Ctrl + 4
+            if (event.keyval == Gdk.KEY_4
+                    and event_and_modifiers == Gdk.ModifierType.CONTROL_MASK):
+                self._toggle_view(0, 3)
         else:
             if (event.keyval == Gdk.KEY_Delete):
                 if self._stack.get_visible_child() == self.views[3]:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]