[gnome-maps/wip/code-format] Fix style issues



commit e458d49ffad2a66e072f7187df392dc163607d2c
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Tue Dec 2 10:46:20 2014 +0100

    Fix style issues
    
    Add a jscs config[1] that corresponds to our code style and fix all
    errors.
    
    1: https://github.com/jscs-dev/node-jscs

 .jscsrc                    |   68 ++++++++++++++++++++++++++++++++++++
 src/application.js         |   12 ++++---
 src/contextMenu.js         |    2 +-
 src/epaf.js                |    6 ++--
 src/favoritesPopover.js    |    3 +-
 src/geoclue.js             |   30 +++++++++------
 src/geocodeService.js      |    2 +-
 src/http.js                |   12 +++---
 src/mainWindow.js          |   50 +++++++++++++++-----------
 src/mapBubble.js           |    3 +-
 src/mapMarker.js           |   50 ++++++++++++++++----------
 src/mapView.js             |   83 +++++++++++++++++++++++++------------------
 src/mapWalker.js           |   52 +++++++++++++++------------
 src/notification.js        |    8 ++--
 src/notificationManager.js |    6 ++--
 src/overpass.js            |    9 +++--
 src/place.js               |   32 ++++++++--------
 src/placeEntry.js          |   17 ++++-----
 src/placeStore.js          |    2 +-
 src/route.js               |   25 +++++++------
 src/routeQuery.js          |   10 +++--
 src/routeService.js        |   30 +++++++++------
 src/searchPopup.js         |   24 +++++++------
 src/searchResultBubble.js  |    5 ++-
 src/searchResultMarker.js  |   10 +++--
 src/settings.js            |    2 +-
 src/sidebar.js             |   19 ++++++----
 src/turnPointMarker.js     |   11 +++---
 src/userLocationBubble.js  |   13 ++++---
 src/userLocationMarker.js  |   18 +++++++---
 src/utils.js               |   51 ++++++++++++++-------------
 src/zoomControl.js         |    4 +-
 32 files changed, 410 insertions(+), 259 deletions(-)
