[gnome-maps/wip/fix-geoloc: 2/8] Cleanups



commit 92dbc5e6c7ee5ab4ffc69d30172505703b67c664
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Wed Jul 10 02:06:30 2013 +0200

    Cleanups
    
    Reindentions, trailing commas, extra spaces, try to fit 80 char columns
    and more js-idiomatic code.

 src/geoclue.js      |   12 ++++++------
 src/mainWindow.js   |    6 +++---
 src/mapLocation.js  |   38 +++++++++++++++++++-------------------
 src/userLocation.js |   19 ++++++++++++-------
 4 files changed, 40 insertions(+), 35 deletions(-)
---
diff --git a/src/geoclue.js b/src/geoclue.js
index 206dc77..033f0f9 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -58,10 +58,10 @@ const Geoclue = new Lang.Class({
     _findLocation: function() {
         GClue.ManagerProxy.new_for_bus(Gio.BusType.SESSION,
                                        Gio.DBusProxyFlags.NONE,
-                                        "org.freedesktop.GeoClue2",
-                                        "/org/freedesktop/GeoClue2/Manager",
-                                        null,
-                                        Lang.bind(this, this._onManagerProxyReady));
+                                       "org.freedesktop.GeoClue2",
+                                       "/org/freedesktop/GeoClue2/Manager",
+                                       null,
+                                       Lang.bind(this, this._onManagerProxyReady));
     },
 
     _onManagerProxyReady: function(sourceObject, res) {
@@ -119,7 +119,7 @@ const Geoclue = new Lang.Class({
 
     _onLocationProxyReady: function(sourceObject, res) {
         try {
-            this.location =  GClue.LocationProxy.new_for_bus_finish(res);
+            this.location = GClue.LocationProxy.new_for_bus_finish(res);
 
             let variant = GLib.Variant.new('ad', [this.location.latitude,
                                                   this.location.longitude,
@@ -132,6 +132,6 @@ const Geoclue = new Lang.Class({
         } catch (e) {
             log("Failed to find your location: " + e);
         }
-    },
+    }
 });
 Signals.addSignalMethods(Geoclue.prototype);
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d0606b9..fad496a 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -98,14 +98,14 @@ const MainWindow = new Lang.Class({
         if (Application.settings.get_boolean('window-maximized'))
             this.window.maximize();
 
-        this.window.connect('delete-event',
-                            Lang.bind(this, this._quit));
+        this.window.connect('delete-event', Lang.bind(this, this._quit));
         this.window.connect('configure-event',
                             Lang.bind(this, this._onConfigureEvent));
         this.window.connect('window-state-event',
                             Lang.bind(this, this._onWindowStateEvent));
 
-        this._searchEntry.connect('activate', Lang.bind(this, this._onSearchActivate));
+        this._searchEntry.connect('activate',
+                                  Lang.bind(this, this._onSearchActivate));
 
         this.mapView = new MapView.MapView();
 
diff --git a/src/mapLocation.js b/src/mapLocation.js
index 48677f5..ce8fe9f 100644
--- a/src/mapLocation.js
+++ b/src/mapLocation.js
@@ -64,28 +64,28 @@ const MapLocation = new Lang.Class({
          * also give user a good idea of where the destination is compared to current
          * location.
          */
-        let locations = new Array();
-        locations[0] = new Geocode.Location({ latitude: this._view.get_center_latitude(),
-                                              longitude: this._view.get_center_longitude() });
-        locations[1] = this;
-
-        let animCompletedId = this._view.connect("animation-completed", Lang.bind(this,
-            function() {
-                this._view.disconnect(animCompletedId);
-                animCompletedId = this._view.connect("animation-completed::go-to", Lang.bind(this,
-                    function() {
-                        this._view.disconnect(animCompletedId);
-                        this._view.set_zoom_level(zoom);
-                        this.emit('gone-to');
-                    }));
-                this._view.go_to(this.latitude, this.longitude);
-            }));
-        this._mapView.ensureVisible(locations);
+
+        let id = this._view.connect("animation-completed", (function() {
+            this._view.disconnect(id);
+
+            id = this._view.connect("animation-completed::go-to", (function() {
+                this._view.disconnect(id);
+                this._view.set_zoom_level(zoom);
+                this.emit('gone-to');
+            }).bind(this));
+
+            this._view.go_to(this.latitude, this.longitude);
+        }).bind(this));
+
+        this._mapView.ensureVisible([
+            new Geocode.Location({ latitude: this._view.get_center_latitude(),
+                                   longitude: this._view.get_center_longitude() }),
+            this
+        ]);
     },
 
     show: function(layer) {
-        let marker = new Champlain.Label();
-        marker.set_text(this.description);
+        let marker = new Champlain.Label({ text: this.description });
         marker.set_location(this.latitude, this.longitude);
         layer.add_marker(marker);
         log("Added marker at " + this.latitude + ", " + this.longitude);
diff --git a/src/userLocation.js b/src/userLocation.js
index fd9419a..67aaf99 100644
--- a/src/userLocation.js
+++ b/src/userLocation.js
@@ -62,16 +62,21 @@ const UserLocation = new Lang.Class({
         textActor.set_margin_left(6);
         textActor.set_margin_right(6);
         textActor.set_color(new Clutter.Color({ red: 255,
-                                                 blue: 255,
-                                                 green: 255,
-                                                 alpha: 255 }));
-        let layout = new Clutter.BinLayout();
-        let descriptionActor = new Clutter.Actor({ layout_manager: layout });
+                                                blue: 255,
+                                                green: 255,
+                                                alpha: 255 }));
+
+        let descriptionActor = new Clutter.Actor({
+            layout_manager: new Clutter.BinLayout()
+        });
         descriptionActor.add_child(bubbleActor);
         descriptionActor.add_child(textActor);
 
-        let layout = new Clutter.BoxLayout({ vertical: true });
-        let locationActor = new Clutter.Actor({ layout_manager: layout });
+        let locationActor = new Clutter.Actor({
+            layout_manager: new Clutter.BoxLayout({
+                vertical: true
+            })
+        });
         locationActor.add_child(descriptionActor);
         locationActor.add_child(pin_actor);
 


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