[gnome-documents] documents: add a print() method to DocCommon
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] documents: add a print() method to DocCommon
- Date: Thu, 19 Jul 2012 01:52:39 +0000 (UTC)
commit 8e87941426194b25603fd4f22d1818afce633351
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Jul 18 21:46:26 2012 -0400
documents: add a print() method to DocCommon
Will be shared between the selection toolbar and the menus.
src/documents.js | 17 +++++++++++++++++
src/selections.js | 14 +-------------
2 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 0df0c60..3641c8a 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -19,6 +19,7 @@
*
*/
+const EvView = imports.gi.EvinceView;
const GdkPixbuf = imports.gi.GdkPixbuf;
const Gio = imports.gi.Gio;
const Gd = imports.gi.Gd;
@@ -35,6 +36,7 @@ const Signals = imports.signals;
const ChangeMonitor = imports.changeMonitor;
const Global = imports.global;
const Manager = imports.manager;
+const Notifications = imports.notifications;
const Path = imports.path;
const Query = imports.query;
const Searchbar = imports.searchbar;
@@ -596,6 +598,21 @@ const DocCommon = new Lang.Class({
}
},
+ print: function(toplevel) {
+ this.load(null, Lang.bind(this,
+ function(doc, docModel, error) {
+ if (error) {
+ log('Unable to print document ' + this.uri + ': ' + error);
+ return;
+ }
+
+ let printOp = EvView.PrintOperation.new(docModel.get_document());
+ let printNotification = new Notifications.PrintNotification(printOp, doc);
+
+ printOp.run(toplevel);
+ }));
+ },
+
setFavorite: function(favorite) {
TrackerUtils.setFavorite(this.id, favorite, null);
},
diff --git a/src/selections.js b/src/selections.js
index 685b8cc..2309a6c 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -971,19 +971,7 @@ const SelectionToolbar = new Lang.Class({
return;
let doc = Global.documentManager.getItemById(selection[0]);
- doc.load(null, Lang.bind(this,
- function(doc, docModel, error) {
- if (error) {
- // TODO: handle error here!
- return;
- }
-
- let printOp = EvView.PrintOperation.new(docModel.get_document());
- let printNotification = new Notifications.PrintNotification(printOp, doc);
-
- let toplevel = this.widget.get_toplevel();
- printOp.run(toplevel);
- }));
+ doc.print(this.widget.get_toplevel());
},
_fadeIn: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]