[gnome-documents] preview: add a shorter context menu in preview mode
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] preview: add a shorter context menu in preview mode
- Date: Wed, 7 Sep 2011 01:04:15 +0000 (UTC)
commit 6e46dc1a00c07667ebc763c782b906cda350b176
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Sep 6 21:02:30 2011 -0400
preview: add a shorter context menu in preview mode
Right now it only has the Open With entry.
src/preview.js | 18 ++++++++++++++++++
src/view.js | 22 +++++++++++++---------
2 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index fe1cc9c..39f4aa3 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -25,6 +25,7 @@ const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Global = imports.global;
+const View = imports.view;
function PreviewView(model, document) {
this._init(model, document);
@@ -41,6 +42,23 @@ PreviewView.prototype = {
this.widget.connect('button-press-event',
Lang.bind(this, this._onButtonPressEvent));
+ this.widget.connect('button-release-event',
+ Lang.bind(this, this._onButtonReleaseEvent));
+ },
+
+ _onButtonReleaseEvent: function(widget, event) {
+ let button = event.get_button()[1];
+ let timestamp = event.get_time();
+
+ if (button != 3)
+ return false;
+
+ let doc = Global.documentManager.getActiveDocument();
+ let menu = new View.ContextMenu(doc.urn);
+
+ menu.widget.popup_for_device(null, null, null, null, null, null, button, timestamp);
+
+ return true;
},
_onButtonPressEvent: function(widget, event) {
diff --git a/src/view.js b/src/view.js
index f199b9c..7183c53 100644
--- a/src/view.js
+++ b/src/view.js
@@ -29,6 +29,7 @@ const Signals = imports.signals;
const Documents = imports.documents;
const Global = imports.global;
const TrackerUtils = imports.trackerUtils;
+const WindowMode = imports.windowMode;
const Utils = imports.utils;
function ContextMenu(urn) {
@@ -38,7 +39,7 @@ function ContextMenu(urn) {
ContextMenu.prototype = {
_init: function(urn) {
let doc = Global.documentManager.lookupDocument(urn);
- let isFavorite = doc.favorite;
+ let showFavorite = (Global.modeController.getWindowMode() != WindowMode.WindowMode.PREVIEW);
this.widget = new Gtk.Menu();
@@ -53,15 +54,18 @@ ContextMenu.prototype = {
doc.open(item.get_screen(), Gtk.get_current_event_time());
}));
- let favoriteLabel = (isFavorite) ? _("Remove from favorites") : _("Add to favorites");
- let favoriteItem = new Gtk.MenuItem({ label: favoriteLabel });
- favoriteItem.show();
- this.widget.append(favoriteItem);
-
- favoriteItem.connect('activate', Lang.bind(this,
- function() {
- doc.setFavorite(!isFavorite);
- }));
+ if (showFavorite) {
+ let isFavorite = doc.favorite;
+ let favoriteLabel = (isFavorite) ? _("Remove from favorites") : _("Add to favorites");
+ let favoriteItem = new Gtk.MenuItem({ label: favoriteLabel });
+ favoriteItem.show();
+ this.widget.append(favoriteItem);
+
+ favoriteItem.connect('activate', Lang.bind(this,
+ function() {
+ doc.setFavorite(!isFavorite);
+ }));
+ }
this.widget.show_all();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]