[gnome-maps/wip/routing: 2/2] WIP Add sidebar support
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/routing: 2/2] WIP Add sidebar support
- Date: Sat, 7 Sep 2013 16:18:51 +0000 (UTC)
commit a65c046b7baeac862febee564a5b3842c17d9c6c
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Sat Sep 7 11:40:11 2013 +0200
WIP Add sidebar support
data/icons/Makefile.am | 6 +
data/icons/route-car-symbolic.svg | 67 +++++++++
data/icons/route-pedestrian-symbolic.svg | 78 +++++++++++
data/icons/route-transit-symbolic.svg | 68 ++++++++++
src/gnome-maps.gresource.xml | 16 +++
src/mainWindow.js | 3 +
src/mapView.js | 10 +-
src/routeService.js | 4 +-
src/sidebar.js | 189 +++++++++++++++++++--------
src/sidebar.ui | 214 ++++++++++++++++++++++++++++++
10 files changed, 596 insertions(+), 59 deletions(-)
---
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index 55493aa..bc28ae7 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -1,3 +1,6 @@
+# -*- indent-tabs-mode: nil; tab-width: 4 -*-
+# vim: set et ts=4 sw=4: */
+
NULL =
public_icons_themes = \
@@ -17,6 +20,9 @@ imagesdir = $(datadir)/gnome-maps/pixmaps
images_DATA = \
bubble.svg \
pin.svg \
+ route-car-symbolic.svg \
+ route-transit-symbolic.svg \
+ route-pedestrian-symbolic.svg \
$(NULL)
noinst_DATA = \
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/gnome-maps.gresource.xml b/src/gnome-maps.gresource.xml
index d30b5eb..1b91ec1 100644
--- a/src/gnome-maps.gresource.xml
+++ b/src/gnome-maps.gresource.xml
@@ -7,10 +7,26 @@
<file preprocess="xml-stripblanks">search-popup.ui</file>
<file preprocess="xml-stripblanks">context-menu.ui</file>
<file preprocess="xml-stripblanks">map-location.ui</file>
+ <file preprocess="xml-stripblanks">sidebar.ui</file>
+ <file preprocess="xml-stripblanks"
+ alias="route-pedestrian-symbolic">../data/icons/route-pedestrian-symbolic.svg</file>
+ <file preprocess="xml-stripblanks"
+ alias="route-bike-symbolic">../data/icons/route-transit-symbolic.svg</file>
+ <file preprocess="xml-stripblanks"
+ alias="route-car-symbolic">../data/icons/route-car-symbolic.svg</file>
<file alias="application.css">../data/gnome-maps.css</file>
<file alias="zoom-in.png">../data/media/zoom-in.png</file>
<file alias="zoom-out.png">../data/media/zoom-out.png</file>
<file alias="zoom-in-insensitive.png">../data/media/zoom-in-insensitive.png</file>
<file alias="zoom-out-insensitive.png">../data/media/zoom-out-insensitive.png</file>
+ <file alias="direction-left">../data/icons/direction-left.png</file>
+ <file alias="direction-right">../data/icons/direction-right.png</file>
+ <file alias="direction-roundabout">../data/icons/direction-roundabout.png</file>
+ <file alias="direction-sharpleft">../data/icons/direction-sharpleft.png</file>
+ <file alias="direction-sharpright">../data/icons/direction-sharpright.png</file>
+ <file alias="direction-slightleft">../data/icons/direction-slightleft.png</file>
+ <file alias="direction-slightright">../data/icons/direction-slightright.png</file>
+ <file alias="direction-continue">../data/icons/direction-continue.png</file>
+ <file alias="direction-uturn">../data/icons/direction-uturn.png</file>
</gresource>
</gresources>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d2abb80..994761d 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -125,6 +125,9 @@ const MainWindow = new Lang.Class({
}, {
properties: { name: 'goto-user-location' },
signalHandlers: { activate: this._onGotoUserLocationActivate }
+ }, {
+ properties: { name: 'route-mode-close' },
+ signalHandlers: { activate: this.mapView.routeModeClose.bind(this.mapView) }
}
], this);
},
diff --git a/src/mapView.js b/src/mapView.js
index fd762cf..1709571 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -69,8 +69,7 @@ const MapView = new Lang.Class({
this.view.connect('notify::longitude', this._onViewMoved.bind(this));
this._sidebar = new Sidebar.Sidebar(this);
- // Don't show sidebar until it has something in it
- //this.view.add_child(this._sidebar.actor);
+ this.view.add_child(this._sidebar.actor);
this._routeLayer = new Champlain.PathLayer();
this._routeLayer.set_stroke_width(2.0);
@@ -180,11 +179,18 @@ const MapView = new Lang.Class({
this.showRoute.bind(this));
},
+ routeModeClose: function() {
+ this._routeLayer.remove_all();
+ this._sidebar.close();
+ },
+
showRoute: function(route) {
+ this._sidebar.open();
this._routeLayer.remove_all();
route.coordinates.forEach(function(coordinate) {
this._routeLayer.add_node(coordinate);
}, this);
+ this._sidebar.addInstructions(route.instructions);
this.view.ensure_visible(route.bbox, true);
},
diff --git a/src/routeService.js b/src/routeService.js
index 1562cae..d192f1f 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -105,7 +105,7 @@ const GraphHopper = new Lang.Class({
_parseResult: function(result) {
let route = JSON.parse(result).route,
directions = this._createDirections(route.instructions.indications),
- instructions = this._createInstructions(route.instructions.indications,
+ instructions = this._createInstructions(directions,
route.instructions.descriptions,
route.instructions.distances),
bbox = new Champlain.BoundingBox();
@@ -113,7 +113,7 @@ const GraphHopper = new Lang.Class({
// GH does lonlat-order and Champlain latlon-order
bbox.extend(route.bbox[1], route.bbox[0]);
bbox.extend(route.bbox[3], route.bbox[2]);
-
+ log(JSON.stringify(instructions));
return new Route.Route({ coordinates: Polyline.decode(route.coordinates),
instructions: instructions,
distance: route.distance,
diff --git a/src/sidebar.js b/src/sidebar.js
index b9d873e..bcd0a90 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -30,71 +30,150 @@ const MapView = imports.mapView;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
+const Signals = imports.signals;
+const Route = imports.route;
const Utils = imports.utils;
const _ = imports.gettext.gettext;
+const isRTL = Gtk.Widget.get_default_direction() === Gtk.TextDirection.RTL;
+
+const Icon = {
+ prev: isRTL ? 'go-previous-rtl-symbolic' : 'go-previous-symbolic',
+ next: isRTL ? 'go-next-rtl-symbolic' : 'go-next-symbolic'
+};
+
const Sidebar = new Lang.Class({
Name: 'Sidebar',
- _init: function(mapView) {
- this._mapView = mapView;
- this.actor = new Clutter.Actor({ layout_manager: new Clutter.BoxLayout({ spacing: 12 }),
- y_expand: true,
- x_align: Clutter.ActorAlign.END });
-
- let isRtl = (Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL);
- let prevIconName = isRtl ? 'go-previous-rtl-symbolic' : 'go-previous-symbolic';
- let nextIconName = isRtl ? 'go-next-rtl-symbolic' : 'go-next-symbolic';
-
- // create the button
- let revealImage = new Gtk.Image ({ icon_name: prevIconName,
- icon_size: Gtk.IconSize.MENU });
- let revealButton = new Gtk.Button({ child: revealImage,
- valign: Gtk.Align.CENTER });
- revealButton.get_style_context().add_class('osd');
- revealButton.show();
-
- // then the sidebar itself, packed into the revealer
- let grid = new Gtk.Grid({ vexpand: true,
- hexpand: true,
- margin_top: 32,
- margin_left: 32,
- margin_right: 32,
- row_spacing: 15,
- orientation: Gtk.Orientation.VERTICAL,
- valign: Gtk.Align.FILL });
-
- let container = new Gtk.Frame({ child: grid,
- shadow_type: Gtk.ShadowType.IN,
- width_request: 200 });
- container.get_style_context().add_class('maps-sidebar');
-
- let revealer = new Gtk.Revealer({ child: container,
- reveal_child: false,
- transition_type: Gtk.RevealerTransitionType.CROSSFADE });
- revealer.show_all();
-
- revealButton.connect('clicked', (function() {
- if (revealer.reveal_child) {
- revealer.reveal_child = false;
- revealButton.symbolic_icon_name = prevIconName;
- } else {
- revealer.reveal_child = true;
- revealButton.symbolic_icon_name = nextIconName;
- }
+ _init: function() {
+ this._ui = Utils.getUIObject('sidebar', ['sidebar',
+ 'instructions-list',
+ 'revealer',
+ 'reveal-button',
+ 'reveal-image']);
+ this._ui.revealButton.connect('clicked', this.toggle.bind(this));
+ this._ui.revealer.show_all();
+ this._ui.instructionsList.connect('row-activated', (function(box, row) {
+ this.emit('instruction-clicked', row.instruction);
}).bind(this));
- // now create actors
- let buttonActor = new GtkClutter.Actor({ contents: revealButton,
- x_align: Clutter.ActorAlign.END });
+ this.actor = this._createActor();
+ this.actor.hide();
+ this.conceal();
+ },
+
+ _createActor: function() {
+ let actor = new Clutter.Actor({
+ layout_manager: new Clutter.BoxLayout({ spacing: 12 }),
+ y_expand: true,
+ x_align: Clutter.ActorAlign.END
+ });
+
+ let buttonActor = new GtkClutter.Actor({
+ contents: this._ui.revealButton,
+ x_align: Clutter.ActorAlign.END
+ });
Utils.clearGtkClutterActorBg(buttonActor);
- this.actor.add_child(buttonActor);
- let revealerActor = new GtkClutter.Actor({ contents: revealer,
- x_align: Clutter.ActorAlign.END,
- x_expand: true,
- y_expand: true });
- this.actor.add_child(revealerActor);
+ let revealerActor = new GtkClutter.Actor({
+ contents: this._ui.revealer,
+ x_align: Clutter.ActorAlign.END,
+ x_expand: true,
+ y_expand: true
+ });
+
+ actor.add_child(buttonActor);
+ actor.add_child(revealerActor);
+
+ return actor;
+ },
+
+ addInstructions: function(instructions) {
+ instructions.forEach(this.addInstruction.bind(this));
+ },
+ addInstruction: function(instruction) {
+ this._ui.instructionsList.add(new InstructionRow(instruction, {
+ visible: true
+ }));
+ },
+
+ reveal: function() {
+ this._ui.revealer.reveal_child = true;
+ this._ui.revealImage.icon_name = Icon.next;
+ },
+
+ conceal: function() {
+ this._ui.revealer.reveal_child = false;
+ this._ui.revealImage.icon_name = Icon.prev;
+ },
+
+ toggle: function() {
+ if(this.isRevealed())
+ this.conceal();
+ else
+ this.reveal();
+ },
+
+ close: function() {
+ this.conceal();
+ this.actor.hide();
+ },
+
+ open: function() {
+ this.actor.show();
+ this.reveal();
+ },
+
+ isRevealed: function() {
+ return this._ui.revealer.reveal_child;
}
});
+Signals.addSignalMethods(Sidebar.prototype);
+
+const InstructionRow = new Lang.Class({
+ Name: "InstructionRow",
+ Extends: Gtk.ListBoxRow,
+
+ _init: function(instruction, props) {
+ this.parent();
+
+ this.instruction = instruction;
+ this.visible = true;
+ Lang.copyPropertiesNoOverwrite(props, this);
+
+ let box = new Gtk.Box({
+ visible: true,
+ can_focus: false
+ });
+ box.add(createDirectionIcon(instruction.direction));
+ box.add(new Gtk.Label({
+ visible: true,
+ can_focus: false,
+ label: instruction.description
+ }));
+ this.add(box);
+ }
+
+});
+
+function createDirectionIcon(direction) {
+ let res,
+ dir = Route.Direction;
+ switch(direction) {
+ case dir.LEFT: res = 'direction-left'; break;
+ case dir.SHARP_LEFT: res = 'direction-sharpleft'; break;
+ case dir.SLIGHT_LEFT: res = 'direction-slightleft'; break;
+ case dir.RIGHT: res = 'direction-right'; break;
+ case dir.SHARP_RIGHT: res = 'direction-sharpright'; break;
+ case dir.SLIGHT_RIGHT: res = 'direction-slightright'; break;
+ case dir.CONTINUE: res = 'direction-continue'; break;
+ case dir.U_TURN: res = 'direction-uturn'; break;
+ case dir.ROUNDABOUT: res = 'direction-roundabout'; break;
+ }
+ log("Direction: " + direction + ", res: " + res);
+ return new Gtk.Image({ visible: true,
+ can_focus: false,
+ icon_size: 1,
+ pixbuf: res });
+}
diff --git a/src/sidebar.ui b/src/sidebar.ui
new file mode 100644
index 0000000..623ce01
--- /dev/null
+++ b/src/sidebar.ui
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.15.2 on Sat Sep 7 13:09:44 2013 -->
+<interface>
+ <!-- interface-requires gtk+ 3.10 -->
+ <object class="GtkImage" id="close-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">window-close-symbolic</property>
+ <property name="icon_size">1</property>
+ </object>
+ <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>
+ <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>
+ <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>
+ <object class="GtkImage" id="reveal-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_size">1</property>
+ </object>
+ <object class="GtkButton" id="reveal-button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">False</property>
+ <property name="valign">center</property>
+ <property name="image">reveal-image</property>
+ <style>
+ <class name="osd"/>
+ </style>
+ </object>
+ <object class="GtkRevealer" id="revealer">
+ <property name="can_focus">False</property>
+ <property name="transition_type">slide-right</property>
+ <child>
+ <object class="GtkFrame" id="sidebar">
+ <property name="width_request">200</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">1</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">32</property>
+ <property name="margin_right">32</property>
+ <property name="margin_top">32</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="row_spacing">15</property>
+ <style>
+ <class name="maps-sidebar"/>
+ </style>
+ <child>
+ <object class="GtkButtonBox" id="mode">
+ <property name="width_request">20</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="spacing">3</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkToggleButton" id="mode-pedestrian-toggle">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">mode-pedestrian-image</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="mode-bike-toggle">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">mode-bike-image</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="mode-car-toggle">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">mode-car-image</property>
+ <property name="active">True</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">2</property>
+ <property name="height">1</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="margin_right">15</property>
+ <property name="label" translatable="yes">To</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="to-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</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="margin_right">15</property>
+ <property name="label" translatable="yes">From</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="from-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="valign">end</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">2</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkListBox" id="instructions-list">
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkButton" id="close-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">win.route-mode-close</property>
+ <property name="image">close-image</property>
+ <property name="relief">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]