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



commit 4354326259b4e3849705619d20d4218d8dd4121f
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. 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 smooths in evenly.

 gnomemusic/widgets/smoothscale.py | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
---
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index 010b5e9f..00c96f20 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -175,14 +175,6 @@ 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
-
-        # Update self._timeout.
         style_context = self.get_style_context()
         state = style_context.get_state()
 
@@ -190,7 +182,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]