[gnome-maps/wip/mlundblad/transit-routing: 2/2] WIP: Hook up a new toggle button for transit mode routing
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 2/2] WIP: Hook up a new toggle button for transit mode routing
- Date: Mon, 15 Feb 2016 22:22:03 +0000 (UTC)
commit a4f9d1da11853c7cd063604246a839798947f909
Author: Marcus Lundblad <ml update uu se>
Date: Mon Feb 15 23:19:09 2016 +0100
WIP: Hook up a new toggle button for transit mode routing
Currently only sends out a query to the OTP instance to get a list of
all routers (public transportation networks) currently available in
the server when the transit mode button is selected.
data/ui/sidebar.ui | 23 +++++++++++++++++++++++
src/application.js | 3 +++
src/routeQuery.js | 5 ++++-
src/sidebar.js | 17 +++++++++++++++--
4 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/sidebar.ui b/data/ui/sidebar.ui
index 490f3df..268750a 100644
--- a/data/ui/sidebar.ui
+++ b/data/ui/sidebar.ui
@@ -94,6 +94,29 @@
</style>
</object>
</child>
+ <child>
+ <object class="GtkRadioButton" id="modeTransitToggle">
+ <property name="name">mode-transit-toggle</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">False</property>
+ <property name="group">modeBikeToggle</property>
+ <property name="height-request">32</property>
+ <property name="width-request">42</property>
+ <child>
+ <object class="GtkImage" id="mode-transit-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon-name">route-transit-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="transportation-mode-button"/>
+ </style>
+ </object>
+ </child>
<style>
<class name="linked"/>
</style>
diff --git a/src/application.js b/src/application.js
index 2d6b023..efe9aa4 100644
--- a/src/application.js
+++ b/src/application.js
@@ -37,6 +37,7 @@ const GeocodeService = imports.geocodeService;
const MainWindow = imports.mainWindow;
const Maps = imports.gi.GnomeMaps;
const NotificationManager = imports.notificationManager;
+const OpenTripPlanner = imports.openTripPlanner;
const OSMEdit = imports.osmEdit;
const OSMTypeSearchEntry = imports.osmTypeSearchEntry;
const PlaceStore = imports.placeStore;
@@ -55,6 +56,7 @@ let geocodeService = null;
let networkMonitor = null;
let checkInManager = null;
let contactStore = null;
+let openTripPlanner = null;
let osmEdit = null;
let normalStartup = true;
@@ -256,6 +258,7 @@ const Application = new Lang.Class({
contactStore = new Maps.ContactStore();
contactStore.load();
osmEdit = new OSMEdit.OSMEdit();
+ openTripPlanner = new OpenTripPlanner.OpenTripPlanner();
},
_createWindow: function() {
diff --git a/src/routeQuery.js b/src/routeQuery.js
index 2108440..952bbec 100644
--- a/src/routeQuery.js
+++ b/src/routeQuery.js
@@ -27,12 +27,14 @@ const Transportation = {
CAR: 0,
BIKE: 1,
PEDESTRIAN: 2,
+ TRANSIT: 3,
toString: function (transportation) {
switch(transportation) {
case Transportation.CAR: return 'car';
case Transportation.BIKE: return 'bike';
case Transportation.PEDESTRIAN: return 'foot';
+ case Transportation.TRANSIT: return 'transit';
default: return null;
}
}
@@ -87,7 +89,8 @@ const RouteQuery = new Lang.Class({
GObject.ParamFlags.WRITABLE,
Transportation.CAR,
Transportation.PEDESTRIAN,
- Transportation.CAR)
+ Transportation.CAR,
+ Transportation.TRANSIT)
},
get points() {
diff --git a/src/sidebar.js b/src/sidebar.js
index f20d535..014127a 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -48,6 +48,7 @@ const Sidebar = new Lang.Class({
'modeBikeToggle',
'modeCarToggle',
'modePedestrianToggle',
+ 'modeTransitToggle',
'timeInfo' ],
_init: function(mapView) {
@@ -59,7 +60,8 @@ const Sidebar = new Lang.Class({
this._initTransportationToggles(this._modePedestrianToggle,
this._modeBikeToggle,
- this._modeCarToggle);
+ this._modeCarToggle,
+ this._modeTransitToggle);
this._initQuerySignals();
let query = Application.routeService.query;
@@ -68,17 +70,25 @@ const Sidebar = new Lang.Class({
query.addPoint(1);
},
- _initTransportationToggles: function(pedestrian, bike, car) {
+ _initTransportationToggles: function(pedestrian, bike, car, transit) {
let query = Application.routeService.query;
let transport = RouteQuery.Transportation;
let onToggle = function(mode, button) {
+ if (button.active && mode === transport.TRANSIT) {
+ let openTripPlanner = Application.openTripPlanner;
+
+ openTripPlanner.fetchRouters(function(status, body) {
+ Utils.debug('fetched routers: ' + status);
+ });
+ }
if (button.active && query.transportation !== mode)
query.transportation = mode;
};
pedestrian.connect('toggled', onToggle.bind(this, transport.PEDESTRIAN));
car.connect('toggled', onToggle.bind(this, transport.CAR));
bike.connect('toggled', onToggle.bind(this, transport.BIKE));
+ transit.connect('toggled', onToggle.bind(this, transport.TRANSIT))
let setToggles = function() {
switch(query.transportation) {
@@ -91,6 +101,9 @@ const Sidebar = new Lang.Class({
case transport.BIKE:
bike.active = true;
break;
+ case transport.TRANSIT:
+ transit.active = true;
+ break;
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]