fixed key bindings

This commit is contained in:
Martin Wagner 2020-03-27 18:16:50 +01:00
parent 0969c981fb
commit 67869b3b63

View File

@ -2115,9 +2115,7 @@ class ClientControl(Gtk.ButtonBox):
self.stop_button = Gtk.Button(image=Gtk.Image.new_from_icon_name("media-playback-stop-symbolic", self.icon_size)) self.stop_button = Gtk.Button(image=Gtk.Image.new_from_icon_name("media-playback-stop-symbolic", self.icon_size))
self.stop_button.set_can_focus(False) self.stop_button.set_can_focus(False)
self.prev_button = Gtk.Button(image=Gtk.Image.new_from_icon_name("media-skip-backward-symbolic", self.icon_size)) self.prev_button = Gtk.Button(image=Gtk.Image.new_from_icon_name("media-skip-backward-symbolic", self.icon_size))
self.prev_button.set_can_focus(False)
self.next_button = Gtk.Button(image=Gtk.Image.new_from_icon_name("media-skip-forward-symbolic", self.icon_size)) self.next_button = Gtk.Button(image=Gtk.Image.new_from_icon_name("media-skip-forward-symbolic", self.icon_size))
self.next_button.set_can_focus(False)
#connect #connect
self.play_button.connect("clicked", self.on_play_clicked) self.play_button.connect("clicked", self.on_play_clicked)
@ -2204,7 +2202,6 @@ class SeekBar(Gtk.Box):
#progress bar #progress bar
self.scale=Gtk.Scale.new_with_range(orientation=Gtk.Orientation.HORIZONTAL, min=0, max=100, step=0.001) self.scale=Gtk.Scale.new_with_range(orientation=Gtk.Orientation.HORIZONTAL, min=0, max=100, step=0.001)
self.scale.set_draw_value(False) self.scale.set_draw_value(False)
self.scale.set_can_focus(False)
#event boxes #event boxes
self.elapsed_event_box=Gtk.EventBox() self.elapsed_event_box=Gtk.EventBox()
@ -2233,16 +2230,21 @@ class SeekBar(Gtk.Box):
return True return True
def seek(self, range, scroll, value): #value is inaccurate def seek(self, range, scroll, value): #value is inaccurate
status=self.client.status() if scroll == Gtk.ScrollType.STEP_BACKWARD:
duration=float(status["duration"]) self.seek_backward()
factor=(value/100) elif scroll == Gtk.ScrollType.STEP_FORWARD:
if factor > 1: #fix error on seek self.seek_forward()
factor=1 elif scroll == Gtk.ScrollType.JUMP:
#detach mouse from slider status=self.client.status()
self.scale.set_visible(False) duration=float(status["duration"])
self.scale.set_visible(True) factor=(value/100)
pos=(duration*factor) if factor > 1: #fix error on seek
self.client.seekcur(pos) factor=1
#detach mouse from slider
self.scale.set_visible(False)
self.scale.set_visible(True)
pos=(duration*factor)
self.client.seekcur(pos)
def seek_forward(self): def seek_forward(self):
self.client.seekcur("+"+self.seek_time) self.client.seekcur("+"+self.seek_time)
@ -2919,16 +2921,21 @@ class MainWindow(Gtk.ApplicationWindow):
if event.keyval == 32: #space if event.keyval == 32: #space
self.control.play_button.grab_focus() self.control.play_button.grab_focus()
if event.keyval == 269025044: #AudioPlay if event.keyval == 269025044: #AudioPlay
self.control.play_button.grab_focus()
self.control.play_button.emit("clicked") self.control.play_button.emit("clicked")
elif event.keyval == 269025047 or event.keyval == 43 or event.keyval == 65451: #AudioNext elif event.keyval == 269025047 or event.keyval == 43 or event.keyval == 65451: #AudioNext
self.control.next_button.grab_focus()
self.control.next_button.emit("clicked") self.control.next_button.emit("clicked")
elif event.keyval == 269025046 or event.keyval == 45 or event.keyval == 65453: #AudioPrev elif event.keyval == 269025046 or event.keyval == 45 or event.keyval == 65453: #AudioPrev
self.control.prev_button.grab_focus()
self.control.prev_button.emit("clicked") self.control.prev_button.emit("clicked")
elif event.keyval == 65307: #esc elif event.keyval == 65307: #esc
self.browser.back() self.browser.back()
elif event.keyval == 65450: #* elif event.keyval == 65450: #*
self.progress.scale.grab_focus()
self.progress.seek_forward() self.progress.seek_forward()
elif event.keyval == 65455: #/ elif event.keyval == 65455: #/
self.progress.scale.grab_focus()
self.progress.seek_backward() self.progress.seek_backward()
def on_save(self, action, param): def on_save(self, action, param):