rind: Add keyboard shortcuts
The following shortcuts are currently supported: - Backspace: Previous song - Return: Next Song - Space: Toggle play / pause - Ctrl+f: Open search bar - Ctrl+s: Open search bar and focus search entry - Ctrl+r: Toggle random - Ctrl+Up: Increase volume - Ctrl+Down: Decrease volume Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
7ec500bcd7
commit
0c1dcad3f3
12
emmental.ui
12
emmental.ui
|
@ -20,7 +20,7 @@
|
|||
</object>
|
||||
<object class="GtkApplicationWindow" id="window">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="title" translatable="yes">Emmental</property>
|
||||
<property name="default_width">960</property>
|
||||
<property name="default_height">600</property>
|
||||
|
@ -53,6 +53,7 @@
|
|||
<property name="icon_size">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="BackSpace" signal="activate"/>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
|
@ -80,6 +81,7 @@
|
|||
<property name="icon_size">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="space" signal="activate"/>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
|
@ -106,6 +108,7 @@
|
|||
<property name="icon_size">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="space" signal="activate"/>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
|
@ -133,6 +136,7 @@
|
|||
<property name="icon_size">5</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="Return" signal="activate"/>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
</style>
|
||||
|
@ -253,6 +257,7 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="f" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
@ -273,6 +278,7 @@
|
|||
<property name="icon_size">2</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="r" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
@ -312,6 +318,8 @@ audio-volume-medium-symbolic</property>
|
|||
<property name="relief">none</property>
|
||||
</object>
|
||||
</child>
|
||||
<accelerator key="Up" signal="popup" modifiers="GDK_CONTROL_MASK"/>
|
||||
<accelerator key="Down" signal="popup" modifiers="GDK_CONTROL_MASK"/>
|
||||
<style>
|
||||
<class name="default"/>
|
||||
</style>
|
||||
|
@ -417,6 +425,7 @@ audio-volume-medium-symbolic</property>
|
|||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">False</property>
|
||||
<property name="placeholder_text" translatable="yes">Search Playlists</property>
|
||||
<accelerator key="s" signal="grab-focus" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -444,6 +453,7 @@ audio-volume-medium-symbolic</property>
|
|||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="expander_column">treeviewcolumn1</property>
|
||||
<property name="enable_search">False</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
|
|
|
@ -146,3 +146,6 @@ class EmmentalAudio:
|
|||
return GLib.SOURCE_CONTINUE
|
||||
|
||||
Audio = EmmentalAudio()
|
||||
|
||||
for button in [ NextButton, PauseButton, PlayButton, PrevButton ]:
|
||||
button.connect("can-activate-accel", gtk.can_activate_accel)
|
||||
|
|
19
rind/gtk.py
19
rind/gtk.py
|
@ -12,6 +12,7 @@ UpArrow = Builder.get_object("up_arrow")
|
|||
DownArrow = Builder.get_object("down_arrow")
|
||||
PlistSearch = Builder.get_object("playlist_search")
|
||||
PlistSep = Builder.get_object("playlist_separator")
|
||||
Window = Builder.get_object("window")
|
||||
|
||||
class EmmentalApplication(Gtk.Application):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -22,7 +23,7 @@ class EmmentalApplication(Gtk.Application):
|
|||
|
||||
def do_activate(self):
|
||||
if self.window == None:
|
||||
self.window = Builder.get_object("window")
|
||||
self.window = Window
|
||||
self.add_window(self.window)
|
||||
self.window.present()
|
||||
|
||||
|
@ -45,6 +46,21 @@ class EmmentalApplication(Gtk.Application):
|
|||
if self.idle_id == None:
|
||||
self.idle_id = GLib.idle_add(self.on_idle)
|
||||
|
||||
def type_focused(type):
|
||||
return isinstance(Window.get_focus(), type)
|
||||
|
||||
def can_activate_accel(widget, signal):
|
||||
widget.stop_emission_by_name("can-activate-accel")
|
||||
return widget.is_visible() and widget.is_sensitive() and \
|
||||
not type_focused(Gtk.Entry)
|
||||
|
||||
def can_activate_entry(widget, signal):
|
||||
widget.stop_emission_by_name("can-activate-accel")
|
||||
active = not UpDown.get_active()
|
||||
UpDown.set_active(active)
|
||||
if active == True:
|
||||
widget.grab_focus()
|
||||
return active
|
||||
|
||||
def updown_toggled(self, *args):
|
||||
active = UpDown.get_active()
|
||||
|
@ -54,5 +70,6 @@ def updown_toggled(self, *args):
|
|||
PlistSep.set_visible(active)
|
||||
|
||||
UpDown.connect("toggled", updown_toggled)
|
||||
PlistSearch.connect("can-activate-accel", can_activate_entry)
|
||||
|
||||
Application = EmmentalApplication()
|
||||
|
|
|
@ -60,3 +60,10 @@ class TestGtk(unittest.TestCase):
|
|||
self.assertTrue( gtk.DownArrow.is_visible())
|
||||
self.assertFalse(gtk.PlistSearch.is_visible())
|
||||
self.assertFalse(gtk.PlistSep.is_visible())
|
||||
|
||||
def test_accel(self):
|
||||
self.assertFalse(gtk.type_focused(Gtk.Entry))
|
||||
gtk.PlistSearch.grab_focus()
|
||||
self.assertTrue(gtk.type_focused(Gtk.Entry))
|
||||
gtk.Window.grab_focus()
|
||||
self.assertFalse(gtk.type_focused(Gtk.Entry))
|
||||
|
|
Loading…
Reference in New Issue