[gnome-maps/wip/fix-geoloc: 3/8] UserLocation: move accuracy desc here



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

    UserLocation: move accuracy desc here
    
    Move accuracy-description code here since it's not very general anyways.

 src/userLocation.js |   18 ++++++++++++++++--
 src/utils.js        |   11 -----------
 2 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/src/userLocation.js b/src/userLocation.js
index 67aaf99..9cd08c0 100644
--- a/src/userLocation.js
+++ b/src/userLocation.js
@@ -23,6 +23,7 @@
 const Clutter = imports.gi.Clutter;
 const Champlain = imports.gi.Champlain;
 const GObject = imports.gi.GObject;
+const Geocode = imports.gi.GeocodeGlib;
 
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
@@ -56,8 +57,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);
@@ -137,4 +138,17 @@ const UserLocation = new Lang.Class({
             this._accuracyMarker.show();
         }
     },
+
+    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²");
+        }
+    }
 });
diff --git a/src/utils.js b/src/utils.js
index 44f72e4..0699daf 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -90,17 +90,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]