[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: Tue, 3 Jun 2014 00:03:33 +0000 (UTC)
commit ef3291085e758c772370b501db110a07096700cd
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Tue Jun 3 02:03:15 2014 +0200
more sidebar work
src/mapLocation.js | 16 +++++++++++-----
src/routeQuery.js | 48 +++++++++++++++++++++++++++++++++++++++++-------
src/routeService.js | 7 ++++---
src/sidebar.js | 40 ++++++++++++++++------------------------
4 files changed, 72 insertions(+), 39 deletions(-)
---
diff --git a/src/mapLocation.js b/src/mapLocation.js
index 615d0b7..8cd406f 100644
--- a/src/mapLocation.js
+++ b/src/mapLocation.js
@@ -54,7 +54,7 @@ const MapLocation = new Lang.Class({
} else {
this.bbox = null;
}
-
+ this.name = place.name;
this._mapView = mapView;
this._view = mapView.view;
this.latitude = place.location.latitude;
@@ -136,10 +136,16 @@ const MapLocation = new Lang.Class({
},
_onHereButtonClicked: function() {
- let to = new Geocode.Location({ latitude: this.latitude,
- longitude: this.longitude
- });
- Application.routeService.query.setMany({ from: Application.geoclue.location,
+ let to = Geocode.Place.new_with_location(this.name,
+ this.type,
+ new Geocode.Location({ latitude: this.latitude,
+ longitude: this.longitude
+ }));
+ let from = Geocode.Place.new_with_location("Current location",
+ Geocode.PlaceType.UNKNOWN,
+ Application.geoclue.location);
+
+ Application.routeService.query.setMany({ from: from,
to: to
});
},
diff --git a/src/routeQuery.js b/src/routeQuery.js
index fd02f8b..df2912f 100644
--- a/src/routeQuery.js
+++ b/src/routeQuery.js
@@ -45,6 +45,9 @@ const Transportation = {
const RouteQuery = new Lang.Class({
Name: 'RouteQuery',
Extends: GObject.Object,
+ Signals: {
+ 'updated': { }
+ },
Properties: {
'from': GObject.ParamSpec.object('from',
'',
@@ -68,13 +71,46 @@ const RouteQuery = new Lang.Class({
Transportation.CAR)
},
+ set from(place) {
+ this._from = place;
+ this.notify("from");
+ },
+ get from() {
+ return this._from;
+ },
+
+ set to(place) {
+ this._to = place;
+ this.notify("to");
+ },
+ get to() {
+ return this._to;
+ },
+
+ set transportation(t) {
+ this._transportation = t;
+ this.notify("transportation");
+ },
+ get transportation() {
+ return this._transportation;
+ },
+
_init: function(args) {
this.parent(args);
- this._changeSignalId = this.connect('notify',
- this.emit.bind(this, 'change'));
+ this._connectSignals();
this.reset();
},
+
+ _connectSignals: function() {
+ this._updatedId = this.connect('notify', (function() {
+ this.emit('updated');
+ }).bind(this));
+ },
+ _disconnectSignals: function() {
+ this.disconnect(this._updatedId);
+ },
+
reset: function() {
this.setMany({ from: null,
to: null,
@@ -82,7 +118,7 @@ const RouteQuery = new Lang.Class({
},
setMany: function(obj) {
- this.disconnect(this._changeSignalId);
+ this._disconnectSignals();
// Only set properties actually defined on this object
["from", "to", "transportation"].forEach((function(prop) {
@@ -90,9 +126,8 @@ const RouteQuery = new Lang.Class({
this[prop] = obj[prop];
}).bind(this));
- this._changeSignalId = this.connect('notify',
- this.emit.bind(this, 'change'));
- this.emit('change');
+ this._connectSignals();
+ this.emit('updated');
},
toString: function() {
@@ -101,4 +136,3 @@ const RouteQuery = new Lang.Class({
"\nTransportation" + this.transportation;
}
});
-Utils.addSignalMethods(RouteQuery.prototype);
diff --git a/src/routeService.js b/src/routeService.js
index 0bcb129..75a7177 100644
--- a/src/routeService.js
+++ b/src/routeService.js
@@ -53,14 +53,15 @@ const GraphHopper = new Lang.Class({
this._route = new Route.Route();
this._query = new RouteQuery.RouteQuery();
- this.query.connect('change', (function() {
+ this.query.connect('updated', (function() {
if(this.query.from && this.query.to) {
- this.fetchRoute([this.query.from, this.query.to],
+ this.fetchRoute([this.query.from.location,
+ this.query.to.location],
this.query.transportation);
} else
this.route.reset();
}).bind(this));
-
+
this.parent();
},
diff --git a/src/sidebar.js b/src/sidebar.js
index 003eeda..ba4462c 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -81,36 +81,31 @@ const PlaceEntry = new Lang.Class({
Name: 'PlaceEntry',
Extends: Gtk.Entry,
Properties: {
- place: GObject.ParamSpec.object('place',
- '',
- '',
- GObject.ParamFlags.READABLE |
- GObject.ParamFlags.WRITABLE,
- Geocode.Place)
+ 'place': GObject.ParamSpec.object('place',
+ '',
+ '',
+ GObject.ParamFlags.READABLE |
+ GObject.ParamFlags.WRITABLE,
+ Geocode.Place)
+ },
+
+ set place(p) {
+ this._place = p;
+ this.text = p.name;
+ this.notify("place");
+ },
+ get place() {
+ return this._place;
},
_init: function(props) {
this.parent(props);
- // this.bind_property_full_with_closures("place",
- // this, "text",
- // GObject.BindingFlags.DEFAULT,
- // function(place) {
- // log("binding-to:" + place.name);
- // return place.name;
- // },
- // function(text) {
- // return text;
- // }); //TODO: will this work?
-
let popover = this._createPopover();
-
this.connect('activate', this._onActivate.bind(this, popover));
this.completion.connect('match-selected', (function(c, model, iter) {
- log("match:selected");
this.place = model.get_value(iter, PlaceStore.Columns.PLACE);
- this.text = this.place.name;
return true;
}).bind(this));
},
@@ -118,9 +113,8 @@ const PlaceEntry = new Lang.Class({
_createPopover: function() {
let popover = new SearchPopup.SearchPopup(this, 5);
- popover.connect('selected', (function(place) {
+ popover.connect('selected', (function(widget, place) {
this.place = place;
- this.text = place.name;
popover.hide();
}).bind(this));
@@ -128,8 +122,6 @@ const PlaceEntry = new Lang.Class({
},
_onActivate: function(popover) {
- log("activated, text is: " + this.text);
- log(popover);
if (this.text.length > 0) {
popover.showSpinner();
Application
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]