[gnome-documents/gnome-3-8] preview: Disable search if EvDocumentFind is not implemented
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/gnome-3-8] preview: Disable search if EvDocumentFind is not implemented
- Date: Fri, 31 May 2013 11:33:32 +0000 (UTC)
commit f78e3a540d91a9403087fca0039e736bf259fd27
Author: Debarshi Ray <debarshir gnome org>
Date: Thu May 30 14:24:30 2013 +0200
preview: Disable search if EvDocumentFind is not implemented
We use a dummy call to a method to hack around the inability of the
instanceof operator to work with interfaces.
https://bugzilla.gnome.org/show_bug.cgi?id=701264
src/preview.js | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 8de72e6..de1b1b4 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -829,9 +829,24 @@ const PreviewToolbar = new Lang.Class({
this._searchAction.enabled = false;
},
- _onLoadFinished: function() {
+ _onLoadFinished: function(manager, doc, docModel) {
this._gearMenu.enabled = true;
- this._searchAction.enabled = true;
+
+ let evDoc = docModel.get_document();
+ let hasPages = (evDoc.get_n_pages() > 0);
+ let isFind = true;
+
+ try {
+ // This is a hack to find out if evDoc implements the
+ // EvDocument.DocumentFind interface or not. We don't expect
+ // the following invocation to work.
+ evDoc.find_text();
+ } catch (e if e instanceof TypeError) {
+ isFind = false;
+ } catch (e) {
+ }
+
+ this._searchAction.enabled = (hasPages && isFind);
},
_getPreviewMenu: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]