[gnome-documents/wip/gepub] preview: use a common method to create the preview context menu
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/gepub] preview: use a common method to create the preview context menu
- Date: Wed, 22 Jun 2016 13:41:37 +0000 (UTC)
commit c2996dce2995893da08bb28809a046fdece7eba3
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Jun 21 21:31:04 2016 -0700
preview: use a common method to create the preview context menu
It's always the same anyway.
src/epubview.js | 4 ++++
src/evinceview.js | 13 +------------
src/lokview.js | 13 +------------
src/preview.js | 11 +++++++++++
4 files changed, 17 insertions(+), 24 deletions(-)
---
diff --git a/src/epubview.js b/src/epubview.js
index 94315bd..1ee2577 100644
--- a/src/epubview.js
+++ b/src/epubview.js
@@ -63,6 +63,10 @@ const EPUBView = new Lang.Class({
return new Gepub.Widget();
},
+ createContextMenu: function() {
+ return null;
+ },
+
onLoadFinished: function(manager, doc) {
this.parent(manager, doc);
diff --git a/src/evinceview.js b/src/evinceview.js
index 8e9d4d5..d382f9a 100644
--- a/src/evinceview.js
+++ b/src/evinceview.js
@@ -63,11 +63,6 @@ const EvinceView = new Lang.Class({
Application.modeController.connect('window-mode-changed', Lang.bind(this,
this._onWindowModeChanged));
- // create context menu
- let model = this._getEvinceViewContextMenu();
- this._previewContextMenu = Gtk.Menu.new_from_model(model);
- this._previewContextMenu.attach_to_widget(this.view, null);
-
this.getAction('bookmark-page').enabled = false;
let nightModeId = Application.application.connect('action-state-changed::night-mode',
@@ -399,12 +394,6 @@ const EvinceView = new Lang.Class({
this.getAction('zoom-out').enabled = this._evView.can_zoom_out;
},
- _getEvinceViewContextMenu: function() {
- let builder = new Gtk.Builder();
- builder.add_from_resource('/org/gnome/Documents/ui/preview-context-menu.ui');
- return builder.get_object('preview-context-menu');
- },
-
_syncControlsVisible: function() {
if (this._controlsVisible) {
if (this._fsToolbar)
@@ -474,7 +463,7 @@ const EvinceView = new Lang.Class({
if (button == 3) {
let time = event.get_time();
- this._previewContextMenu.popup(null, null, null, button, time);
+ this.contextMenu.popup(null, null, null, button, time);
return true;
}
diff --git a/src/lokview.js b/src/lokview.js
index 7dbb3a3..8b4c690 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -107,11 +107,6 @@ const LOKView = new Lang.Class({
valign: Gtk.Align.START });
this._progressBar.get_style_context().add_class('osd');
this.overlay.add_overlay(this._progressBar);
-
- // create context menu
- let model = this._getPreviewContextMenu();
- this._previewContextMenu = Gtk.Menu.new_from_model(model);
- this._previewContextMenu.attach_to_widget(this.view, null);
},
createActions: function() {
@@ -199,18 +194,12 @@ const LOKView = new Lang.Class({
this.getAction('zoom-out').enabled = this._lokview.can_zoom_out;
},
- _getPreviewContextMenu: function() {
- let builder = new Gtk.Builder();
- builder.add_from_resource('/org/gnome/Documents/ui/preview-context-menu.ui');
- return builder.get_object('preview-context-menu');
- },
-
_onButtonPressEvent: function(widget, event) {
let button = event.get_button()[1];
if (button == 3) {
let time = event.get_time();
- this._previewContextMenu.popup(null, null, null, button, time);
+ this.contextMenu.popup(null, null, null, button, time);
return true;
}
diff --git a/src/preview.js b/src/preview.js
index 365e719..1284c3c 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -39,6 +39,10 @@ const Preview = new Lang.Class({
this.view.show();
this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
+ this.contextMenu = this.createContextMenu();
+ if (this.contextMenu)
+ this.contextMenu.attach_to_widget(this.view, null);
+
this.navControls = this.createNavControls();
this.navControls.show();
this.show_all();
@@ -118,6 +122,13 @@ const Preview = new Lang.Class({
throw(new Error('Not implemented'));
},
+ createContextMenu: function() {
+ let builder = new Gtk.Builder();
+ builder.add_from_resource('/org/gnome/Documents/ui/preview-context-menu.ui');
+ let model = builder.get_object('preview-context-menu');
+ return Gtk.Menu.new_from_model(model);
+ },
+
onLoadStarted: function(manager, doc) {
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]