[gnome-music/wip/jfelder/playback-status-v3: 8/8] linearplaybox: Set_vadjustment



commit 5e182c85fb6d3c895b91ff4056687a9fc8fb8d4f
Author: Jean Felder <jfelder src gnome org>
Date:   Fri Dec 7 00:55:30 2018 +0100

    linearplaybox: Set_vadjustment

 gnomemusic/widgets/playbackpopover.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/gnomemusic/widgets/playbackpopover.py b/gnomemusic/widgets/playbackpopover.py
index ca05b0bd..c41455d7 100644
--- a/gnomemusic/widgets/playbackpopover.py
+++ b/gnomemusic/widgets/playbackpopover.py
@@ -60,6 +60,17 @@ class LinearPlaybackWindow(Gtk.ScrolledWindow):
 
         self._listbox.connect('row-activated', self._on_row_activated)
 
+        self.props.vadjustment.connect(
+            'changed', self._vertical_adjustment_changed)
+
+    @log
+    def _vertical_adjustment_changed(self, klass):
+        v_adjust = self.props.vadjustment
+        if v_adjust.props.upper != self._window_height:
+            self._window_height = v_adjust.props.upper
+            self._row_height = self._window_height / len(self._listbox)
+        v_adjust.props.value = self._current_index * self._row_height + self._row_height / 2 - 
v_adjust.props.page_size / 2
+
     @log
     def _init_listbox_rows(self):
         songs = self._player.get_mpris_playlist()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]