[gnome-documents] documents, selections: Exit selection only after printing has begun
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] documents, selections: Exit selection only after printing has begun
- Date: Thu, 11 May 2017 21:43:45 +0000 (UTC)
commit 026e25d1d2f710d47ca12401e1a9629ac18e93b0
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Apr 20 19:09:57 2017 +0200
documents, selections: Exit selection only after printing has begun
We should leave the selection mode only after an affirmative action
has been taken. eg., we don't want to leave the selection mode if the
print dialog was cancelled. This matches the behaviour of the other
modal dialogs - OrganizeCollectionDialog, PropertiesDialog and
SharingDialog.
Fallout from e8b2d3431e44d30e4f8edb2c67c600784b81d567
https://bugzilla.gnome.org/show_bug.cgi?id=781552
src/documents.js | 5 +++++
src/selections.js | 32 +++++++++++++++++++++++++++++---
2 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index fc4258a..891de48 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -757,6 +757,11 @@ const DocCommon = new Lang.Class({
let printOp = EvView.PrintOperation.new(docModel.get_document());
+ printOp.connect('begin-print', Lang.bind(this,
+ function() {
+ this.emit('begin-print');
+ }));
+
printOp.connect('done', Lang.bind(this,
function(op, res) {
if (res == Gtk.PrintOperationResult.ERROR) {
diff --git a/src/selections.js b/src/selections.js
index 2d87540..449840b 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -857,6 +857,8 @@ const SelectionToolbar = new Lang.Class({
'toolbarCollection' ],
_init: function(overview) {
+ this._docToPrint = null;
+ this._docBeginPrintId = 0;
this._itemListeners = {};
this._insideRefresh = false;
this._overview = overview;
@@ -885,6 +887,24 @@ const SelectionToolbar = new Lang.Class({
this._onSelectionChanged();
},
+ vfunc_destroy: function() {
+ this._disconnectDocToPrint();
+ this.parent();
+ },
+
+ vfunc_hide: function() {
+ this._disconnectDocToPrint();
+ this.parent();
+ },
+
+ _disconnectDocToPrint: function() {
+ if (this._docToPrint != null && this._docBeginPrintId != 0) {
+ this._docToPrint.disconnect(this._docBeginPrintId);
+ this._docToPrint = null;
+ this._docBeginPrintId = 0;
+ }
+ },
+
_updateCollectionsButton: function() {
let windowMode = Application.modeController.getWindowMode();
let activeCollection = Application.documentManager.getActiveCollection();
@@ -1048,8 +1068,14 @@ const SelectionToolbar = new Lang.Class({
if (selection.length != 1)
return;
- let doc = Application.documentManager.getItemById(selection[0]);
- doc.print(this.get_toplevel());
- this._overview.getAction('selection-mode').change_state(GLib.Variant.new('b', false));
+ this._disconnectDocToPrint();
+
+ this._docToPrint = Application.documentManager.getItemById(selection[0]);
+ this._docBeginPrintId = this._docToPrint.connect('begin-print', Lang.bind(this,
+ function(doc) {
+ this._overview.getAction('selection-mode').change_state(GLib.Variant.new('b', false));
+ }));
+
+ this._docToPrint.print(this.get_toplevel());
},
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]