[gnome-maps/wip/mlundblad/transit-routing: 5/32] routeQuery: Move routequery to the Application module
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 5/32] routeQuery: Move routequery to the Application module
- Date: Tue, 14 Feb 2017 21:12:33 +0000 (UTC)
commit 678393116e6ca2c29fd6fef522d16ef8ada93f4f
Author: Marcus Lundblad <ml update uu se>
Date: Thu Mar 17 21:28:34 2016 +0100
routeQuery: Move routequery to the Application module
Let the Application module handle the route query singleton instance.
This is needed so that the OpenTripPlanner module can access the
query.
Also change the GraphHopper object to take the query as a contruct
parameter to avoid accessing globals in Application.
https://bugzilla.gnome.org/show_bug.cgi?id=755808
src/application.js | 3 +++
src/contextMenu.js | 8 ++++----
src/mainWindow.js | 4 ++--
src/mapBubble.js | 2 +-
src/mapView.js | 8 ++++----
src/printLayout.js | 2 +-
src/routeService.js | 28 +++++++++-------------------
src/turnPointMarker.js | 2 +-
8 files changed, 25 insertions(+), 32 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 5a452ee..46c5f87 100644
--- a/src/application.js
+++ b/src/application.js
@@ -40,6 +40,7 @@ const OSMEdit = imports.osmEdit;
const OSMTypeSearchEntry = imports.osmTypeSearchEntry;
const PlaceStore = imports.placeStore;
const RouteService = imports.routeService;
+const RouteQuery = imports.routeQuery;
const Settings = imports.settings;
const Utils = imports.utils;
@@ -56,6 +57,7 @@ let checkInManager = null;
let contactStore = null;
let osmEdit = null;
let normalStartup = true;
+let routeQuery = null;
const _ensuredTypes = [WebKit2.WebView,
OSMTypeSearchEntry.OSMTypeSearchEntry];
@@ -244,6 +246,7 @@ const Application = new Lang.Class({
_initServices: function() {
settings = Settings.getSettings('org.gnome.Maps');
+ routeQuery = new RouteQuery.RouteQuery();
routeService = new RouteService.GraphHopper();
geoclue = new Geoclue.Geoclue();
geocodeService = new GeocodeService.GeocodeService();
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 1941bb7..bd1bc12 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -65,8 +65,8 @@ const ContextMenu = new Lang.Class({
this._onAddOSMLocationActivated.bind(this));
this._routeItem.connect('activate',
this._onRouteActivated.bind(this));
- Application.routeService.query.connect('notify::points',
- this._routingUpdate.bind(this));
+ Application.routeQuery.connect('notify::points',
+ this._routingUpdate.bind(this));
this._routeItem.visible = false;
this._routingUpdate();
},
@@ -86,7 +86,7 @@ const ContextMenu = new Lang.Class({
},
_routingUpdate: function() {
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
if (query.points.length === 0)
return;
@@ -102,7 +102,7 @@ const ContextMenu = new Lang.Class({
},
_onRouteActivated: function() {
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
let location = new Location.Location({ latitude: this._latitude,
longitude: this._longitude,
accuracy: 0 });
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 2be7c40..02e4211 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -134,9 +134,9 @@ const MainWindow = new Lang.Class({
_createSidebar: function() {
let sidebar = new Sidebar.Sidebar(this._mapView);
- Application.routeService.query.connect('notify',
- this._setRevealSidebar.bind(this, true));
+ Application.routeQuery.connect('notify',
+ this._setRevealSidebar.bind(this, true));
this._toggleSidebarButton.bind_property('active',
this._mapView, 'routeVisible',
GObject.BindingFlags.BIDIRECTIONAL);
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 74f8b59..0851655 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -150,7 +150,7 @@ const MapBubble = new Lang.Class({
},
_initRouteButton: function(button, routeFrom) {
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
let route = Application.routeService.route;
let from = query.points[0];
let to = query.points[query.points.length - 1];
diff --git a/src/mapView.js b/src/mapView.js
index 6b38cb1..f38553b 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -88,7 +88,7 @@ const MapView = new Lang.Class({
},
set routeVisible(value) {
- let isValid = Application.routeService.query.isValid();
+ let isValid = Application.routeQuery.isValid();
this._routeLayer.visible = value && isValid;
this._instructionMarkerLayer.visible = value && isValid;
@@ -188,7 +188,7 @@ const MapView = new Lang.Class({
_connectRouteSignals: function() {
let route = Application.routeService.route;
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
route.connect('update', this.showRoute.bind(this, route));
route.connect('reset', (function() {
@@ -417,7 +417,7 @@ const MapView = new Lang.Class({
},
_showStoredRoute: function(stored) {
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
let route = Application.routeService.route;
Application.routeService.storedRoute = stored.route;
@@ -471,7 +471,7 @@ const MapView = new Lang.Class({
_showDestinationTurnpoints: function() {
let route = Application.routeService.route;
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
let pointIndex = 0;
this._instructionMarkerLayer.remove_all();
diff --git a/src/printLayout.js b/src/printLayout.js
index 45868e9..4dc60d2 100644
--- a/src/printLayout.js
+++ b/src/printLayout.js
@@ -276,7 +276,7 @@ const PrintLayout = new Lang.Class({
},
_formatQueryPlaceName: function(index) {
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
if (index === -1)
index = query.filledPoints.length - 1;
let name;
diff --git a/src/routeService.js b/src/routeService.js
index 31ad061..3b0289f 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -35,30 +35,20 @@ const Utils = imports.utils;
const GraphHopper = new Lang.Class({
Name: 'GraphHopper',
- get query() {
- return this._query;
- },
-
get route() {
return this._route;
},
- _init: function() {
+ _init: function(params) {
this._session = new Soup.Session({ user_agent : 'gnome-maps/' + pkg.version });
this._key = "VCIHrHj0pDKb8INLpT4s5hVadNmJ1Q3vi0J4nJYP";
this._baseURL = "https://graphhopper.com/api/1/route?";
this._locale = GLib.get_language_names()[0];
this._route = new Route.Route();
- this._query = new RouteQuery.RouteQuery();
this.storedRoute = null;
-
- this.query.connect('notify::points', (function() {
- if (this.query.isValid())
- this.fetchRoute(this.query.filledPoints,
- this._query.transportation);
- }).bind(this));
-
- this.parent();
+ this._query = params.query;
+ delete params.query;
+ this.parent(params);
},
_updateFromStored: function() {
@@ -88,8 +78,8 @@ const GraphHopper = new Lang.Class({
let result = this._parseMessage(message);
if (!result) {
Application.notificationManager.showMessage(_("No route found."));
- if (this.query.latest)
- this.query.latest.place = null;
+ if (this._query.latest)
+ this._query.latest.place = null;
else
this.route.reset();
@@ -100,8 +90,8 @@ const GraphHopper = new Lang.Class({
} catch(e) {
Application.notificationManager.showMessage(_("Route request failed."));
Utils.debug(e);
- if (this.query.latest)
- this.query.latest.place = null;
+ if (this._query.latest)
+ this._query.latest.place = null;
else
this.route.reset();
}
@@ -184,7 +174,7 @@ const GraphHopper = new Lang.Class({
let text = instr.text;
if (type === Route.TurnPointType.VIA) {
via++;
- let viaPlace = this.query.filledPoints[via].place;
+ let viaPlace = this._query.filledPoints[via].place;
text = viaPlace.name || instr.text;
}
return new Route.TurnPoint({
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index 3774083..9bc9036 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -91,7 +91,7 @@ const TurnPointMarker = new Lang.Class({
},
_onMarkerDrag: function() {
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
let place = new Place.Place({
location: new Location.Location({ latitude: this.latitude.toFixed(5),
longitude: this.longitude.toFixed(5) }) });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]