---
diff --git a/.jscsrc b/.jscsrc
new file mode 100644
index 0000000..9822e72
--- /dev/null
+++ b/.jscsrc
@@ -0,0 +1,68 @@
+{
+    "esnext": true,
+
+    "requireCurlyBraces": [
+        "try",
+        "catch"
+    ],
+    "requireSpaceBeforeKeywords": [
+        "else",
+        "while",
+        "catch"
+    ],
+    "requireSpaceAfterKeywords": [
+        "do",
+        "for",
+        "if",
+        "else",
+        "switch",
+        "case",
+        "try",
+        "catch",
+        "void",
+        "while",
+        "with",
+        "return"
+    ],
+    "requireSpaceBeforeBlockStatements": true,
+    "requireParenthesesAroundIIFE": true,
+    "requireSpacesInConditionalExpression": true,
+    "requireSpacesInFunction": {
+        "beforeOpeningCurlyBrace": true
+    },    
+    "disallowSpacesInFunction": {
+        "beforeOpeningRoundBrace": true
+    },
+    "disallowSpacesInCallExpression": true,
+    "disallowMultipleVarDecl": "exceptUndefined",
+    "requireBlocksOnNewline": true,
+    "disallowSpacesInsideParentheses": true,
+    "requireSpacesInsideObjectBrackets": "all",
+    "disallowSpaceAfterObjectKeys": true,
+    "requireSpaceBeforeObjectValues": true,
+    "requireCommaBeforeLineBreak": true,
+    "disallowSpaceAfterPrefixUnaryOperators": true,
+    "disallowSpaceBeforePostfixUnaryOperators": true,
+    "disallowSpaceBeforeBinaryOperators": [
+        ","
+    ],
+    "requireSpaceAfterBinaryOperators": true,
+    "disallowMultipleLineBreaks": true,
+    "disallowMixedSpacesAndTabs": true,
+    "disallowOperatorBeforeLineBreak": ["."],
+    "disallowTrailingWhitespace": true,
+    "disallowTrailingComma": true,
+    "disallowKeywordsOnNewLine": ["catch"],
+    "maximumLineLength": {
+        "value": 80,
+        "allowUrlComments": true
+    },
+    "requireCapitalizedConstructors": true,
+    "disallowYodaConditions": true,
+    "requireSpaceAfterLineComment": true,
+    "disallowNewlineBeforeBlockStatements": true,
+    "validateLineBreaks": "LF",
+    "validateIndentation": 4,
+    "validateParameterSeparator": ", ",
+    "requireCapitalizedComments": true
+}
diff --git a/src/application.js b/src/application.js
index 9315d30..49d6d5e 100644
--- a/src/application.js
+++ b/src/application.js
@@ -86,11 +86,11 @@ const Application = new Lang.Class({
         let addr = new Gio.NetworkAddress({ hostname: 'tile.openstreetmap.org',
                                             port: 80 });
 
-        networkMonitor.can_reach_async(addr, null, (function(networkMonitor, res) {
+        networkMonitor.can_reach_async(addr, null, (function(monitor, res) {
             try {
                 if (networkMonitor.can_reach_finish(res))
                     this.connected = true;
-            } catch(e) {
+            } catch (e) {
                 this.connected = false;
                 Utils.debug('Connection failed: ' + e.message);
             }
@@ -125,7 +125,7 @@ const Application = new Lang.Class({
 
         GtkClutter.init(null);
 
-        Utils.loadStyleSheet(Gio.file_new_for_uri('resource:///org/gnome/maps/application.css'));
+        Utils.loadStyleSheet('resource:///org/gnome/maps/application.css');
 
         application = this;
         this._initServices();
@@ -154,9 +154,11 @@ const Application = new Lang.Class({
 
         Gtk.IconTheme.get_default().append_search_path(Path.ICONS_DIR);
         let overlay = new Gtk.Overlay({ visible: true, can_focus: false });
-        notificationManager = new NotificationManager.NotificationManager(overlay);
+        notificationManager =
+            new NotificationManager.NotificationManager(overlay);
         this._mainWindow = new MainWindow.MainWindow(this, overlay);
-        this._mainWindow.window.connect('destroy', this._onWindowDestroy.bind(this));
+        this._mainWindow.window.connect('destroy',
+                                        this._onWindowDestroy.bind(this));
     },
 
     vfunc_dbus_register: function(connection, path) {
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 6f01cb1..e5dd2b5 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -63,5 +63,5 @@ const ContextMenu = new Lang.Class({
         Application.geocodeService.reverse(location, (function(place) {
             this._mapView.showSearchResult(place);
         }).bind(this));
-    },
+    }
 });
diff --git a/src/epaf.js b/src/epaf.js
index f96866d..ffc10b2 100644
--- a/src/epaf.js
+++ b/src/epaf.js
@@ -22,7 +22,7 @@
  */
 
 // Google encoded polyline decoder
-// https://developers.google.com/maps/documentation/utilities/polylinealgorithm
+// (https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
 
 const Champlain = imports.gi.Champlain;
 
@@ -41,7 +41,7 @@ function _decodeValue(data, index) {
         shift += 5;
     } while (b >= 0x20);
 
-    // negative values are encoded as two's complement
+    // Negative values are encoded as two's complement
     let ret_val = ((value & 1) ? ~(value >> 1) : (value >> 1));
     return [ret_val, index];
 }
@@ -59,7 +59,7 @@ function decode(data) {
         [latdelta, index] = _decodeValue(data, index);
         [londelta, index] = _decodeValue(data, index);
 
-        // first value is absolute, rest are relative to previous value
+        // First value is absolute, rest are relative to previous value
         lat += latdelta;
         lon += londelta;
         polyline.push(new Champlain.Coordinate({
diff --git a/src/favoritesPopover.js b/src/favoritesPopover.js
index bbfd201..18c4603 100644
--- a/src/favoritesPopover.js
+++ b/src/favoritesPopover.js
@@ -75,7 +75,8 @@ const FavoritesPopover = new Lang.Class({
             let visible = Math.min(this._rows, _N_VISIBLE);
 
             // + 6 Makes it pixel perfect
-            this._scrolledWindow.min_content_height = visible * (PlaceListRow.ROW_HEIGHT + 6);
+            this._scrolledWindow.min_content_height
+                = visible * (PlaceListRow.ROW_HEIGHT + 6);
             this._revealer.reveal_child = this._rows > _N_VISIBLE;
         }).bind(this));
 
diff --git a/src/geoclue.js b/src/geoclue.js
index e224923..cb27e3c 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -104,19 +104,22 @@ const Geoclue = new Lang.Class({
         this.place = null;
 
         try {
-            this._managerProxy = new ManagerProxy(Gio.DBus.system,
-                                                  "org.freedesktop.GeoClue2",
-                                                  "/org/freedesktop/GeoClue2/Manager");
-            this._managerProxy.GetClientRemote(this._onGetClientReady.bind(this));
+            this._managerProxy
+                = new ManagerProxy(Gio.DBus.system,
+                                   "org.freedesktop.GeoClue2",
+                                   "/org/freedesktop/GeoClue2/Manager");
+            this._managerProxy
+                .GetClientRemote(this._onGetClientReady.bind(this));
         } catch (e) {
             Utils.debug("Failed to connect to GeoClue2 service: " + e.message);
-            log('Connection with GeoClue failed, we are not able to find your location!');
+            log('Connection with GeoClue failed, '
+                + 'we are not able to find your location!');
         }
     },
 
     _onGetClientReady: function(result, e) {
         if (e) {
-            log ("Failed to connect to GeoClue2 service: " + e.message);
+            log("Failed to connect to GeoClue2 service: " + e.message);
             return;
         }
 
@@ -132,19 +135,22 @@ const Geoclue = new Lang.Class({
                                         this._onLocationUpdated.bind(this));
         this._clientProxy.StartRemote((function(result, e) {
             if (e) {
-                log ("Failed to connect to GeoClue2 service: " + e.message);
+                log("Failed to connect to GeoClue2 service: " + e.message);
             }
         }).bind(this));
     },
 
     _onLocationUpdated: function(proxy, sender, [oldPath, newPath]) {
-        let geoclueLocation = new LocationProxy(Gio.DBus.system,
+        let { Latitude,
+              Longitude,
+              Accuracy,
+              Description } = new LocationProxy(Gio.DBus.system,
                                                 "org.freedesktop.GeoClue2",
                                                 newPath);
-        let location = new Geocode.Location({ latitude: geoclueLocation.Latitude,
-                                              longitude: geoclueLocation.Longitude,
-                                              accuracy: geoclueLocation.Accuracy,
-                                              description: geoclueLocation.Description });
+        let location = new Geocode.Location({ latitude: Latitude,
+                                              longitude: Longitude,
+                                              accuracy: Accuracy,
+                                              description: Description });
 
         this._updateLocation(location);
 
diff --git a/src/geocodeService.js b/src/geocodeService.js
index e5e1df1..f628dce 100644
--- a/src/geocodeService.js
+++ b/src/geocodeService.js
@@ -60,7 +60,7 @@ const GeocodeService = new Lang.Class({
         let reverse = Geocode.Reverse.new_for_location(location);
 
         Application.application.mark_busy();
-        reverse.resolve_async (null, (function(reverse, res) {
+        reverse.resolve_async(null, (function(reverse, res) {
             Application.application.unmark_busy();
             try {
                 let place = reverse.resolve_finish(res);
diff --git a/src/http.js b/src/http.js
index acd2529..fb12bf7 100644
--- a/src/http.js
+++ b/src/http.js
@@ -24,7 +24,7 @@ const Lang = imports.lang;
 const Soup = imports.gi.Soup;
 
 function encode(data) {
-    if(data === null)
+    if (data === null)
         return null;
 
     return Soup.URI.encode(data.toString(), null);
@@ -35,7 +35,7 @@ const Query = new Lang.Class({
 
     _init: function(obj) {
         this._query = {};
-        for(let key in obj) {
+        for (let key in obj) {
             this.add(key, obj[key]);
         }
     },
@@ -43,10 +43,10 @@ const Query = new Lang.Class({
     // a value === null represents an empty value
     add: function(key, value) {
         // Initialize query field if it isn't already
-        if(!Array.isArray(this._query[key]))
+        if (!Array.isArray(this._query[key]))
             this._query[key] = [];
 
-        if(Array.isArray(value))
+        if (Array.isArray(value))
             this._query[key] = this._query[key].concat(value);
         else
             this._query[key].push(value);
@@ -54,12 +54,12 @@ const Query = new Lang.Class({
 
     toString: function() {
         let vars = [];
-        for(let key in this._query) {
+        for (let key in this._query) {
             let values = this._query[key];
             let encKey = encode(key);
             values.forEach(function(value) {
                 let encValue = encode(value);
-                if(encValue !== null)
+                if (encValue !== null)
                     vars.push([encKey, encValue].join('='));
                 else
                     vars.push(encKey);
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d09ffe0..1181d49 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -74,7 +74,8 @@ const MainWindow = new Lang.Class({
         this._contextMenu = new ContextMenu.ContextMenu(this.mapView);
 
         ui.layersButton.popover = new LayersPopover.LayersPopover();
-        ui.favoritesButton.popover = new FavoritesPopover.FavoritesPopover({ mapView: this.mapView });
+        ui.favoritesButton.popover
+            = new FavoritesPopover.FavoritesPopover({ mapView: this.mapView });
         this._overlay.add_overlay(new ZoomControl.ZoomControl(this.mapView));
 
         this._mainStack = ui.mainStack;
@@ -97,13 +98,14 @@ const MainWindow = new Lang.Class({
     },
 
     _createPlaceEntry: function() {
-        let placeEntry = new PlaceEntry.PlaceEntry({ mapView:       this.mapView,
-                                                     visible:       true,
-                                                     margin_start:  6,
-                                                     margin_end:    6,
-                                                     width_request: 500,
-                                                     loupe:         true
-                                                   });
+        let placeEntry =
+                new PlaceEntry.PlaceEntry({ mapView:       this.mapView,
+                                            visible:       true,
+                                            margin_start:  6,
+                                            margin_end:    6,
+                                            width_request: 500,
+                                            loupe:         true
+                                          });
         placeEntry.connect('notify::place', (function() {
             if (placeEntry.place) {
                 this.mapView.showSearchResult(placeEntry.place);
@@ -119,9 +121,10 @@ const MainWindow = new Lang.Class({
     },
 
     _createSidebar: function() {
+        let query = Application.routeService.query;
         let sidebar = new Sidebar.Sidebar(this.mapView);
-        Application.routeService.query.connect('notify',
-                                               this._setRevealSidebar.bind(this, true));
+        query.connect('notify',
+                      this._setRevealSidebar.bind(this, true));
         sidebar.bind_property('reveal-child',
                               this.mapView, 'routeVisible',
                               GObject.BindingFlags.DEFAULT);
@@ -181,7 +184,7 @@ const MainWindow = new Lang.Class({
                                   this.mapView.grab_focus.bind(this.mapView));
 
         this.window.application.connect('notify::connected', (function() {
-            if(this.window.application.connected)
+            if (this.window.application.connected)
                 this._mainStack.visible_child = this._overlay;
             else
                 this._mainStack.visible_child = this._noNetworkView;
@@ -200,14 +203,15 @@ const MainWindow = new Lang.Class({
         }).bind(this));
 
         Application.geoclue.connect('notify::connected', (function() {
-            this._gotoUserLocationButton.sensitive = Application.geoclue.connected;
+            this._gotoUserLocationButton.sensitive =
+                Application.geoclue.connected;
         }).bind(this));
 
         this.window.application.connect('notify::connected', (function() {
             let app = this.window.application;
 
-            this._gotoUserLocationButton.sensitive = (app.connected &&
-                                                      Application.geoclue.connected);
+            this._gotoUserLocationButton.sensitive =
+                (app.connected && Application.geoclue.connected);
             this._layersButton.sensitive = app.connected;
             this._toggleSidebarButton.sensitive = app.connected;
             this._favoritesButton.sensitive = (app.connected &&
@@ -255,11 +259,15 @@ const MainWindow = new Lang.Class({
             this._configureId = 0;
         }
 
-        this._configureId = Mainloop.timeout_add(_CONFIGURE_ID_TIMEOUT, (function() {
-            this._saveWindowGeometry();
-            this._configureId = 0;
-            return false;
-        }).bind(this));
+        this._configureId =
+            Mainloop.timeout_add(_CONFIGURE_ID_TIMEOUT,
+                                 this._onConfigureIdTimeout.bind(this));
+    },
+
+    _onConfigureIdTimeout: function() {
+        this._saveWindowGeometry();
+        this._configureId = 0;
+        return false;
     },
 
     _onWindowStateEvent: function(widget, event) {
@@ -325,8 +333,8 @@ const MainWindow = new Lang.Class({
             program_name: _("Maps"),
             comments: _("A map application for GNOME"),
             copyright: 'Copyright ' + String.fromCharCode(0x00A9) +
-                       ' 2011' + String.fromCharCode(0x2013) +
-                       '2013 Red Hat, Inc.',
+                ' 2011' + String.fromCharCode(0x2013) +
+                '2013 Red Hat, Inc.',
             license_type: Gtk.License.GPL_2_0,
             logo_icon_name: 'gnome-maps',
             version: Config.PACKAGE_VERSION,
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 20b8183..2d832ee 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -116,7 +116,8 @@ const MapBubble = new Lang.Class({
     },
 
     _initShareButton: function(button) {
-        let dialog = new ShareDialog.ShareDialog({ transient_for: this.get_toplevel(),
+        let toplevel = this.get_toplevel();
+        let dialog = new ShareDialog.ShareDialog({ transient_for: toplevel,
                                                    place: this._place });
         if (!dialog.ensureShares())
             return;
diff --git a/src/mapMarker.js b/src/mapMarker.js
index 96185d5..458b124 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -122,7 +122,8 @@ const MapMarker = new Lang.Class({
             bubble.position = Gtk.PositionType.LEFT;
         else if (pos.x + pos.width / 2 - bubbleSize.width / 2 <= 0)
             bubble.position = Gtk.PositionType.RIGHT;
-        // Avoid bubble to cover header bar if the marker is close to the top map edge
+        // Avoid bubble to cover header bar if the marker is close to the top
+        // map edge
         else if (pos.y - bubbleSize.height <= 0)
             bubble.position = Gtk.PositionType.BOTTOM;
     },
@@ -168,26 +169,30 @@ const MapMarker = new Lang.Class({
         this._hideBubbleOn('notify::size');
 
         // This is done to get just one marker selected at any time regardless
-        // of the layer to which it belongs so we can get only one visible bubble
-        // at any time. We do this for markers in different layers because for
-        // markers in the same layer, ChamplainMarkerLayer single selection mode
-        // does the job.
+        // of the layer to which it belongs so we can get only one visible
+        // bubble at any time. We do this for markers in different layers
+        // because for markers in the same layer, ChamplainMarkerLayer single
+        // selection mode does the job.
         this._mapView.onSetMarkerSelected(this);
 
-        let markerSelectedSignalId = this._mapView.connect('marker-selected', (function(mapView, 
selectedMarker) {
-            if (this.get_parent() !== selectedMarker.get_parent())
-                this.selected = false;
-        }).bind(this));
-
-        let goingToSignalId = this._mapView.connect('going-to',
-                                                    this.set_selected.bind(this, false));
-        let buttonPressSignalId = this._view.connect('button-press-event',
-                                                     this.set_selected.bind(this, false));
-        // Destroy the bubble when the marker is destroyed o removed from a layer
-        let parentSetSignalId = this.connect('parent-set',
-                                             this.set_selected.bind(this, false));
-        let dragMotionSignalId = this.connect('drag-motion',
-                                              this.set_selected.bind(this, false));
+        let markerSelectedSignalId =
+                this._mapView.connect('marker-selected',
+                                      this._onMapMarkerSelected.bind(this));
+
+        let goingToSignalId =
+                this._mapView.connect('going-to',
+                                      this.set_selected.bind(this, false));
+        let buttonPressSignalId =
+                this._view.connect('button-press-event',
+                                   this.set_selected.bind(this, false));
+        // Destroy the bubble when the marker is destroyed or removed from a
+        // layer
+        let parentSetSignalId =
+                this.connect('parent-set',
+                             this.set_selected.bind(this, false));
+        let dragMotionSignalId =
+                this.connect('drag-motion',
+                             this.set_selected.bind(this, false));
 
         Utils.once(this.bubble, 'closed', (function() {
             this._mapView.disconnect(markerSelectedSignalId);
@@ -201,6 +206,11 @@ const MapMarker = new Lang.Class({
         }).bind(this));
     },
 
+    _onMapMarkerSelected: function(mapView, selectedMarker) {
+        if (this.get_parent() !== selectedMarker.get_parent())
+            this.selected = false;
+    },
+
     _isInsideView: function() {
         let [tx, ty, tz] = this.get_translation();
         let x = this._view.longitude_to_x(this.longitude);
@@ -208,7 +218,7 @@ const MapMarker = new Lang.Class({
         let mapSize = this._mapView.get_allocation();
 
         return x + tx + this.width > 0 && x + tx < mapSize.width &&
-               y + ty + this.height > 0 && y + ty < mapSize.height;
+            y + ty + this.height > 0 && y + ty < mapSize.height;
     },
 
     showBubble: function() {
diff --git a/src/mapView.js b/src/mapView.js
index dd3e0a6..78afc62 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -93,7 +93,7 @@ const MapView = new Lang.Class({
 
         view.connect('notify::latitude', this._onViewMoved.bind(this));
         view.connect('notify::longitude', this._onViewMoved.bind(this));
-        // switching map type will set view min-zoom-level from map source
+        // Switching map type will set view min-zoom-level from map source
         view.connect('notify::min-zoom-level', (function() {
             if (view.min_zoom_level < MapMinZoom) {
                 view.min_zoom_level = MapMinZoom;
@@ -103,22 +103,25 @@ const MapView = new Lang.Class({
     },
 
     _initLayers: function() {
-        let strokeColor = new Clutter.Color({ red: 0,
-                                               blue: 255,
-                                               green: 0,
-                                               alpha: 100 });
+        let color = new Clutter.Color({ red: 0,
+                                        blue: 255,
+                                        green: 0,
+                                        alpha: 100 });
         this._routeLayer = new Champlain.PathLayer({ stroke_width: 5.0,
-                                                     stroke_color: strokeColor });
+                                                     stroke_color: color });
         this.view.add_layer(this._routeLayer);
 
         let mode = Champlain.SelectionMode.SINGLE;
-        this._searchResultLayer = new Champlain.MarkerLayer({ selection_mode: mode });
+        this._searchResultLayer =
+            new Champlain.MarkerLayer({ selection_mode: mode });
         this.view.add_layer(this._searchResultLayer);
 
-        this._instructionMarkerLayer = new Champlain.MarkerLayer({ selection_mode: mode });
+        this._instructionMarkerLayer =
+            new Champlain.MarkerLayer({ selection_mode: mode });
         this.view.add_layer(this._instructionMarkerLayer);
 
-        this._userLocationLayer = new Champlain.MarkerLayer({ selection_mode: mode });
+        this._userLocationLayer =
+            new Champlain.MarkerLayer({ selection_mode: mode });
         this.view.add_layer(this._userLocationLayer);
     },
 
@@ -133,7 +136,7 @@ const MapView = new Lang.Class({
         }).bind(this));
 
         query.connect('notify', (function() {
-                this.routeVisible = query.isValid();
+            this.routeVisible = query.isValid();
         }).bind(this));
     },
 
@@ -159,7 +162,8 @@ const MapView = new Lang.Class({
     userLocationVisible: function() {
         let box = this.view.get_bounding_box();
 
-        return box.covers(this._userLocation.latitude, this._userLocation.longitude);
+        return box.covers(this._userLocation.latitude,
+                          this._userLocation.longitude);
     },
 
     _updateUserLocation: function() {
@@ -168,13 +172,14 @@ const MapView = new Lang.Class({
 
         let place = Application.geoclue.place;
 
-        let previousSelected = this._userLocation && this._userLocation.selected;
-        this._userLocation = new UserLocationMarker.UserLocationMarker({ place: place,
-                                                                         mapView: this });
+        let selected = this._userLocation && this._userLocation.selected;
+        this._userLocation
+            = new UserLocationMarker.UserLocationMarker({ place: place,
+                                                          mapView: this });
         this._userLocationLayer.remove_all();
         this._userLocation.addToLayer(this._userLocationLayer);
 
-        this._userLocation.selected = previousSelected;
+        this._userLocation.selected = selected;
 
         this.emit('user-location-changed');
     },
@@ -186,16 +191,18 @@ const MapView = new Lang.Class({
         if (turnPoint.isStop())
             return;
 
-        this._turnPointMarker = new TurnPointMarker.TurnPointMarker({ turnPoint: turnPoint,
-                                                                      mapView: this });
+        this._turnPointMarker =
+            new TurnPointMarker.TurnPointMarker({ turnPoint: turnPoint,
+                                                  mapView: this });
         this._instructionMarkerLayer.add_marker(this._turnPointMarker);
         this._turnPointMarker.goToAndSelect(true);
     },
 
     showSearchResult: function(place) {
         this._searchResultLayer.remove_all();
-        let searchResultMarker = new SearchResultMarker.SearchResultMarker({ place: place,
-                                                                             mapView: this });
+        let searchResultMarker =
+                new SearchResultMarker.SearchResultMarker({ place: place,
+                                                            mapView: this });
 
         this._searchResultLayer.add_marker(searchResultMarker);
         searchResultMarker.goToAndSelect(true);
@@ -211,12 +218,12 @@ const MapView = new Lang.Class({
 
         let [lat, lon] = route.bbox.get_center();
         let place = new Geocode.Place({
-            location     : new Geocode.Location({ latitude  : lat,
-                                                  longitude : lon }),
-            bounding_box : new Geocode.BoundingBox({ top    : route.bbox.top,
-                                                     bottom : route.bbox.bottom,
-                                                     left   : route.bbox.left,
-                                                     right  : route.bbox.right })
+            location:     new Geocode.Location({ latitude:  lat,
+                                                 longitude: lon }),
+            bounding_box: new Geocode.BoundingBox({ top:    route.bbox.top,
+                                                    bottom: route.bbox.bottom,
+                                                    left:   route.bbox.left,
+                                                    right:  route.bbox.right })
         });
 
         this._showDestinationTurnpoints();
@@ -226,21 +233,27 @@ const MapView = new Lang.Class({
     _showDestinationTurnpoints: function() {
         let route = Application.routeService.route;
         let query = Application.routeService.query;
-        let pointIndex = 0;
 
         this._instructionMarkerLayer.remove_all();
-        route.turnPoints.forEach(function(turnPoint) {
-            if (turnPoint.isStop()) {
-                let queryPoint = query.filledPoints[pointIndex];
-                let destinationMarker = new TurnPointMarker.DestinationMarker({ turnPoint: turnPoint,
-                                                                                queryPoint: queryPoint,
-                                                                                mapView: this });
-                this._instructionMarkerLayer.add_marker(destinationMarker);
-                pointIndex++;
-            }
+
+        route.turnPoints.filter(function(turnPoint) {
+            return turnPoint.isStop();
+        }).forEach(function(turnPoint, index) {
+            let queryPoint = query.filledPoints[index];
+            this._showDestinationMarker(turnPoint, queryPoint);
         }, this);
     },
 
+    _showDestinationMarker: function(turnPoint, queryPoint) {
+        let marker = new TurnPointMarker.DestinationMarker({
+            turnPoint: turnPoint,
+            queryPoint: queryPoint,
+            mapView: this
+        });
+
+        this._instructionMarkerLayer.add_marker(marker);
+    },
+
     _onViewMoved: function() {
         this.emit('view-moved');
     },
diff --git a/src/mapWalker.js b/src/mapWalker.js
index 8386525..481736c 100644
--- a/src/mapWalker.js
+++ b/src/mapWalker.js
@@ -44,13 +44,13 @@ const MapWalker = new Lang.Class({
     },
 
     _createBoundingBox: function(place) {
-        if (place.bounding_box !== null) {
-            return new Champlain.BoundingBox({ top: place.bounding_box.top,
-                                               bottom: place.bounding_box.bottom,
-                                               left: place.bounding_box.left,
-                                               right: place.bounding_box.right });
-        } else
+        if (place.bounding_box === null) 
             return null;
+
+        return new Champlain.BoundingBox({ top:    place.bounding_box.top,
+                                           bottom: place.bounding_box.bottom,
+                                           left:   place.bounding_box.left,
+                                           right:  place.bounding_box.right });
     },
 
     // Zoom to the maximal zoom-level that fits the place type
@@ -108,29 +108,35 @@ const MapWalker = new Lang.Class({
             return;
         }
 
-        /* Lets first ensure that both current and destination location are visible
-         * before we start the animated journey towards destination itself. We do this
-         * to create the zoom-out-then-zoom-in effect that many map implementations
-         * do. This not only makes the go-to animation look a lot better visually but
-         * also give user a good idea of where the destination is compared to current
-         * location.
+        /* Lets first ensure that both current and destination location are
+         * visible before we start the animated journey towards destination
+         * itself. We do this to create the zoom-out-then-zoom-in effect that
+         * many map implementations do. This not only makes the go-to animation
+         * look a lot better visually but also give user a good idea of where
+         * the destination is compared to current location.
          */
 
         this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_CUBIC;
+        let lat = this._view.get_center_latitude();
+        let lng = this._view.get_center_longitude();
 
-        let fromLocation = new Geocode.Location({ latitude: this._view.get_center_latitude(),
-                                                  longitude: this._view.get_center_longitude() });
+        let fromLocation = new Geocode.Location({ latitude: lat,
+                                                  longitude:  lng });
         this._updateGoToDuration(fromLocation);
 
         Utils.once(this._view, 'animation-completed', (function() {
             Utils.once(this._view, 'animation-completed::go-to', (function() {
                 this.zoomToFit();
-                this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
+                this._view.goto_animation_mode
+                    = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
                 this.emit('gone-to');
             }).bind(this));
 
-            this._view.goto_animation_mode = Clutter.AnimationMode.EASE_OUT_CUBIC;
-            this._view.go_to(this.place.location.latitude, this.place.location.longitude);
+            this._view.goto_animation_mode
+                = Clutter.AnimationMode.EASE_OUT_CUBIC;
+
+            this._view.go_to(this.place.location.latitude,
+                             this.place.location.longitude);
         }).bind(this));
 
         this._ensureVisible(fromLocation);
@@ -148,12 +154,12 @@ const MapWalker = new Lang.Class({
                                                      right: -180,
                                                      bottom:  90,
                                                      top:    -90 });
-
-            [fromLocation, this.place.location].forEach(function(location) {
-                visibleBox.left   = Math.min(visibleBox.left,   location.longitude);
-                visibleBox.right  = Math.max(visibleBox.right,  location.longitude);
-                visibleBox.bottom = Math.min(visibleBox.bottom, location.latitude);
-                visibleBox.top    = Math.max(visibleBox.top,    location.latitude);
+            let locations =  [fromLocation, this.place.location];
+            locations.forEach(function({ longitude, latitude }) {
+                visibleBox.left   = Math.min(visibleBox.left,   longitude);
+                visibleBox.right  = Math.max(visibleBox.right,  longitude);
+                visibleBox.bottom = Math.min(visibleBox.bottom, latitude);
+                visibleBox.top    = Math.max(visibleBox.top,    latitude);
             });
         }
 
diff --git a/src/notification.js b/src/notification.js
index fe2027f..a5f8409 100644
--- a/src/notification.js
+++ b/src/notification.js
@@ -75,10 +75,10 @@ const Plain = new Lang.Class({
 
     _init: function(msg) {
         this.parent();
-        let label = new Gtk.Label({ visible : true,
-                                    hexpand : true,
-                                    halign  : Gtk.Align.START,
-                                    label   : msg });
+        let label = new Gtk.Label({ visible: true,
+                                    hexpand: true,
+                                    halign:  Gtk.Align.START,
+                                    label:   msg });
         this._ui.body.add(label);
     }
 });
diff --git a/src/notificationManager.js b/src/notificationManager.js
index 4a2df14..280027c 100644
--- a/src/notificationManager.js
+++ b/src/notificationManager.js
@@ -33,7 +33,7 @@ const NotificationManager = new Lang.Class({
         this._cache = {};
     },
 
-    showMessage: function (msg) {
+    showMessage: function(msg) {
         let notification = new Notification.Plain(msg);
         notification.connect('dismissed',
                              notification.destroy.bind(notification));
@@ -42,7 +42,7 @@ const NotificationManager = new Lang.Class({
     },
 
     showNotification: function(notification) {
-        if(notification.get_parent() !== this._overlay) {
+        if (notification.get_parent() !== this._overlay) {
             this._overlay.add_overlay(notification);
 
             notification.connect('dismissed', (function() {
@@ -51,5 +51,5 @@ const NotificationManager = new Lang.Class({
             }).bind(this));
         }
         notification.reveal();
-    },
+    }
 });
diff --git a/src/overpass.js b/src/overpass.js
index 9864613..2d50690 100644
--- a/src/overpass.js
+++ b/src/overpass.js
@@ -56,7 +56,8 @@ const Overpass = new Lang.Class({
         this.outputInfo = params.outputInfo || _DEFAULT_OUTPUT_INFO;
 
         // data sort order : qt(fastest based on geography), ids, asc
-        this.outputSortOrder = params.outputSortOrder || _DEFAULT_OUTPUT_SORT_ORDER;
+        this.outputSortOrder = params.outputSortOrder
+            || _DEFAULT_OUTPUT_SORT_ORDER;
 
         // HTTP Session Variables
         this._session = new Soup.Session();
@@ -78,7 +79,7 @@ const Overpass = new Lang.Class({
                 callback(true,
                          message.status_code,
                          this._createPlace(place, jsonObj));
-            } catch(e) {
+            } catch (e) {
                 callback(false, message.status_code, null);
             }
         }).bind(this));
@@ -106,8 +107,8 @@ const Overpass = new Lang.Class({
     },
 
     _getQueryUrl: function(osmId) {
-        return Format.vprintf('%s?data=%s', [ BASE_URL,
-                                              this._generateOverpassQuery(osmId) ]);
+        let query = this._generateOverpassQuery(osmId);
+        return Format.vprintf('%s?data=%s', [ BASE_URL, query ]);
     },
 
     _generateOverpassQuery: function(osmId) {
diff --git a/src/place.js b/src/place.js
index 8248140..e7bb92b 100644
--- a/src/place.js
+++ b/src/place.js
@@ -105,7 +105,7 @@ const Place = new Lang.Class({
     },
 
     _translateWheelchair: function(string) {
-        switch(string) {
+        switch (string) {
             /* Translators:
              * This means wheelchairs have full unrestricted access.
              */
@@ -179,24 +179,24 @@ Place.fromJSON = function(obj) {
     for (let key in obj) {
         let prop = obj[key];
 
-        switch(key) {
-            case 'id':
-                props.osm_id = prop;
-                break;
+        switch (key) {
+        case 'id':
+            props.osm_id = prop;
+            break;
 
-            case 'location':
-                props.location = new Geocode.Location(prop);
-                break;
+        case 'location':
+            props.location = new Geocode.Location(prop);
+            break;
 
-            case 'bounding_box':
-                if (prop)
-                    props.bounding_box = new Geocode.BoundingBox(prop);
-                break;
+        case 'bounding_box':
+            if (prop)
+                props.bounding_box = new Geocode.BoundingBox(prop);
+            break;
 
-            default:
-                if (prop !== null && prop !== undefined)
-                    props[key] = prop;
-                break;
+        default:
+            if (prop !== null && prop !== undefined)
+                props[key] = prop;
+            break;
         }
     }
     return new Place(props);
diff --git a/src/placeEntry.js b/src/placeEntry.js
index 409bc17..356552d 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -59,12 +59,11 @@ const PlaceEntry = new Lang.Class({
             return;
 
         if (p) {
-            if (p.name) {
+            if (p.name)
                 this.text = p.name;
-            } else
+            else
                 this.text = p.location.latitude + ', ' + p.location.longitude;
-        } else
-            this.text = '';
+        } else this.text = '';
 
         this._place = p;
         this.notify('place');
@@ -133,7 +132,7 @@ const PlaceEntry = new Lang.Class({
     _createPopover: function(numVisible, maxChars) {
         let popover = new SearchPopup.SearchPopup({ num_visible:   numVisible,
                                                     relative_to:   this,
-                                                    maxChars:      maxChars});
+                                                    maxChars:      maxChars });
 
         this.connect('size-allocate', (function(widget, allocation) {
             // Magic number to make the alignment pixel perfect.
@@ -163,10 +162,10 @@ const PlaceEntry = new Lang.Class({
             if (this._validateCoordinates(latitude, longitude)) {
                 return new Geocode.Location({ latitude: latitude,
                                               longitude: longitude });
-            } else
-                return null;
-        } else
-            return null;
+            }
+        }
+
+        return null;
     },
 
     _parse: function() {
diff --git a/src/placeStore.js b/src/placeStore.js
index 3723714..782b9ba 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -53,7 +53,7 @@ function completionMatchFunc(completion, key, iter) {
     if (name === null)
         return false;
 
-    name = GLib.utf8_normalize (name, -1, GLib.NormalizeMode.ALL);
+    name = GLib.utf8_normalize(name, -1, GLib.NormalizeMode.ALL);
     if (name === null)
         return false;
 
diff --git a/src/route.js b/src/route.js
index cda2ea8..900b2f6 100644
--- a/src/route.js
+++ b/src/route.js
@@ -99,17 +99,20 @@ const TurnPoint = new Lang.Class({
     },
 
     _getIconName: function() {
-        switch(this._type) {
-        case TurnPointType.SHARP_LEFT:   return 'maps-direction-sharpleft-symbolic';
-        case TurnPointType.LEFT:         return 'maps-direction-left-symbolic';
-        case TurnPointType.SLIGHT_LEFT:  return 'maps-direction-slightleft-symbolic';
-        case TurnPointType.CONTINUE:     return 'maps-direction-continue-symbolic';
-        case TurnPointType.SLIGHT_RIGHT: return 'maps-direction-slightright-symbolic';
-        case TurnPointType.RIGHT:        return 'maps-direction-right-symbolic';
-        case TurnPointType.SHARP_RIGHT:  return 'maps-direction-sharpright-symbolic';
-        case TurnPointType.START:        return 'maps-point-start-symbolic';
-        case TurnPointType.VIA:          return 'maps-point-end-symbolic';
-        case TurnPointType.END:          return 'maps-point-end-symbolic';
+        let dir = 'maps-direction-';
+        let point = 'maps-point-';
+
+        switch (this._type) {
+        case TurnPointType.SHARP_LEFT:   return dir   + 'sharpleft-symbolic';
+        case TurnPointType.LEFT:         return dir   + 'left-symbolic';
+        case TurnPointType.SLIGHT_LEFT:  return dir   + 'slightleft-symbolic';
+        case TurnPointType.CONTINUE:     return dir   + 'continue-symbolic';
+        case TurnPointType.SLIGHT_RIGHT: return dir   + 'slightright-symbolic';
+        case TurnPointType.RIGHT:        return dir   + 'right-symbolic';
+        case TurnPointType.SHARP_RIGHT:  return dir   + 'sharpright-symbolic';
+        case TurnPointType.START:        return point + 'start-symbolic';
+        case TurnPointType.VIA:          return point + 'end-symbolic';
+        case TurnPointType.END:          return point + 'end-symbolic';
         default:                         return '';
         }
     }
diff --git a/src/routeQuery.js b/src/routeQuery.js
index 212d1b6..a96656c 100644
--- a/src/routeQuery.js
+++ b/src/routeQuery.js
@@ -29,8 +29,8 @@ const Transportation = {
     BIKE:       1,
     PEDESTRIAN: 2,
 
-    toString: function (transportation) {
-        switch(transportation) {
+    toString: function(transportation) {
+        switch (transportation) {
         case Transportation.CAR:        return 'car';
         case Transportation.BIKE:       return 'bike';
         case Transportation.PEDESTRIAN: return 'foot';
@@ -71,8 +71,10 @@ const RouteQuery = new Lang.Class({
     Extends: GObject.Object,
     Signals: {
         'reset': { },
-        'point-added': { param_types: [GObject.TYPE_OBJECT, GObject.TYPE_INT] },
-        'point-removed': { param_types: [GObject.TYPE_OBJECT, GObject.TYPE_INT] }
+        'point-added': { param_types: [ GObject.TYPE_OBJECT,
+                                        GObject.TYPE_INT ] },
+        'point-removed': { param_types: [ GObject.TYPE_OBJECT,
+                                          GObject.TYPE_INT] }
     },
     Properties: {
         'points': GObject.ParamSpec.object('points',
diff --git a/src/routeService.js b/src/routeService.js
index 6134e0b..345b586 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -46,7 +46,7 @@ const GraphHopper = new Lang.Class({
     },
 
     _init: function() {
-        this._session = new Soup.Session({ user_agent : Config.USER_AGENT });
+        this._session = new Soup.Session({ user_agent: Config.USER_AGENT });
         this._key     = "VCIHrHj0pDKb8INLpT4s5hVadNmJ1Q3vi0J4nJYP";
         this._baseURL = "http://graphhopper.com/api/1/route?";;
         this._locale  = GLib.get_language_names()[0];
@@ -69,14 +69,16 @@ const GraphHopper = new Lang.Class({
             try {
                 let result = this._parseMessage(message);
                 if (!result) {
-                    Application.notificationManager.showMessage(_("No route found."));
+                    let notification = _("No route found.");
+                    Application.notificationManager.showMessage(notification);
                     this.route.reset();
                 } else {
                     let route = this._createRoute(result.paths[0]);
                     this.route.update(route);
                 }
-            } catch(e) {
-                Application.notificationManager.showMessage(_("Route request failed."));
+            } catch (e) {
+                let notification = _("Route request failed.");
+                Application.notificationManager.showMessage(notification);
                 log(e);
             }
         }).bind(this));
@@ -84,7 +86,8 @@ const GraphHopper = new Lang.Class({
 
     _buildURL: function(points, transportation) {
         let locations = points.map(function(point) {
-            return [point.place.location.latitude, point.place.location.longitude].join(',');
+            return [point.place.location.latitude,
+                    point.place.location.longitude].join(',');
         });
         let vehicle = RouteQuery.Transportation.toString(transportation);
         let query = new HTTP.Query({ type:    'json',
@@ -144,19 +147,22 @@ const GraphHopper = new Lang.Class({
     },
 
     _createTurnPoints: function(path, instructions) {
-        let startPoint = new Route.TurnPoint({ coordinate:  path[0],
-                                               type:        Route.TurnPointType.START,
-                                               distance:    0,
-                                               instruction: _("Start!"),
-                                               time:        0
-                                             });
+        let startPoint
+                = new Route.TurnPoint({ coordinate:  path[0],
+                                        type:        Route.TurnPointType.START,
+                                        distance:    0,
+                                        instruction: _("Start!"),
+                                        time:        0
+                                      });
         let rest = instructions.map(this._createTurnPoint.bind(this, path));
         return [startPoint].concat(rest);
     },
 
     _createTurnPoint: function(path, { text, distance, time, interval, sign }) {
+        let type = this._createTurnPointType(sign);
+
         return new Route.TurnPoint({ coordinate:  path[interval[0]],
-                                     type:        this._createTurnPointType(sign),
+                                     type:        type,
                                      distance:    distance,
                                      instruction: text,
                                      time:        time });
diff --git a/src/searchPopup.js b/src/searchPopup.js
index 2de9107..6c0e1da 100644
--- a/src/searchPopup.js
+++ b/src/searchPopup.js
@@ -29,8 +29,8 @@ const _PLACE_ICON_SIZE = 20;
 const SearchPopup = new Lang.Class({
     Name: 'SearchPopup',
     Extends: Gtk.Popover,
-    Signals : {
-        'selected' : { param_types: [ GObject.TYPE_OBJECT ] }
+    Signals: {
+        'selected': { param_types: [ GObject.TYPE_OBJECT ] }
     },
     Template: 'resource:///org/gnome/maps/search-popup.ui',
     InternalChildren: [ 'scrolledWindow',
@@ -96,15 +96,17 @@ const SearchPopup = new Lang.Class({
             row.destroy();
         });
 
-        places.forEach((function(place) {
-            if (!place.location)
-                return;
+        places.forEach(this._addPlace.bind(this, searchString));
+    },
 
-            let row = new PlaceListRow.PlaceListRow({ place: place,
-                                                      searchString: searchString,
-                                                      maxChars: this._maxChars,
-                                                      can_focus: true });
-            this._list.add(row);
-        }).bind(this));
+    _addPlace: function(searchString, place) {
+        if (!place.location)
+            return;
+
+        let row = new PlaceListRow.PlaceListRow({ place: place,
+                                                  searchString: searchString,
+                                                  maxChars: this._maxChars,
+                                                  can_focus: true });
+        this._list.add(row);
     }
 });
diff --git a/src/searchResultBubble.js b/src/searchResultBubble.js
index b70bc3c..d111c49 100644
--- a/src/searchResultBubble.js
+++ b/src/searchResultBubble.js
@@ -113,7 +113,10 @@ const SearchResultBubble = new Lang.Class({
         }
 
         if (place.wheelchair) {
-            infos.push(_("Wheelchair access: %s").format(place.wheelchairTranslated));
+            let wheelchair = _("Wheelchair access: %s")
+                    .format(place.wheelchairTranslated);
+
+            infos.push(wheelchair);
         }
 
         infos.forEach((function(info) {
diff --git a/src/searchResultMarker.js b/src/searchResultMarker.js
index a4fc7f8..4f327eb 100644
--- a/src/searchResultMarker.js
+++ b/src/searchResultMarker.js
@@ -42,10 +42,12 @@ const SearchResultMarker = new Lang.Class({
     },
 
     _createBubble: function() {
-        if (this.place.name) {
-            return new SearchResultBubble.SearchResultBubble({ place: this.place,
-                                                               mapView: this._mapView });
-        } else
+        if (!this.place.name)
             return null;
+
+        const Bubble = SearchResultBubble.SearchResultBubble;
+
+        return new Bubble ({ place: this.place,
+                             mapView: this._mapView });
     }
 });
diff --git a/src/settings.js b/src/settings.js
index 10d1221..4ef4009 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -45,6 +45,6 @@ const Settings = new Lang.Class({
     },
 
     set: function(name, value) {
-        this.set_value(name, GLib.Variant.new (this._keyTypes[name], value));
+        this.set_value(name, GLib.Variant.new(this._keyTypes[name], value));
     }
 });
diff --git a/src/sidebar.js b/src/sidebar.js
index 5434c53..2c8dc88 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -49,9 +49,10 @@ const InstructionRow = new Lang.Class({
         ui.instructionLabel.label = this.turnPoint.instruction;
         ui.directionImage.icon_name = this.turnPoint.iconName;
 
-        if (this.turnPoint.distance > 0)
-            ui.distanceLabel.label = Utils.prettyDistance(this.turnPoint.distance);
-
+        if (this.turnPoint.distance > 0) {
+            ui.distanceLabel.label
+                = Utils.prettyDistance(this.turnPoint.distance);
+        }
         this.add(ui.instructionBox);
     }
 });
@@ -128,12 +129,13 @@ const Sidebar = new Lang.Class({
             if (button.active && query.transportation !== mode)
                 query.transportation = mode;
         };
-        pedestrian.connect('toggled', onToggle.bind(this, transport.PEDESTRIAN));
+        pedestrian.connect('toggled',
+                           onToggle.bind(this, transport.PEDESTRIAN));
         car.connect('toggled', onToggle.bind(this, transport.CAR));
         bike.connect('toggled', onToggle.bind(this, transport.BIKE));
 
         let setToggles = function() {
-            switch(query.transportation) {
+            switch (query.transportation) {
             case transport.PEDESTRIAN:
                 pedestrian.active = true;
                 break;
@@ -233,12 +235,13 @@ const Sidebar = new Lang.Class({
                 this._instructionList.add(row);
             }).bind(this));
 
-            /* Translators: %s is a time expression with the format "%f h" or "%f min" */
-            this._timeInfo.label = _("Estimated time: %s").format(Utils.prettyTime(route.time));
+            let time = Utils.prettyTime(route.time);
+            // Translators: %s is a time expression in format "%f h" or "%f min"
+            this._timeInfo.label = _("Estimated time: %s").format();
             this._distanceInfo.label = Utils.prettyDistance(route.distance);
         }).bind(this));
 
-        this._instructionList.connect('row-selected',(function(listbox, row) {
+        this._instructionList.connect('row-selected', (function(listbox, row) {
             if (row)
                 this._mapView.showTurnPoint(row.turnPoint);
         }).bind(this));
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index e5e659c..ecaf72d 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -109,11 +109,12 @@ const DestinationMarker = new Lang.Class({
     },
 
     _onMarkerDrag: function() {
-        let query = Application.routeService.query;
-        let place = new Geocode.Place({
-                        location: new Geocode.Location({ latitude: this.latitude.toFixed(5),
-                                                         longitude: this.longitude.toFixed(5) }) });
+        let lat = this.latitude.toFixed(5);
+        let lng = this.longitude.toFixed(5);
 
-        this._queryPoint.place = place;
+        let location = new Geocode.Location({ latitude: lat,
+                                              longitude:  lng });
+
+        this._queryPoint.place = new Geocode.Place({ location: location });
     }
 });
diff --git a/src/userLocationBubble.js b/src/userLocationBubble.js
index 7a0d408..461e070 100644
--- a/src/userLocationBubble.js
+++ b/src/userLocationBubble.js
@@ -30,9 +30,10 @@ const UserLocationBubble = new Lang.Class({
     Extends: MapBubble.MapBubble,
 
     _init: function(params) {
-        let ui = Utils.getUIObject('user-location-bubble', [ 'grid-content',
-                                                             'label-accuracy',
-                                                             'label-coordinates' ]);
+        let ui = Utils.getUIObject('user-location-bubble',
+                                   [ 'grid-content',
+                                     'label-accuracy',
+                                     'label-coordinates' ]);
         params.buttons = MapBubble.Button.ROUTE | MapBubble.Button.SHARE;
         params.routeFrom = true;
 
@@ -41,8 +42,10 @@ const UserLocationBubble = new Lang.Class({
         this.image.icon_name = 'find-location-symbolic';
         this.image.pixel_size = 48;
 
-        let accuracyDescription = Utils.getAccuracyDescription(this.place.location.accuracy);
-        ui.labelAccuracy.label = ui.labelAccuracy.label.format(accuracyDescription);
+        let accuracyDescription
+                = Utils.getAccuracyDescription(this.place.location.accuracy);
+        ui.labelAccuracy.label
+            = ui.labelAccuracy.label.format(accuracyDescription);
         ui.labelCoordinates.label = this.place.location.latitude.toFixed(5)
                                   + ', '
                                   + this.place.location.longitude.toFixed(5);
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js
index ca114c3..1d72c7e 100644
--- a/src/userLocationMarker.js
+++ b/src/userLocationMarker.js
@@ -74,24 +74,32 @@ const UserLocationMarker = new Lang.Class({
         this.add_actor(Utils.CreateActorFromIconName('user-location'));
 
         if (this.place.location.accuracy > 0) {
-            this._accuracyMarker = new AccuracyCircleMarker({ place: this.place });
+            this._accuracyMarker =
+                new AccuracyCircleMarker({ place: this.place });
             this._accuracyMarker.refreshGeometry(this._view);
-            this._zoomLevelId = this._view.connect('notify::zoom-level',
-                                                   
this._accuracyMarker.refreshGeometry.bind(this._accuracyMarker));
+            this._zoomLevelId =
+                this._view.connect('notify::zoom-level',
+                                   this._onZoomLevelChange.bind(this));
             this.connect('destroy', (function() {
                 this._view.disconnect(this._zoomLevelId);
             }).bind(this));
         }
     },
 
+    _onZoomLevelChange: function() {
+        this._accuracyMarker.refreshGeometry();
+    },
+
     get anchor() {
         return { x: Math.floor(this.width / 2),
                  y: Math.floor(this.height / 2) };
     },
 
     _createBubble: function() {
-        return new UserLocationBubble.UserLocationBubble({ place: this.place,
-                                                           mapView: this._mapView });
+        const Bubble = UserLocationBubble.UserLocationBubble;
+
+        return new Bubble({ place: this.place,
+                            mapView: this._mapView });
     },
 
     addToLayer: function(layer) {
diff --git a/src/utils.js b/src/utils.js
index 79c857f..3ef8161 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -36,7 +36,7 @@ const _ = imports.gettext.gettext;
 const METRIC_SYSTEM = 1;
 const IMPERIAL_SYSTEM = 2;
 
-//List of locales using imperial system according to glibc locale database
+// List of locales using imperial system according to glibc locale database
 const IMPERIAL_LOCALES = ['unm_US', 'es_US', 'es_PR', 'en_US', 'yi_US'];
 
 let debugInit = false;
@@ -72,12 +72,13 @@ function addSignalMethods(proto) {
     proto.once = once.bind(undefined, proto);
 }
 
-function loadStyleSheet(file) {
+function loadStyleSheet(uri) {
     let provider = new Gtk.CssProvider();
-    provider.load_from_file(file);
+    provider.load_from_file(Gio.file_new_for_uri(uri));
+    let priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION;
     Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
                                              provider,
-                                             Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+                                             priority);
 }
 
 function clearGtkClutterActorBg(actor) {
@@ -89,13 +90,13 @@ function clearGtkClutterActorBg(actor) {
 }
 
 function addActions(actionMap, entries) {
-    for(let name in entries) {
+    for (let name in entries) {
         let entry = entries[name];
         let action = createAction(name, entry);
 
         actionMap.add_action(action);
 
-        if(entry.accels)
+        if (entry.accels)
             setAccelsForActionMap(actionMap, name, entry.accels);
     }
 }
@@ -104,10 +105,10 @@ function setAccelsForActionMap(actionMap, actionName, accels) {
     let app;
     let prefix;
 
-    if(actionMap instanceof Gtk.Application) {
+    if (actionMap instanceof Gtk.Application) {
         app = actionMap;
         prefix = "app";
-    } else if(actionMap instanceof Gtk.Window) {
+    } else if (actionMap instanceof Gtk.Window) {
         app = actionMap.application;
         prefix = "win";
     }
@@ -117,19 +118,19 @@ function setAccelsForActionMap(actionMap, actionName, accels) {
 function createAction(name, { state, paramType, onActivate, onChangeState }) {
     let entry = { name: name };
 
-    if(Array.isArray(state)) {
+    if (Array.isArray(state)) {
         let [type, value] = state;
         entry.state = new GLib.Variant.new(type, value);
     }
 
-    if(paramType !== undefined)
+    if (paramType !== undefined)
         entry.parameter_type = GLib.VariantType.new(paramType);
 
     let action = new Gio.SimpleAction(entry);
 
-    if(onActivate)
+    if (onActivate)
         action.connect('activate', onActivate);
-    if(onChangeState)
+    if (onChangeState)
         action.connect('change-state', onChangeState);
 
     return action;
@@ -182,7 +183,7 @@ function CreateActorFromIconName(name) {
         actor.set_size(pixbuf.get_width(), pixbuf.get_height());
 
         return actor;
-    } catch(e) {
+    } catch (e) {
         log("Failed to load image: " + e.message);
         return null;
     }
@@ -248,7 +249,7 @@ function getMeasurementSystem() {
 }
 
 function getAccuracyDescription(accuracy) {
-    switch(accuracy) {
+    switch (accuracy) {
     case Geocode.LOCATION_ACCURACY_UNKNOWN:
         /* Translators: Accuracy of user location information */
         return _("Unknown");
@@ -276,7 +277,7 @@ function _load_file_icon(icon, loadCompleteCallback) {
         return;
     }
 
-    if (icon.file.has_uri_scheme ("http") || icon.file.has_uri_scheme ("https")) {
+    if (icon.file.has_uri_scheme("http") || icon.file.has_uri_scheme("https")) {
         _load_http_icon(icon, loadCompleteCallback);
         return;
     }
@@ -290,7 +291,7 @@ function _load_file_icon(icon, loadCompleteCallback) {
 
             _iconStore[icon.file.get_uri()] = pixbuf;
             loadCompleteCallback(pixbuf);
-        } catch(e) {
+        } catch (e) {
             log("Failed to load pixbuf: " + e);
         }
     });
@@ -307,14 +308,14 @@ function _load_http_icon(icon, loadCompleteCallback) {
         }
 
         let contents = msg.response_body.flatten().get_as_bytes();
-        let stream = Gio.MemoryInputStream.new_from_data
-                    (contents.get_data (null));
+        let data = contents.get_data(null);
+        let stream = Gio.MemoryInputStream.new_from_data(data);
         try {
             let pixbuf = GdkPixbuf.Pixbuf.new_from_stream(stream, null);
 
             _iconStore[icon.file.get_uri()] = pixbuf;
             loadCompleteCallback(pixbuf);
-        } catch(e) {
+        } catch (e) {
             log("Failed to load pixbuf: " + e);
         }
     });
@@ -339,7 +340,7 @@ function _load_themed_icon(icon, size, loadCompleteCallback) {
     try {
         let pixbuf = info.load_icon();
         loadCompleteCallback(pixbuf);
-    } catch(e) {
+    } catch (e) {
         log("Failed to load pixbuf: " + e);
     }
 }
@@ -353,7 +354,7 @@ function prettyTime(time) {
 
     let labelledTime = "";
     if (hours > 0)
-        labelledTime += _("%f h").format(hours)+' ';
+        labelledTime += _("%f h").format(hours) + ' ';
     if (minutes > 0)
         labelledTime += _("%f min").format(minutes);
     return labelledTime;
@@ -362,14 +363,15 @@ function prettyTime(time) {
 function prettyDistance(distance) {
     distance = Math.round(distance);
 
-    if (getMeasurementSystem() === METRIC_SYSTEM){
+    if (getMeasurementSystem() === METRIC_SYSTEM) {
         if (distance >= 1000) {
             distance = Math.round(distance / 1000 * 10) / 10;
             /* Translators: This is a distance measured in kilometers */
             return _("%f km").format(distance);
-        } else
+        } else {
             /* Translators: This is a distance measured in meters */
             return _("%f m").format(distance);
+        }
     } else {
         // Convert to feet
         distance = Math.round(distance * 3.2808399);
@@ -378,8 +380,9 @@ function prettyDistance(distance) {
             distance = Math.round(distance / 5280 * 10) / 10;
             /* Translators: This is a distance measured in miles */
             return _("%f mi").format(distance);
-        } else
+        } else {
             /* Translators: This is a distance measured in feet */
             return _("%f ft").format(distance);
+        }
     }
 }
diff --git a/src/zoomControl.js b/src/zoomControl.js
index 0f98121..eff0765 100644
--- a/src/zoomControl.js
+++ b/src/zoomControl.js
@@ -28,7 +28,7 @@ const ZoomControl = new Lang.Class({
     Name: 'ZoomControl',
     Extends: Gtk.Bin,
 
-    _init: function (mapView) {
+    _init: function(mapView) {
         this.parent({ halign: Gtk.Align.START,
                       valign: Gtk.Align.START,
                       margin_top: 6,
@@ -56,7 +56,7 @@ const ZoomControl = new Lang.Class({
         this.add(ui.zoomControl);
     },
 
-    _updateSensitive: function () {
+    _updateSensitive: function() {
         let zoomLevel = this._view.zoom_level;
         let maxZoomLevel = this._view.max_zoom_level;
         let minZoomLevel = this._view.min_zoom_level;


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