[gnome-maps/wip/routing2: 22/23] Update: RouteQuery
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/routing2: 22/23] Update: RouteQuery
- Date: Sun, 15 Jun 2014 02:15:04 +0000 (UTC)
commit fc20e71bfd3f1cc50dfeb3b4740652bebfafc78f
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Wed Jun 11 01:55:42 2014 +0200
Update: RouteQuery
Some changes to the routequery needed for the bind_property stuff that I
didn't anticipate.
- Change signal from change to updated (and use glib signals)
- Add setters and getters that does notify() calls
- some small refactorings
- Some if() => if ()
Squash with:
7d6d3b1 Add Route query model
https://bugzilla.gnome.org/show_bug.cgi?id=728695
src/routeQuery.js | 48 +++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 41 insertions(+), 7 deletions(-)
---
diff --git a/src/routeQuery.js b/src/routeQuery.js
index fd02f8b..8029a57 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(transportation) {
+ this._transportation = transportation;
+ 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]