[gnome-maps] geocodeService: Add support for cancellable
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] geocodeService: Add support for cancellable
- Date: Thu, 18 Dec 2014 07:29:17 +0000 (UTC)
commit 0ebf5104821a2f1de35f7605b5735c377cd04585
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue Dec 2 01:26:33 2014 -0500
geocodeService: Add support for cancellable
https://bugzilla.gnome.org/show_bug.cgi?id=739036
src/contextMenu.js | 2 +-
src/geocodeService.js | 8 ++++----
src/placeEntry.js | 7 ++++++-
3 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 6f01cb1..6211bf2 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -60,7 +60,7 @@ const ContextMenu = new Lang.Class({
longitude: this._longitude,
accuracy: 0 });
- Application.geocodeService.reverse(location, (function(place) {
+ Application.geocodeService.reverse(location, null, (function(place) {
this._mapView.showSearchResult(place);
}).bind(this));
},
diff --git a/src/geocodeService.js b/src/geocodeService.js
index e5e1df1..b39f0e2 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);
@@ -56,11 +56,11 @@ const GeocodeService = new Lang.Class({
});
},
- reverse: function(location, callback) {
+ reverse: function(location, cancellable, callback) {
let reverse = Geocode.Reverse.new_for_location(location);
Application.application.mark_busy();
- reverse.resolve_async (null, (function(reverse, res) {
+ reverse.resolve_async(cancellable, (function(reverse, res) {
Application.application.unmark_busy();
try {
let place = reverse.resolve_finish(res);
diff --git a/src/placeEntry.js b/src/placeEntry.js
index 9855c2a..78ae7d2 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;
@@ -108,6 +109,9 @@ const PlaceEntry = new Lang.Class({
this.connect('activate', this._onActivate.bind(this));
this.connect('changed', (function() {
+ if (this._cancellable)
+ this._cancellable.cancel();
+
this._refreshFilter();
if (this.text.length === 0) {
@@ -218,7 +222,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();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]