[gnome-maps/wip/routing2: 12/18] fixup route query



commit a7956c5141cc32d294cdcd99bcccc74bc460ff7e
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Sat May 3 00:39:23 2014 +0200

    fixup route query

 src/gnome-maps.js.gresource.xml |    1 +
 src/route.js                    |   67 ---------------------------
 src/routeQuery.js               |   95 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+), 67 deletions(-)
---
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
index 0663567..589f17a 100644
--- a/src/gnome-maps.js.gresource.xml
+++ b/src/gnome-maps.js.gresource.xml
@@ -16,6 +16,7 @@
     <file>path.js</file>
     <file>placeStore.js</file>
     <file>route.js</file>
+    <file>routeQuery.js</file>
     <file>routeService.js</file>
     <file>searchPopup.js</file>
     <file>settings.js</file>
diff --git a/src/route.js b/src/route.js
index 898a295..5c8ed36 100644
--- a/src/route.js
+++ b/src/route.js
@@ -28,12 +28,6 @@ const Champlain = imports.gi.Champlain;
 
 const Utils = imports.utils;
 
-const Transportation = {
-    CAR:        0,
-    BIKE:       1,
-    PEDESTRIAN: 2
-};
-
 const TurnPointType = {
     SHARP_LEFT:    0,
     LEFT:          1,
@@ -50,67 +44,6 @@ const TurnPointType = {
     START:         10000
 };
 
-const Query = new Lang.Class({
-    Name: 'Query',
-    Extends: GObject.Object,
-    Properties: {
-        'from': GObject.ParamSpec.object('from',
-                                         '',
-                                         '',
-                                         GObject.ParamFlags.READABLE |
-                                         GObject.ParamFlags.WRITABLE,
-                                         GeoCode.Place),
-        'to': GObject.ParamSpec.object('to',
-                                       '',
-                                       '',
-                                       GObject.ParamFlags.READABLE |
-                                       GObject.ParamFlags.WRITABLE,
-                                       GeoCode.Place),
-        'transportation': GObject.ParamSpec.int('transportation',
-                                                '',
-                                                '',
-                                                GObject.ParamFlags.READABLE |
-                                                GObject.ParamFlags.WRITABLE,
-                                                Transportation.CAR,
-                                                Transportation.PEDESTRIAN,
-                                                Transportation.CAR)
-    },
-
-    _init: function(args) {
-        this.parent(args);
-        this._changeSignalId = this.connect('notify',
-                                            this.emit.bind(this, 'change'));
-        this.reset();
-    },
-
-    reset: function() {
-        this.setMany({ from: null,
-                       to: null,
-                       transportation: Transportation.CAR });
-    },
-
-    setMany: function(obj) {
-        this.disconnect(this._changeSignalId);
-
-        // Only set properties actually defined on this object
-        ["from", "to", "transportation"].forEach((function(prop) {
-            if (obj.hasOwnProperty(prop))
-                this[prop] = obj[prop];
-        }).bind(this));
-
-        this._changeSignalId = this.connect('notify',
-                                            this.emit.bind(this, 'change'));
-        this.emit('change');
-    },
-
-    toString: function() {
-        return "From: " + this.from +
-            "\nTo: " + this.to +
-            "\nTransportation" + this.transportation;
-    }
-});
-Utils.addSignalMethods(Query.prototype);
-
 const Route = new Lang.Class({
     Name: 'Route',
 
diff --git a/src/routeQuery.js b/src/routeQuery.js
new file mode 100644
index 0000000..c2ff2b4
--- /dev/null
+++ b/src/routeQuery.js
@@ -0,0 +1,95 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2013 Mattias Bengtsson.
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
+ */
+
+const Geocode = imports.gi.GeocodeGlib;
+const GObject = imports.gi.GObject;
+
+const Lang = imports.lang;
+
+const Utils = imports.utils;
+
+const Transportation = {
+    CAR:        0,
+    BIKE:       1,
+    PEDESTRIAN: 2
+};
+
+const Query = new Lang.Class({
+    Name: 'Query',
+    Extends: GObject.Object,
+    Properties: {
+        'from': GObject.ParamSpec.object('from',
+                                         '',
+                                         '',
+                                         GObject.ParamFlags.READABLE |
+                                         GObject.ParamFlags.WRITABLE,
+                                         Geocode.Place),
+        'to': GObject.ParamSpec.object('to',
+                                       '',
+                                       '',
+                                       GObject.ParamFlags.READABLE |
+                                       GObject.ParamFlags.WRITABLE,
+                                       Geocode.Place),
+        'transportation': GObject.ParamSpec.int('transportation',
+                                                '',
+                                                '',
+                                                GObject.ParamFlags.READABLE |
+                                                GObject.ParamFlags.WRITABLE,
+                                                Transportation.CAR,
+                                                Transportation.PEDESTRIAN,
+                                                Transportation.CAR)
+    },
+
+    _init: function(args) {
+        this.parent(args);
+        this._changeSignalId = this.connect('notify',
+                                            this.emit.bind(this, 'change'));
+        this.reset();
+    },
+
+    reset: function() {
+        this.setMany({ from: null,
+                       to: null,
+                       transportation: Transportation.CAR });
+    },
+
+    setMany: function(obj) {
+        this.disconnect(this._changeSignalId);
+
+        // Only set properties actually defined on this object
+        ["from", "to", "transportation"].forEach((function(prop) {
+            if (obj.hasOwnProperty(prop))
+                this[prop] = obj[prop];
+        }).bind(this));
+
+        this._changeSignalId = this.connect('notify',
+                                            this.emit.bind(this, 'change'));
+        this.emit('change');
+    },
+
+    toString: function() {
+        return "From: " + this.from +
+            "\nTo: " + this.to +
+            "\nTransportation" + this.transportation;
+    }
+});
+Utils.addSignalMethods(Query.prototype);


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