[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: Mon, 9 Jun 2014 01:16:02 +0000 (UTC)
commit 0f6173148e9f386f6d86a007512f5b74e6fc536d
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Mon Jun 9 03:15:14 2014 +0200
More sidebar work
src/mainWindow.js | 16 ++++++----------
src/sidebar.js | 37 +++++++++++++++++++++++--------------
src/sidebar.ui | 30 +++++-------------------------
3 files changed, 34 insertions(+), 49 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 0ba6ea8..afe465e 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -70,7 +70,7 @@ const MainWindow = new Lang.Class({
this._sidebar = new Sidebar.Sidebar();
overlay.add_overlay(this._sidebar);
Application.routeService.route.connect('update',
- this._showSidebar.bind(this));
+ this._setRevealSidebar.bind(this, true));
this.mapView = new MapView.MapView();
overlay.add(this.mapView);
@@ -312,19 +312,15 @@ const MainWindow = new Lang.Class({
let reveal = variant.get_boolean();
if(!reveal) {
Application.routeService.route.reset();
- // Application.routeService.query.reset();
+ Application.routeService.query.reset();
}
this._sidebar.set_reveal_child(reveal);
},
- _hideSidebar: function() {
- let action = this.window.lookup_action('toggle-sidebar');
- action.change_state(GLib.Variant.new_boolean(false));
- },
-
- _showSidebar: function() {
- let action = this.window.lookup_action('toggle-sidebar');
- action.change_state(GLib.Variant.new_boolean(true));
+ _setRevealSidebar: function(value) {
+ this.window
+ .lookup_action('toggle-sidebar')
+ .change_state(GLib.Variant.new_boolean(value));
},
_onAboutActivate: function() {
diff --git a/src/sidebar.js b/src/sidebar.js
index b0cfb90..7219012 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -55,12 +55,11 @@ const Sidebar = new Lang.Class({
'mode-car-toggle']);
this._instructionList = ui.instructionList;
this._initInstructionList();
-
- this._initModeToggle({ "PEDESTRIAN": ui.modePedestrianToggle,
- "BIKE": ui.modeBikeToggle,
- "CAR": ui.modeCarToggle
- });
-
+
+ this._initTransportationToggles(ui.modePedestrianToggle,
+ ui.modeBikeToggle,
+ ui.modeCarToggle);
+
ui.grid.attach(this._createEntry("from", ui.fromCompletion),
1, 0, 1, 1);
ui.grid.attach(this._createEntry("to", ui.toCompletion),
@@ -68,13 +67,23 @@ const Sidebar = new Lang.Class({
this.add(ui.grid);
},
- _initModeToggle: function(toggles) {
- for(let mode in toggles) {
- toggles[mode].connect('toggled', function(button) {
- if (button.active)
- Application.routeService.query.transportation = mode;
- });
- }
+ _initTransportationToggles: function(pedestrian, bike, car) {
+ let query = Application.routeService.query;
+ let transport = RouteQuery.Transportation;
+
+ let onToggle = function(mode, button) {
+ 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));
+
+ query.connect('updated', function() {
+ pedestrian.active = query.transportation === transport.PEDESTRIAN;
+ car.active = query.transportation === transport.CAR;
+ bike.active = query.transportation === transport.BIKE;
+ });
},
_createEntry: function(propName, completion) {
@@ -129,7 +138,7 @@ const PlaceEntry = new Lang.Class({
set place(p) {
this._place = p;
- this.text = p.name;
+ this.text = p ? p.name : "";
this.notify("place");
},
get place() {
diff --git a/src/sidebar.ui b/src/sidebar.ui
index 7b4900b..ec37c5f 100644
--- a/src/sidebar.ui
+++ b/src/sidebar.ui
@@ -49,10 +49,11 @@
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="vexpand">True</property>
+ <property name="valign">fill</property>
<property name="orientation">vertical</property>
<property name="row_spacing">10</property>
<child>
- <object class="GtkBox" id="mode">
+ <object class="GtkBox" id="mode-chooser">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
@@ -157,30 +158,6 @@
<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>
@@ -198,10 +175,13 @@
<object class="GtkScrolledWindow" id="instruction-list-scrolled">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="valign">fill</property>
+ <property name="vexpand">True</property>
<child>
<object class="GtkListBox" id="instruction-list">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="valign">fill</property>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]