[gnome-music/wip/mschraal/player-factor-out-gstreamer] Move duration calc to smoothscale
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/player-factor-out-gstreamer] Move duration calc to smoothscale
- Date: Sun, 18 Feb 2018 15:54:23 +0000 (UTC)
commit 768471022c801ba8c81fe0c2b09da35149946f8c
Author: Marinus Schraal <mschraal gnome org>
Date: Sun Feb 18 16:31:24 2018 +0100
Move duration calc to smoothscale
gnomemusic/player.py | 5 -----
gnomemusic/widgets/smoothscale.py | 9 +++++++++
2 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 23f7f11..d040897 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -369,7 +369,6 @@ class Player(GObject.GObject):
@log
def load(self, media):
- self._set_duration(media.get_duration())
self._total_time_label.set_label(
utils.seconds_to_string(media.get_duration()))
@@ -679,10 +678,6 @@ class Player(GObject.GObject):
def _on_prev_button_clicked(self, button):
self.play_previous()
- @log
- def _set_duration(self, duration):
- self._progress_scale.set_range(0.0, duration * 60)
-
@log
def _sync_repeat_image(self):
icon = None
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index 0bb1093..ef59461 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -74,6 +74,7 @@ class SmoothScale(Gtk.Scale):
self._player = player
self._player.connect('notify::state', self._on_state_change)
+ self._player.connect('notify::duration', self._on_duration_changed)
@log
def _on_state_change(self, klass, arguments):
@@ -94,6 +95,13 @@ class SmoothScale(Gtk.Scale):
return True
+ @log
+ def _on_duration_changed(self, klass, arguments):
+ duration = self._player.duration
+
+ if duration is not None:
+ self.set_range(0.0, duration * 60)
+
def _on_progress_scale_seek_finish(self, value):
"""Prevent stutters when seeking with infinitesimal amounts"""
self._seek_timeout = None
@@ -142,6 +150,7 @@ class SmoothScale(Gtk.Scale):
return False
def _on_progress_scale_draw(self, cr, data):
+ self._on_duration_changed(None, None)
self._update_timeout()
self.disconnect(self._ps_draw)
return False
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]