playlist: Scroll to the current track when tracks change
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
dece303a09
commit
e248fd3658
|
@ -46,6 +46,19 @@ View.append_column(column.Column("Last Played", "lastplayed", width=150))
|
|||
Scroll = Gtk.ScrolledWindow()
|
||||
Scroll.set_child(View)
|
||||
|
||||
def scroll_to_track(track):
|
||||
adj = Scroll.get_vadjustment()
|
||||
for i in range(FilterModel.get_n_items()):
|
||||
if FilterModel.get_item(i) == track:
|
||||
Selection.select_item(i, True)
|
||||
pos = (max(i - 5, 0) / FilterModel.get_n_items())
|
||||
adj.set_value(pos * adj.get_upper())
|
||||
return
|
||||
|
||||
def on_tracks_changed(prev, new):
|
||||
scroll_to_track(new)
|
||||
audio.Player.TrackChanged.register(on_tracks_changed)
|
||||
|
||||
Box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
|
||||
Box.append(Model.Controls)
|
||||
Box.append(Scroll)
|
||||
|
|
Loading…
Reference in New Issue