[gnome-maps/wip/mlundblad/transit-routing: 5/15] 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/15] routeQuery: Move routequery to the Application module
- Date: Thu, 2 Jun 2016 22:27:54 +0000 (UTC)
commit c5bdd7c4f49663463c194a33575feeaefcc0c109
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.
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 | 32 ++++++++++++++++++--------------
src/turnPointMarker.js | 2 +-
8 files changed, 34 insertions(+), 27 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 c399dd2..76f799c 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -66,8 +66,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();
},
@@ -87,7 +87,7 @@ const ContextMenu = new Lang.Class({
},
_routingUpdate: function() {
- let query = Application.routeService.query;
+ let query = Application.routeQuery;
if (query.points.length === 0)
return;
@@ -103,7 +103,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 dd28a8e..02386d0 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 aa587da..e8db3bb 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -89,7 +89,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;
@@ -189,7 +189,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() {
@@ -411,7 +411,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;
@@ -465,7 +465,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 b89d9aa..6b541eb 100644
--- a/src/printLayout.js
+++ b/src/printLayout.js
@@ -275,7 +275,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..d887c31 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -35,10 +35,6 @@ const Utils = imports.utils;
const GraphHopper = new Lang.Class({
Name: 'GraphHopper',
- get query() {
- return this._query;
- },
-
get route() {
return this._route;
},
@@ -49,16 +45,24 @@ const GraphHopper = new Lang.Class({
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 = Application.routeQuery;
+ this.parent();
+ },
- this.query.connect('notify::points', (function() {
- if (this.query.isValid())
- this.fetchRoute(this.query.filledPoints,
+ connect: function() {
+ this._signalHandler = this._query.connect('notify::points', (function() {
+ if (this._query.isValid())
+ this.fetchRoute(this._query.filledPoints,
this._query.transportation);
}).bind(this));
+ },
- this.parent();
+ disconnect: function() {
+ if (this._signalHandler !== 0) {
+ this._query.disconnect(this._signalHandler);
+ this._signalHandler = 0;
+ }
},
_updateFromStored: function() {
@@ -88,8 +92,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 +104,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 +188,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]