[gnome-maps/wip/routing2] More sidebar work
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/routing2] More sidebar work
- Date: Sun, 25 May 2014 01:51:24 +0000 (UTC)
commit 015246cc89b49c390dc442065a455693156540ea
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Sun May 25 02:50:14 2014 +0100
More sidebar work
data/icons/route-bike-symbolic.svg | 20 +++
data/icons/route-car-symbolic.svg | 67 +++++++++
data/icons/route-pedestrian-symbolic.svg | 78 +++++++++++
data/icons/route-transit-symbolic.svg | 68 ++++++++++
src/application.js | 15 ++-
src/geocodeService.js | 56 ++++++++
src/gnome-maps.js.gresource.xml | 1 +
src/main-window.ui | 31 +++--
src/mainWindow.js | 24 +++-
src/sidebar.js | 90 +++++++++++--
src/sidebar.ui | 215 ++++++++++++++++++++++++++++++
11 files changed, 637 insertions(+), 28 deletions(-)
---
diff --git a/data/icons/route-bike-symbolic.svg b/data/icons/route-bike-symbolic.svg
new file mode 100644
index 0000000..0223d5f
--- /dev/null
+++ b/data/icons/route-bike-symbolic.svg
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="16px" height="16px" id="svg6558"
version="1.1" inkscape:version="0.48.4 r9939" sodipodi:docname="route-cycling-symbolic.svg">
+ <defs id="defs6560"/>
+ <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0"
inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="45.254834" inkscape:cx="13.7037"
inkscape:cy="8.1151584" inkscape:current-layer="layer1" showgrid="false" inkscape:grid-bbox="true"
inkscape:document-units="px" inkscape:snap-nodes="false" inkscape:snap-bbox="true"
inkscape:window-width="1920" inkscape:window-height="1014" inkscape:window-x="0" inkscape:window-y="27"
inkscape:window-maximized="1">
+ <inkscape:grid type="xygrid" id="grid6938"/>
+ </sodipodi:namedview>
+ <metadata id="metadata6563">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:title/>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer1" inkscape:label="Layer 1" inkscape:groupmode="layer">
+ <path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#2e3436;fill-opacity:1;stroke:none;stroke-width:1.31249988;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="M 11 2 C 9.971479 2 9.1411313 2.780118 9.03125 3.78125 L 3.0625 8.53125 L 8 10.65625 L 8 14 L 9 14 L 9 10
L 5 8.28125 L 7.09375 6.59375 L 9.21875 8.96875 L 13 8.96875 L 13 7.96875 L 9.65625 7.96875 L 7.875 5.96875 L
9.21875 4.90625 C 9.5484621 5.5568813 10.221826 6 11 6 C 12.103146 6 13 5.1052236 13 4 C 13 2.8947762
12.103146 2 11 2 z M 3 9.96875 C 1.3490679 9.96875 -2.9605947e-16 11.317818 0 12.96875 C 0 14.619682 1.349
0679 15.96875 3 15.96875 C 4.6509321 15.96875 6 14.619682 6 12.96875 C 6 11.317818 4.6509321 9.96875 3
9.96875 z M 13 9.96875 C 11.349067 9.96875 10 11.317818 10 12.96875 C 10 14.619682 11.349067 15.96875 13
15.96875 C 14.650932 15.96875 16 14.619682 16 12.96875 C 16 11.317818 14.650932 9.96875 13 9.96875 z M 3
10.96875 C 4.1104919 10.96875 5 11.858258 5 12.96875 C 5 14.079242 4.1104919 14.96875 3 14.96875 C 1.8895081
14.96875 1 14.079242 1 12.96875 C 1 11.858258 1.8895081 10.96875 3 10.96875 z M 13 10.96875 C 14.110491
10.96875 15 11.858258 15 12.96875 C 15 14.079242 14.110491 14.96875 13 14.96875 C 11.889508 14.96875 11
14.079242 11 12.96875 C 11 11.858258 11.889508 10.96875 13 10.96875 z " id="path6050-13"/>
+ </g>
+</svg>
\ No newline at end of file
diff --git a/data/icons/route-car-symbolic.svg b/data/icons/route-car-symbolic.svg
new file mode 100644
index 0000000..c511fe1
--- /dev/null
+++ b/data/icons/route-car-symbolic.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16px"
+ height="16px"
+ id="svg6558"
+ version="1.1"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="route-walking-symbolic.svg">
+ <defs
+ id="defs6560" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="22.197802"
+ inkscape:cx="9.2245257"
+ inkscape:cy="9.6312031"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:snap-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:window-width="1600"
+ inkscape:window-height="841"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid7232" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata6563">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ inkscape:connector-curvature="0"
+
style="color:#000000;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="M 4,4 C 3.480625,4 3.19205,4.4345415 3.0625,4.9375 L 2.28125,8 1.9375,8 C 1.418125,8 1,8.418125
1,8.9375 l 0,4.125 C 1,13.581875 1.480625,14 2,14 l 0,0.90625 C 2,15.512187 2.446,16 3,16 3.554,16
4,15.512187 4,14.90625 L 4,14 l 8,0 0,0.90625 C 12,15.512187 12.446,16 13,16 c 0.554,0 1,-0.487813 1,-1.09375
L 14,14 c 0.546725,0 1,-0.418125 1,-0.9375 l 0,-4.125 C 15,8.418125 14.581875,8 14.0625,8 L 13.71875,8
12.9375,4.9375 C 12.80795,4.4345415 12.519375,4 12,4 L 4,4 z m 1.0625,1 5.875,0 C 11.543438,5
11.816859,5.5161519 12,6.09375 L 12.625,8 c 0.183141,0.577598 -0.112812,1 -0.71875,1 L 4.09375,9 C 3.487812,9
3.153528,8.606555 3.34375,8.03125 L 4,6.09375 C 4.190222,5.5184449 4.456562,5 5.0625,5 z M 4,10 c 0.552285,0
1,0.447715 1,1 0,0.552285 -0.447715,1 -1,1 -0.552285,0 -1,-0.447715 -1,-1 0,-0.552285 0.447715,-1 1,-1 z m
8,0 c 0.552285,0 1,0.447715 1,1 0,0.552285 -0.447715,1 -1,1 -0.552285,0 -1,-0.447715 -1,-1 0,-0.552285
0.447715,-1 1,-1 z"
+ id="rect6086" />
+ </g>
+</svg>
diff --git a/data/icons/route-pedestrian-symbolic.svg b/data/icons/route-pedestrian-symbolic.svg
new file mode 100644
index 0000000..7317b86
--- /dev/null
+++ b/data/icons/route-pedestrian-symbolic.svg
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16px"
+ height="16px"
+ id="svg6558"
+ version="1.1"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="New document 18">
+ <defs
+ id="defs6560" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="22.197802"
+ inkscape:cx="9.2245257"
+ inkscape:cy="9.6312031"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:snap-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:window-width="1600"
+ inkscape:window-height="841"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid7232" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata6563">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+
style="color:#000000;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="M 5.7191343,5.0308108 3.96875,7.03125 3.0625,9.6875 c -0.2635754,0.511148 0.016909,1.224387
0.5625,1.40625 0.545591,0.181864 1.2166716,-0.214187 1.3125,-0.78125 L 5.71875,8.0625 6,7.75 6,13.25 4.375,15
5.875,16.375 8,14.03125 8,11.90625 10.09375,16 11.875,15.09375 9,9.40625 9,7.65625 11.34375,9.75 c
0.383224,0.3968 1.108768,0.37896 1.472028,-0.03619 C 13.179038,9.298651 13.100409,8.5771604 12.65625,8.25 L
9,5 z"
+ id="rect7046"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccscccccccccccccsccc" />
+ <path
+ sodipodi:type="arc"
+
style="color:#000000;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ id="path6214"
+ sodipodi:cx="9.1592426"
+ sodipodi:cy="5.4265437"
+ sodipodi:rx="2.4638252"
+ sodipodi:ry="2.4638252"
+ d="m 11.623068,5.4265437 a 2.4638252,2.4638252 0 1 1 -4.9276506,0 2.4638252,2.4638252 0 1 1
4.9276506,0 z"
+ transform="matrix(0.81174588,0,0,0.8117459,0.5650225,-2.4049746)" />
+ </g>
+</svg>
diff --git a/data/icons/route-transit-symbolic.svg b/data/icons/route-transit-symbolic.svg
new file mode 100644
index 0000000..05a49d5
--- /dev/null
+++ b/data/icons/route-transit-symbolic.svg
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16px"
+ height="16px"
+ id="svg6558"
+ version="1.1"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="route-driving-symbolic.svg">
+ <defs
+ id="defs6560" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="15.696216"
+ inkscape:cx="5.7511062"
+ inkscape:cy="13.453719"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:snap-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:window-width="1600"
+ inkscape:window-height="841"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid7232" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata6563">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+
style="color:#000000;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+ d="M 1.9375,1 C 1.418125,1 1,1.418125 1,1.9375 L 1,14.90625 C 1,15.512187 1.487812,16 2.09375,16 l
0.8125,0 C 3.512188,16 4,15.512187 4,14.90625 L 4,14 l 8,0 0,0.90625 C 12,15.512187 12.487812,16 13.09375,16
l 0.8125,0 C 14.512188,16 15,15.512187 15,14.90625 L 15,1.9375 C 15,1.418125 14.581875,1 14.0625,1 z m
1.15625,1 9.8125,0 C 13.512188,2 14,2.4878125 14,3.09375 l 0,4.8125 C 14,8.5121875 13.512188,9 12.90625,9 L
3.09375,9 C 2.487812,9 2,8.5121875 2,7.90625 L 2,3.09375 C 2,2.4878125 2.487812,2 3.09375,2 z M 3.5,10 C
4.328427,10 5,10.671573 5,11.5 5,12.328427 4.328427,13 3.5,13 2.671573,13 2,12.328427 2,11.5 2,10.671573
2.671573,10 3.5,10 z m 9,0 C 13.328427,10 14,10.671573 14,11.5 14,12.328427 13.328427,13 12.5,13 11.671573,13
11,12.328427 11,11.5 11,10.671573 11.671573,10 12.5,10 z"
+ id="rect6086-1"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="sccsssccsssccsssssssssssssssssssss" />
+ </g>
+</svg>
diff --git a/src/application.js b/src/application.js
index 01cb7a1..ef4aac3 100644
--- a/src/application.js
+++ b/src/application.js
@@ -35,6 +35,7 @@ const GLib = imports.gi.GLib;
const Main = imports.main;
const Format = imports.format;
const Geoclue = imports.geoclue;
+// const GeocodeService = imports.geocode;
const MainWindow = imports.mainWindow;
const Notification = imports.notification;
const NotificationManager = imports.notificationManager;
@@ -51,6 +52,7 @@ let placeStore = null;
let notificationManager = null;
let routeService = null;
let geoclue = null;
+let geocodeService = null;
const Application = new Lang.Class({
Name: 'Application',
@@ -97,10 +99,8 @@ const Application = new Lang.Class({
Utils.loadStyleSheet(Gio.file_new_for_uri('resource:///org/gnome/maps/application.css'));
application = this;
- settings = new Settings.Settings('org.gnome.maps');
- routeService = new RouteService.GraphHopper();
- geoclue = new Geoclue.Geoclue();
-
+ this._initServices();
+
Utils.initActions(this, [{
properties: { name: 'quit' },
signalHandlers: { activate: this._onQuitActivate }
@@ -109,6 +109,13 @@ const Application = new Lang.Class({
this._initPlaceStore();
this._initAppMenu();
},
+
+ _initServices: function() {
+ settings = new Settings.Settings('org.gnome.maps');
+ routeService = new RouteService.GraphHopper();
+ geoclue = new Geoclue.Geoclue();
+ geocodeService = new GeocodeService.GeocodeService();
+ },
_createWindow: function() {
if (this._mainWindow)
diff --git a/src/geocodeService.js b/src/geocodeService.js
new file mode 100644
index 0000000..6b857b9
--- /dev/null
+++ b/src/geocodeService.js
@@ -0,0 +1,56 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2014 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 Lang = imports.lang;
+
+const Application = imports.application;
+
+const GeocodeService = new Lang.Class({
+ Name: 'GeocodeService',
+
+ _init: function() { },
+
+ search: function(string, bbox, callback) {
+ let answerCount = Application.settings.get('max-search-results');
+ let forward = Geocode.Forward.new_for_string(string);
+
+ if(bbox) {
+ forward.search_area = new Geocode.BoundingBox({
+ top: bbox.top,
+ left: bbox.left,
+ bottom: bbox.bottom,
+ right: bbox.right
+ });
+ }
+ forward.bounded = false;
+ forward.set_answer_count(answerCount);
+ forward.search_async(null, function(forward, res) {
+ try {
+ let places = forward.search_finish(res);
+ callback(places);
+ } catch (e) {
+ callback(null);
+ }
+ });
+ }
+});
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
index 9c5598c..5a24857 100644
--- a/src/gnome-maps.js.gresource.xml
+++ b/src/gnome-maps.js.gresource.xml
@@ -6,6 +6,7 @@
<file>contextMenu.js</file>
<file>epaf.js</file>
<file>geoclue.js</file>
+ <file>geocodeService.js</file>
<file>http.js</file>
<file>layersPopover.js</file>
<file>main.js</file>
diff --git a/src/main-window.ui b/src/main-window.ui
index bea1340..6832b53 100644
--- a/src/main-window.ui
+++ b/src/main-window.ui
@@ -81,16 +81,27 @@
</child>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkGrid" id="main-grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <!-- <property name="margin_left">7</property> -->
- <!-- <property name="margin_right">7</property> -->
- <property name="orientation">horizontal</property>
- <!-- <property name="row_spacing">10</property> -->
+ <child>
+ <object class="GtkToggleButton" id="toggle-sidebar-button">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="valign">center</property>
+ <property name="action-name">win.toggle-sidebar</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="toggle-sidebar-button-image">
+ <property name="visible">True</property>
+ <property name="icon-size">1</property>
+ <property name="icon-name">route-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index f4c262c..bbd4720 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -62,12 +62,12 @@ const MainWindow = new Lang.Class({
this.window = ui.appWindow;
this.window.application = app;
this._placeStore = Application.placeStore;
+
this._overlay = overlay;
+ ui.appWindow.add(this._overlay);
- ui.mainGrid.add(this._overlay);
- let sidebar = new Sidebar.Sidebar();
- ui.mainGrid.add(sidebar);
- sidebar.reveal_child = true;
+ this._sidebar = new Sidebar.Sidebar();
+ overlay.add_overlay(this._sidebar);
this.mapView = new MapView.MapView();
overlay.add(this.mapView);
@@ -152,13 +152,21 @@ const MainWindow = new Lang.Class({
}, {
properties: { name: 'goto-user-location' },
signalHandlers: { activate: this._onGotoUserLocationActivate }
+ }, {
+ properties: {
+ name: 'toggle-sidebar',
+ state: GLib.Variant.new('b', false)
+ },
+ signalHandlers: { activate: this._onToggleSidebarActivate }
}
], this);
let action = this.window.lookup_action('goto-user-location');
Application.geoclue.bind_property('connected',
- action, 'enabled',
+ action,
+ 'enabled',
GObject.BindingFlags.SYNC_CREATE);
+
},
_initSignals: function() {
@@ -309,6 +317,12 @@ const MainWindow = new Lang.Class({
let [mapType, len] = value.get_string();
this.mapView.setMapType(MapView.MapType[mapType]);
},
+
+ _onToggleSidebarActivate: function(action) {
+ let newState = !action.get_state().get_boolean();
+ action.set_state(GLib.Variant.new('b', newState));
+ this._sidebar.set_reveal_child(newState);
+ },
_onAboutActivate: function() {
let aboutDialog = new Gtk.AboutDialog({
diff --git a/src/sidebar.js b/src/sidebar.js
index 07d9b73..99f5e4f 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -25,9 +25,11 @@ const Lang = imports.lang;
const Gtk = imports.gi.Gtk;
const GLib = imports.gi.GLib;
+const Application = imports.application;
+const PlaceStore = imports.placeStore;
+const SearchPopup = imports.searchPopup;
const Utils = imports.utils;
-
const Sidebar = new Lang.Class({
Name: 'Sidebar',
Extends: Gtk.Revealer,
@@ -35,12 +37,10 @@ const Sidebar = new Lang.Class({
_init: function() {
this.parent({ name: "sidebar",
visible: true,
- width_request: 100,
transition_type: Gtk.RevealerTransitionType.SLIDE_LEFT,
transition_duration: 400,
- vexpand: true,
- hexpand: false,
- halign: Gtk.Align.START
+ halign: Gtk.Align.END,
+ valign: Gtk.Align.FILL
});
this._ui = Utils.getUIObject('sidebar', [ 'form',
'instruction-list-scrolled',
@@ -53,11 +53,83 @@ const Sidebar = new Lang.Class({
'mode-bike-toggle',
'mode-car-toggle']);
- // this._ui.instructionList.connect('row-activated', (function(list, row) {
- // this.emit('instruction-selected', row.instruction);
- // }).bind(this));
+ this._ui.instructionList.connect('row-activated', (function(list, row) {
+ this.emit('instruction-selected', row.instruction);
+ }).bind(this));
+
+ this._initCompletion(this._ui.toCompletion);
+ this._initCompletion(this._ui.fromCompletion);
+
+ this._initSearchEntries();
this.add(this._ui.form);
- this.add(this._ui.instructionListScrolled);
+ },
+
+ _initCompletion: function(completion) {
+ completion.model = Application.placeStore;
+ completion.set_match_func(PlaceStore.completionMatchFunc);
+ completion.connect('match-selected',
+ this._onPlaceSelected.bind(this));
+ },
+
+ _initSearchEntries: function() {
+ this._fromPopover = new SearchPopup.SearchPopup(this._ui.fromEntry, 5);
+ this._fromPopover.connect('selected',
+ this._onSearchPopupSelected.bind(this));
+ this._ui.fromEntry.connect('activate', this._onSearchActivate.bind(this));
+
+ this._toPopover = new SearchPopup.SearchPopup(this._ui.toEntry, 5);
+ this._toPopover.connect('selected',
+ this._onSearchPopupSelected.bind(this));
+ this._ui.toEntry.connect('activate', this._onSearchActivate.bind(this));
+ },
+
+ _onPlaceSelected: function(completion, model, iter) {
+ let entry;
+ let place = model.get_value(iter, PlaceStore.Columns.PLACE);
+
+ if (completion === this._ui.fromCompletion) {
+ entry = this._ui.fromEntry;
+ this._fromPlace = place;
+ } else {
+ entry = this._ui.toEntry;
+ this._toPlace = place;
+ }
+ entry.text = place.name;
+
+ return true;
+ },
+
+ _onSearchPopupSelected: function(popover, place) {
+ let entry;
+
+ if (popover === this._fromPopover) {
+ entry = this._ui.fromEntry;
+ this._fromPlace = place;
+ } else {
+ entry = this._ui.toEntry;
+ this._toPlace = place;
+ }
+ entry.text = place.name;
+ popover.hide();
+ },
+
+ _onSearchActivate: function(entry) {
+ let searchString = entry.get_text();
+
+ if (searchString.length > 0) {
+ let popover = (entry === this._ui.toEntry)
+ ? this._toPopover
+ : this._fromPopover;
+
+ popover.showSpinner();
+ Application.geocodeService.search(searchString, null, function(places) {
+ if (places === null)
+ popover.hide();
+
+ popover.update(places, searchString);
+ popover.showResult();
+ });
+ }
}
});
diff --git a/src/sidebar.ui b/src/sidebar.ui
new file mode 100644
index 0000000..c17e6ea
--- /dev/null
+++ b/src/sidebar.ui
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <object class="GtkEntryCompletion" id="from-completion">
+ <property name="minimum_key_length">2</property>
+ <child>
+ <object class="GtkCellRendererPixbuf" id="from-icon-cell-renderer">
+ <property name="xpad">2</property>
+ </object>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText" id="from-text-cell-renderer">
+ <property name="ypad">4</property>
+ </object>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ <object class="GtkEntryCompletion" id="to-completion">
+ <property name="minimum_key_length">2</property>
+ <child>
+ <object class="GtkCellRendererPixbuf" id="to-icon-cell-renderer">
+ <property name="xpad">2</property>
+ </object>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText" id="to-text-cell-renderer">
+ <property name="ypad">4</property>
+ </object>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ <object class="GtkGrid" id="form">
+ <property name="name">sidebar-form</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">7</property>
+ <property name="margin_right">7</property>
+ <property name="margin_top">10</property>
+ <property name="margin_bottom">10</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="row_spacing">10</property>
+ <child>
+ <object class="GtkBox" id="mode">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkRadioButton" id="mode-pedestrian-toggle">
+ <property name="name">mode-pedestrian-toggle</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="xalign">0.5</property>
+ <property name="draw_indicator">False</property>
+ <child>
+ <object class="GtkImage" id="mode-pedestrian-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">route-pedestrian-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="transportation-mode-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="mode-bike-toggle">
+ <property name="name">mode-bike-toggle</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="xalign">0.5</property>
+ <property name="draw_indicator">False</property>
+ <property name="group">mode-pedestrian-toggle</property>
+ <child>
+ <object class="GtkImage" id="mode-bike-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">route-bike-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="transportation-mode-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="mode-car-toggle">
+ <property name="name">mode-car-toggle</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="xalign">0.5</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">False</property>
+ <property name="group">mode-pedestrian-toggle</property>
+ <child>
+ <object class="GtkImage" id="mode-car-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="pixbuf">route-car-symbolic</property>
+ </object>
+ </child>
+ <style>
+ <class name="transportation-mode-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="to-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">To</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="to-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="completion">to-completion</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="from-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="completion">from-completion</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="from-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">From</property>
+ <property name="ellipsize">end</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="instruction-list-scrolled">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkListBox" id="instruction-list">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]