[gnome-music/wip/mschraal/gst-handle-async-done] smoothscale: Always set a timeout on update



commit 55837cda4105e17e638de8fb909c15017556e026
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon Apr 15 09:15:48 2019 +0200

    smoothscale: Always set a timeout on update
    
    Async latency could cause the SmoothScale timeout be calculated when the
    widget had not yet been realized, as it is based on the widgets realized
    size. This could result in no timeout being set and SmoothScale not being
    updated for the first song of the playlist on a fresh startup.
    Always trigger a timeout being added even when the widget has not yet been
    realized, so SmoothScale starts working as soon as the widget is realized.
    Set a small minimal timeout, so the updates smooth in evenly.

 gnomemusic/widgets/smoothscale.py | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index 010b5e9f..c17b315d 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -175,14 +175,8 @@ class SmoothScale(Gtk.Scale):
         the slider SmoothScale move smoothly based on the current song
         duration and scale length.
         """
-        # Do not run until SmoothScale has been realized and GStreamer
-        # provides a duration.
-        duration = self._player.props.duration
-        if (self.get_realized() is False
-                or duration == -1.):
-            return
+        duration = abs(self._player.props.duration)
 
-        # Update self._timeout.
         style_context = self.get_style_context()
         state = style_context.get_state()
 
@@ -190,7 +184,7 @@ class SmoothScale(Gtk.Scale):
         padding = style_context.get_padding(state)
         width = max(width - (padding.left + padding.right), 1)
 
-        timeout_period = min(1000 * duration // width, 1000)
+        timeout_period = min(1000 * duration // width, 200)
 
         if self._timeout:
             GLib.source_remove(self._timeout)


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