fixed error in PlaybackControl._refresh_tooltips()

This commit is contained in:
Martin Wagner 2020-12-19 00:14:55 +01:00
parent 604b17ea3a
commit 5953d73389

View File

@ -3010,12 +3010,16 @@ class PlaybackControl(Gtk.ButtonBox):
self.pack_start(self._next_button, True, True, 0)
def _refresh_tooltips(self, *args):
songs=self._client.wrapped_call("playlistinfo")
song=int(self._client.wrapped_call("status")["song"])
elapsed=ClientHelper.calc_display_length(songs[:song])
rest=ClientHelper.calc_display_length(songs[song+1:])
self._prev_button.set_tooltip_text(_("{titles} titles ({length})").format(titles=song, length=elapsed))
self._next_button.set_tooltip_text(_("{titles} titles ({length})").format(titles=(len(songs)-(song+1)), length=rest))
try:
songs=self._client.wrapped_call("playlistinfo")
song=int(self._client.wrapped_call("status")["song"])
elapsed=ClientHelper.calc_display_length(songs[:song])
rest=ClientHelper.calc_display_length(songs[song+1:])
self._prev_button.set_tooltip_text(_("{titles} titles ({length})").format(titles=song, length=elapsed))
self._next_button.set_tooltip_text(_("{titles} titles ({length})").format(titles=(len(songs)-(song+1)), length=rest))
except:
self._prev_button.set_tooltip_text("")
self._next_button.set_tooltip_text("")
def _on_play_clicked(self, widget):
self._client.wrapped_call("toggle_play")