[gnome-maps/wip/fix-geoloc: 5/11] UserLocation: move accuracy desc here
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/fix-geoloc: 5/11] UserLocation: move accuracy desc here
- Date: Fri, 19 Jul 2013 10:07:36 +0000 (UTC)
commit 13fa3fdd8851abca8c94aa05140b90f3b0f5b9fe
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 8673d4f..bce1722 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 817ef39..23005fa 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -87,17 +87,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]