[gnome-maps/wip/mlundblad/transit-routing: 3/32] transitOptions: Add class holding options for transit routing



commit b1f7679fb53591bdb999c67527455a88352e4183
Author: Marcus Lundblad <ml update uu se>
Date:   Sun May 29 22:27:12 2016 +0200

    transitOptions: Add class holding options for transit routing
    
    Currently has options to show all route types (modes of transportation) or
    restrict to a selected set of modes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755808

 src/org.gnome.Maps.src.gresource.xml |    1 +
 src/transitOptions.js                |   54 ++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index 0bf7d73..a962fb3 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -73,6 +73,7 @@
     <file>socialPlaceMatcher.js</file>
     <file>storedRoute.js</file>
     <file>togeojson/togeojson.js</file>
+    <file>transitOptions.js</file>
     <file>translations.js</file>
     <file>turnPointMarker.js</file>
     <file>userLocationBubble.js</file>
diff --git a/src/transitOptions.js b/src/transitOptions.js
new file mode 100644
index 0000000..db88861
--- /dev/null
+++ b/src/transitOptions.js
@@ -0,0 +1,54 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2017 Marcus Lundblad.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+const Lang = imports.lang;
+
+const TransitOptions = new Lang.Class({
+    Name: 'TransitOptions',
+
+    _init: function() {
+        this._showAllTransitTypes = true;
+        this._transitTypes = [];
+    },
+
+    get showAllTransitTypes() {
+        return this._showAllTransitTypes;
+    },
+
+    /* When set to true, show any mode of transportation, else only show modes
+     * added with addTransitType()
+     */
+    set showAllTransitTypes(showAllTransitTypes) {
+        this._showAllTransitTypes = showAllTransitTypes;
+        this._transitTypes = [];
+    },
+
+    /* Add an explicit transport mode to show
+     */
+    addTransitType: function(transitType) {
+        this._showAllTransitTypes = false;
+        this._transitTypes.push(transitType);
+    },
+
+    get transitTypes() {
+        return this._transitTypes;
+    }
+});


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