[gnome-documents] preview: don't trigger find for the empty string
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] preview: don't trigger find for the empty string
- Date: Tue, 7 Aug 2012 20:52:57 +0000 (UTC)
commit f75c6ef2d7701bc7988e0ffc627300cacc49f82a
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Aug 7 22:14:17 2012 +0200
preview: don't trigger find for the empty string
And cancel the job properly if we change the string and it's not
finished yet.
src/preview.js | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index cacf327..0d751d4 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -44,6 +44,7 @@ const PreviewView = new Lang.Class({
_init: function() {
this._model = null;
+ this._jobFind = null;
this.widget = new Gtk.ScrolledWindow({ hexpand: true,
vexpand: true,
@@ -152,12 +153,23 @@ const PreviewView = new Lang.Class({
if (!this._model)
return;
+ if (this._jobFind) {
+ if (!this._jobFind.is_finished())
+ this._jobFind.cancel();
+ this._jobFind = null;
+ }
+
+ if (!str) {
+ this.view.queue_draw();
+ return;
+ }
+
let evDoc = this._model.get_document();
- let job = EvView.JobFind.new(evDoc, this._model.get_page(), evDoc.get_n_pages(),
- str, false);
- job.connect('updated', Lang.bind(this, this._onSearchJobUpdated));
+ this._jobFind = EvView.JobFind.new(evDoc, this._model.get_page(), evDoc.get_n_pages(),
+ str, false);
+ this._jobFind.connect('updated', Lang.bind(this, this._onSearchJobUpdated));
- job.scheduler_push_job(EvView.JobPriority.PRIORITY_NONE);
+ this._jobFind.scheduler_push_job(EvView.JobPriority.PRIORITY_NONE);
},
_onSearchJobUpdated: function(job, page) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]