[gnome-documents] Add "Copy to the Clipboard" functionality
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] Add "Copy to the Clipboard" functionality
- Date: Thu, 4 Apr 2013 17:48:27 +0000 (UTC)
commit f9364e4bc3bcbbe366802287c9f665c940bb89f8
Author: Fabiano FidĂȘncio <fidencio redhat com>
Date: Thu Mar 28 16:28:02 2013 +0100
Add "Copy to the Clipboard" functionality
https://bugzilla.gnome.org/show_bug.cgi?id=688756
po/POTFILES.in | 1 +
src/application.js | 3 +++
src/gnome-documents.gresource.xml | 1 +
src/preview.js | 29 +++++++++++++++++++++++++++--
src/resources/preview-context-menu.ui | 11 +++++++++++
5 files changed, 43 insertions(+), 2 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8395132..9935228 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -17,6 +17,7 @@ src/properties.js
[type: gettext/glade]src/resources/app-menu.ui
[type: gettext/glade]src/resources/preview-menu.ui
[type: gettext/glade]src/resources/selection-menu.ui
+[type: gettext/glade]src/resources/preview-context-menu.ui
src/searchbar.js
src/search.js
src/selections.js
diff --git a/src/application.js b/src/application.js
index 66bd523..83a984e 100644
--- a/src/application.js
+++ b/src/application.js
@@ -458,6 +458,9 @@ const Application = new Lang.Class({
window_mode: WindowMode.WindowMode.PREVIEW },
{ name: 'places',
accel: '<Primary>b',
+ window_mode: WindowMode.WindowMode.PREVIEW },
+ { name: 'copy',
+ accel: '<Primary>c',
window_mode: WindowMode.WindowMode.PREVIEW }
];
diff --git a/src/gnome-documents.gresource.xml b/src/gnome-documents.gresource.xml
index 75ef1bf..4b2fe7d 100644
--- a/src/gnome-documents.gresource.xml
+++ b/src/gnome-documents.gresource.xml
@@ -4,6 +4,7 @@
<file alias="app-menu.ui" preprocess="xml-stripblanks">resources/app-menu.ui</file>
<file alias="preview-menu.ui" preprocess="xml-stripblanks">resources/preview-menu.ui</file>
<file alias="selection-menu.ui" preprocess="xml-stripblanks">resources/selection-menu.ui</file>
+ <file alias="preview-context-menu.ui"
preprocess="xml-stripblanks">resources/preview-context-menu.ui</file>
<file alias="thumbnail-frame.png" preprocess="to-pixdata">resources/thumbnail-frame.png</file>
</gresource>
</gresources>
diff --git a/src/preview.js b/src/preview.js
index 0bde66d..bc6ed94 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -75,6 +75,11 @@ const PreviewView = new Lang.Class({
this._createView();
+ // create context menu
+ let model = this._getPreviewContextMenu();
+ this._previewContextMenu = Gtk.Menu.new_from_model(model);
+ this._previewContextMenu.attach_to_widget(this.widget, null);
+
// create page nav bar
this._navBar = new PreviewNavBar(this._model);
this._overlay.add_overlay(this._navBar.widget);
@@ -113,6 +118,11 @@ const PreviewView = new Lang.Class({
function() {
this.view.find_next();
}));
+ this._copy = Application.application.lookup_action('copy');
+ this._copy.connect('activate', Lang.bind(this,
+ function() {
+ this.view.copy();
+ }));
let rotLeft = Application.application.lookup_action('rotate-left');
rotLeft.connect('activate', Lang.bind(this,
@@ -141,6 +151,7 @@ const PreviewView = new Lang.Class({
_onLoadStarted: function() {
this._showPlaces.enabled = false;
+ this._copy.enabled = false;
},
_onLoadFinished: function(manager, doc, docModel) {
@@ -240,7 +251,9 @@ const PreviewView = new Lang.Class({
_onViewSelectionChanged: function() {
this._viewSelectionChanged = true;
- if (!this.view.get_has_selection())
+ let has_selection = this.view.get_has_selection();
+ this._copy.enabled = has_selection;
+ if (!has_selection)
this._cancelControlsFlip();
},
@@ -329,6 +342,12 @@ const PreviewView = new Lang.Class({
this._handleExternalLink));
},
+ _getPreviewContextMenu: function() {
+ let builder = new Gtk.Builder();
+ builder.add_from_resource('/org/gnome/documents/preview-context-menu.ui');
+ return builder.get_object('preview-context-menu');
+ },
+
_syncControlsVisible: function() {
if (this._controlsVisible) {
if (this._fsToolbar)
@@ -428,9 +447,15 @@ const PreviewView = new Lang.Class({
},
_onButtonPressEvent: function(widget, event) {
+ let button = event.get_button()[1];
- this._viewSelectionChanged = false;
+ if (button == 3) {
+ let time = event.get_time();
+ this._previewContextMenu.popup(null, null, null, button, time);
+ return true;
+ }
+ this._viewSelectionChanged = false;
return false;
},
diff --git a/src/resources/preview-context-menu.ui b/src/resources/preview-context-menu.ui
new file mode 100644
index 0000000..c4a7212
--- /dev/null
+++ b/src/resources/preview-context-menu.ui
@@ -0,0 +1,11 @@
+<interface>
+ <menu id="preview-context-menu">
+ <section>
+ <item>
+ <attribute name="action">app.copy</attribute>
+ <attribute name="label" translatable="yes">_Copy</attribute>
+ <attribute name="accel"><Primary>c</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]