[gnome-music/wip/merge: 252/343] Fix duration display on all views



commit a7a1cff0833e353375d88d2fa1a997c7b7847b8b
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Thu Jul 18 12:33:00 2013 +0200

    Fix duration display on all views
    
    Fixes #50

 gnomemusic/player.py |   12 +++++-------
 gnomemusic/view.py   |    6 +++---
 2 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 3d9ea10..bbc0e1b 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -244,7 +244,7 @@ class Player(GObject.GObject):
 
     def load(self, media):
         self._set_duration(media.get_duration())
-        self.songTotalTimeLabel.label = self.seconds_to_string(media.get_duration())
+        self.songTotalTimeLabel.set_label(self.seconds_to_string(media.get_duration()))
         self.progressScale.set_sensitive(True)
 
         self.playBtn.set_sensitive(True)
@@ -423,13 +423,11 @@ class Player(GObject.GObject):
         return False
 
     def seconds_to_string(self, duration):
-        minutes = int(duration / 60) % 60
-        seconds = duration % 60
+        seconds = duration
+        minutes = seconds // 60
+        seconds %= 60
 
-        if seconds < 10:
-            return "%s:0%s" % (minutes, seconds)
-        else:
-            return "%s:%s" % (minutes, seconds)
+        return "%i:%02i" % (minutes, seconds)
 
     def _on_play_btn_clicked(self, btn):
         if self._get_playing():
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index ff10702..41fc92b 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -383,9 +383,9 @@ class Songs(ViewContainer):
     def _on_list_widget_duration_render(self, col, cell, model, itr, data):
         item = model.get_value(itr, 5)
         if item:
-            duration = item.get_duration()
-            minutes = int(duration / 60)
-            seconds = duration % 60
+            seconds = item.get_duration()
+            minutes = seconds // 60
+            seconds %= 60
             cell.set_property("xalign", 1.0)
             cell.set_property("text", "%i:%02i" % (minutes, seconds))
 


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