[sushi/wip/cosimoc/no-clutter: 35/36] audio: move function to only caller



commit b65e0bb197e12b38b71ab290d7e077da18dc6703
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Apr 3 12:18:22 2017 -0700

    audio: move function to only caller

 src/js/ui/utils.js      |   17 -----------------
 src/js/viewers/audio.js |   22 +++++++++++++++++++---
 2 files changed, 19 insertions(+), 20 deletions(-)
---
diff --git a/src/js/ui/utils.js b/src/js/ui/utils.js
index 05a4fee..007142a 100644
--- a/src/js/ui/utils.js
+++ b/src/js/ui/utils.js
@@ -97,20 +97,3 @@ function createOpenButton(file, mainWindow) {
         }
     });
 }
-
-function formatTimeString(timeVal) {
-    let hours = Math.floor(timeVal / 3600);
-    timeVal -= hours * 3600;
-
-    let minutes = Math.floor(timeVal / 60);
-    timeVal -= minutes * 60;
-
-    let seconds = Math.floor(timeVal);
-
-    let str = ('%02d:%02d').format(minutes, seconds);
-    if (hours > 0) {
-        str = ('%d').format(hours) + ':' + str;
-    }
-
-    return str;
-}
diff --git a/src/js/viewers/audio.js b/src/js/viewers/audio.js
index d206178..de5e1a5 100644
--- a/src/js/viewers/audio.js
+++ b/src/js/viewers/audio.js
@@ -36,7 +36,23 @@ const Lang = imports.lang;
 const Constants = imports.util.constants;
 const MimeHandler = imports.ui.mimeHandler;
 const TotemMimeTypes = imports.util.totemMimeTypes;
-const Utils = imports.ui.utils;
+
+function _formatTimeString(timeVal) {
+    let hours = Math.floor(timeVal / 3600);
+    timeVal -= hours * 3600;
+
+    let minutes = Math.floor(timeVal / 60);
+    timeVal -= minutes * 60;
+
+    let seconds = Math.floor(timeVal);
+
+    let str = ('%02d:%02d').format(minutes, seconds);
+    if (hours > 0) {
+        str = ('%d').format(hours) + ':' + str;
+    }
+
+    return str;
+}
 
 const AudioRenderer = new Lang.Class({
     Name: 'AudioRenderer',
@@ -207,7 +223,7 @@ const AudioRenderer = new Lang.Class({
         let currentTime =
             Math.floor(this._player.duration * this._player.progress);
 
-        this._currentLabel.set_text(Utils.formatTimeString(currentTime));
+        this._currentLabel.set_text(_formatTimeString(currentTime));
     },
 
     _updateDurationLabel : function() {
@@ -216,7 +232,7 @@ const AudioRenderer = new Lang.Class({
 
         let totalTime = this._player.duration;
 
-        this._durationLabel.set_text(Utils.formatTimeString(totalTime));
+        this._durationLabel.set_text(_formatTimeString(totalTime));
     },
 
     _onPlayerProgressChanged : function() {


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