[gnome-documents] application, documents, edit: Disable Print menu item when unsupported
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] application, documents, edit: Disable Print menu item when unsupported
- Date: Wed, 25 Nov 2015 09:12:26 +0000 (UTC)
commit 6edb4199ccb446f4ba40505e0d25d7481c24220b
Author: Bastien Nocera <hadess hadess net>
Date: Tue Nov 24 15:31:55 2015 +0100
application, documents, edit: Disable Print menu item when unsupported
When we finish to load a document, verify whether it can be printed
before enabling the "Print..." menu item.
https://bugzilla.gnome.org/show_bug.cgi?id=758445
src/application.js | 3 +--
src/documents.js | 10 ++++++++++
src/edit.js | 6 ++++++
3 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 7c8243b..0373e26 100644
--- a/src/application.js
+++ b/src/application.js
@@ -580,8 +580,7 @@ const Application = new Lang.Class({
state: GLib.Variant.new('b', false),
accels: ['F5'] },
{ name: 'print-current', accels: ['<Primary>p'],
- callback: this._onActionPrintCurrent,
- window_mode: WindowMode.WindowMode.PREVIEW },
+ callback: this._onActionPrintCurrent },
{ name: 'search',
callback: this._onActionToggle,
state: GLib.Variant.new('b', false),
diff --git a/src/documents.js b/src/documents.js
index b3c8829..a963f29 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -369,6 +369,13 @@ const DocCommon = new Lang.Class({
log('Error: DocCommon implementations must override canTrash');
},
+ canPrint: function(docModel) {
+ if (!docModel)
+ return false;
+
+ return EvView.PrintOperation.exists_for_document(docModel.get_document());
+ },
+
trash: function() {
if (!this.canTrash())
return;
@@ -608,6 +615,9 @@ const DocCommon = new Lang.Class({
return;
}
+ if (!this.canPrint(docModel))
+ return;
+
let printOp = EvView.PrintOperation.new(docModel.get_document());
printOp.connect('begin-print', Lang.bind(this,
diff --git a/src/edit.js b/src/edit.js
index 879fbda..76244ee 100644
--- a/src/edit.js
+++ b/src/edit.js
@@ -87,6 +87,9 @@ const EditView = new Lang.Class({
Application.modeController.goBack();
}));
+ this._printAction = Application.application.lookup_action('print-current');
+ this._printAction.set_enabled(false);
+
Application.documentManager.connect('load-started',
Lang.bind(this, this._onLoadStarted));
Application.documentManager.connect('load-finished',
@@ -97,6 +100,7 @@ const EditView = new Lang.Class({
_onLoadStarted: function() {
this._editAction.enabled = false;
this._viewAction.enabled = false;
+ this._printAction.set_enabled(false);
},
_onLoadFinished: function(manager, doc, docModel) {
@@ -104,6 +108,8 @@ const EditView = new Lang.Class({
if (doc.canEdit())
this._editAction.enabled = true;
this._viewAction.enabled = true;
+ if (doc.canPrint(docModel))
+ this._printAction.set_enabled(true);
}
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]