tracklist: Use the Gtk.ColumnView.scroll_to() function for scrolling
Rather than trying to implement this myself through manually moving the scrolled window. It's much easier to simply let Gtk do the work for us. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
2504f4b91d
commit
70d7f5fa70
|
@ -81,13 +81,9 @@ class TrackView(Gtk.ScrolledWindow):
|
||||||
|
|
||||||
def scroll_to_track(self, track: db.tracks.Track) -> None:
|
def scroll_to_track(self, track: db.tracks.Track) -> None:
|
||||||
"""Scroll to the requested Track."""
|
"""Scroll to the requested Track."""
|
||||||
# This is a workaround until the ColumnView has better scrolling
|
for i in range(self._selection.props.n_items):
|
||||||
# support, which seems to be targeted for Gtk 4.10.
|
if self._selection[i] == track:
|
||||||
adjustment = self._scrollwin.get_vadjustment()
|
self._columnview.scroll_to(i, None, Gtk.ListScrollFlags.NONE)
|
||||||
for (i, t) in enumerate(self._selection):
|
|
||||||
if t == track:
|
|
||||||
pos = max(i - 3, 0) * adjustment.get_upper()
|
|
||||||
adjustment.set_value(pos / self._selection.get_n_items())
|
|
||||||
|
|
||||||
@GObject.Property(type=Gio.ListModel)
|
@GObject.Property(type=Gio.ListModel)
|
||||||
def columns(self) -> Gio.ListModel:
|
def columns(self) -> Gio.ListModel:
|
||||||
|
|
Loading…
Reference in New Issue