[gnome-documents/wip/lokdocview-rebase: 20/27] Add support for the "Copy" menu item
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/lokdocview-rebase: 20/27] Add support for the "Copy" menu item
- Date: Mon, 4 Jan 2016 12:24:46 +0000 (UTC)
commit cc2741e41b3f9234435fb1b257ad72e92caca5ad
Author: Bastien Nocera <hadess hadess net>
Date: Thu Dec 10 13:34:18 2015 +0100
Add support for the "Copy" menu item
src/lokview.js | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/lokview.js b/src/lokview.js
index 3d63436..d5137e7 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -132,6 +132,9 @@ const LOKView = new Lang.Class({
this.view.set_zoom(zoomLevel / 2);
}));
+ this._copy = Application.application.lookup_action('copy');
+ let copyId = this._copy.connect('activate', Lang.bind(this, this._onCopyActivated));
+
Application.documentManager.connect('load-started',
Lang.bind(this, this._onLoadStarted));
Application.documentManager.connect('load-error',
@@ -144,6 +147,14 @@ const LOKView = new Lang.Class({
}));
},
+ _onCopyActivated: function() {
+ let [selectedText, mimeType] = this.view.copy_selection('text/plain;charset=utf-8');
+ let display = Gdk.Display.get_default();
+ let clipboard = Gtk.Clipboard.get_default(display);
+
+ clipboard.set_text(selectedText, selectedText.length);
+ },
+
_onLoadStarted: function(manager, doc) {
if (doc.viewType != Documents.ViewType.LOK)
return;
@@ -152,6 +163,7 @@ const LOKView = new Lang.Class({
let file = Gio.File.new_for_uri (doc.uri);
let location = file.get_path();
this._doc = doc;
+ this._copy.enabled = false;
this.view.open_document(location, "{}", null, Lang.bind(this, this.open_document_cb));
this._progressBar.show();
},
@@ -177,6 +189,8 @@ const LOKView = new Lang.Class({
this.view.show();
// FIXME this doesn't work yet
this.view.set_edit(false);
+ // FIXME https://bugs.documentfoundation.org/show_bug.cgi?id=96384
+ this._copy.enabled = true;
},
reset: function () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]