summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Danielsson <jonas@threetimestwo.org>2014-12-02 01:26:33 -0500
committerJonas Danielsson <jonas@threetimestwo.org>2014-12-02 01:31:55 -0500
commitcb6f852f7b1b5cbb88fc58e27116e718a5e194e4 (patch)
tree5cae688be99646aaee5e56fb32822cff1fa3e76d
parent6a8700de590e3b344f9c47ea00a45cac50389459 (diff)
downloadgnome-maps-wip/completion.tar.gz
Add cancellable to geocode searchwip/completion
https://bugzilla.gnome.org/show_bug.cgi?id=739036
-rw-r--r--src/geocodeService.js4
-rw-r--r--src/placeEntry.js7
2 files changed, 8 insertions, 3 deletions
diff --git a/src/geocodeService.js b/src/geocodeService.js
index e5e1df1a..6b6e9199 100644
--- a/src/geocodeService.js
+++ b/src/geocodeService.js
@@ -32,7 +32,7 @@ const GeocodeService = new Lang.Class({
_init: function() { },
- search: function(string, bbox, callback) {
+ search: function(string, bbox, cancellable, callback) {
let answerCount = Application.settings.get('max-search-results');
let forward = Geocode.Forward.new_for_string(string);
@@ -46,7 +46,7 @@ const GeocodeService = new Lang.Class({
}
forward.bounded = false;
forward.set_answer_count(answerCount);
- forward.search_async(null, function(forward, res) {
+ forward.search_async(cancellable, function(forward, res) {
try {
let places = forward.search_finish(res);
callback(places);
diff --git a/src/placeEntry.js b/src/placeEntry.js
index 814ed736..461a01a6 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -24,6 +24,7 @@
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Geocode = imports.gi.GeocodeGlib;
+const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
@@ -105,6 +106,9 @@ const PlaceEntry = new Lang.Class({
this._popover = this._createPopover(numVisible, maxChars);
this.connect('activate', this._onActivate.bind(this));
this.connect('changed', (function() {
+ if (this._cancellable)
+ this._cancellable.cancel();
+
if (this.text.length === 0) {
this._popover.hide();
this.place = null;
@@ -211,7 +215,8 @@ const PlaceEntry = new Lang.Class({
let bbox = this._mapView.view.get_bounding_box();
this._popover.showSpinner();
- Application.geocodeService.search(this.text, bbox, (function(places) {
+ this._cancellable = new Gio.Cancellable();
+ Application.geocodeService.search(this.text, bbox, this._cancellable, (function(places) {
if (!places) {
this.place = null;
this._popover.hide();