[gnome-maps] MapLocation: move accuracy desc here



commit 6895ecc241f284550b36702ee121d4701fa7313f
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Wed Jul 10 18:25:15 2013 +0200

    MapLocation: move accuracy desc here
    
    Move accuracy-description code here since it's not very general anyways.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704537

 src/mapLocation.js  |   13 +++++++++++++
 src/userLocation.js |    4 ++--
 src/utils.js        |   11 -----------
 3 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/src/mapLocation.js b/src/mapLocation.js
index 1312984..6a460bc 100644
--- a/src/mapLocation.js
+++ b/src/mapLocation.js
@@ -108,6 +108,19 @@ const MapLocation = new Lang.Class({
         this._view.set_zoom_level(zoom);
     },
 
+    getAccuracyDescription: function() {
+        switch(this.accuracy) {
+        case Geocode.LOCATION_ACCURACY_UNKNOWN:
+            return "Unknown";
+        case 0:
+            return "Exact";
+        default:
+            let area =  Math.PI * Math.pow(this.accuracy / 1000, 2);
+            area = Math.floor(area);
+            return area.toString() + _(" km²");
+        }
+    },
+
     _getCurrentLocation: function() {
         return new Geocode.Location({
             latitude: this._view.get_center_latitude(),
diff --git a/src/userLocation.js b/src/userLocation.js
index fe20278..cca8e86 100644
--- a/src/userLocation.js
+++ b/src/userLocation.js
@@ -55,8 +55,8 @@ const UserLocation = new Lang.Class({
             return;
         bubbleActor.set_x_expand(true);
         bubbleActor.set_y_expand(true);
-        let text = _("%s\nPosition Accuracy: %s").format (this.description,
-                                                          Utils.getDescriptionForAccuracy(this.accuracy));
+        let text = _("%s\nPosition Accuracy: %s")
+                .format (this.description, this.getAccuracyDescription());
         let textActor = new Clutter.Text({ text: text });
         textActor.set_margin_left(6);
         textActor.set_margin_right(6);
diff --git a/src/utils.js b/src/utils.js
index f125702..60c4d3f 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -80,17 +80,6 @@ function initActions(actionMap, simpleActionEntries, context) {
 }
 
 
-function getDescriptionForAccuracy(accuracy) {
-    if (accuracy == Geocode.LOCATION_ACCURACY_UNKNOWN)
-        return "Unknown";
-    else if (accuracy == 0)
-        return "Exact";
-    else {
-        let area =  Math.PI * Math.pow(accuracy / 1000, 2);
-        area = Math.floor(area);
-        return area.toString() + _(" km²");
-    }
-}
 
 function CreateActorFromImageFile(path) {
     try {


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