[gnome-documents/wip/lokdocview-rebase: 20/21] Show the right menu in the toolbar



commit e0f1cafdfa692c95135c4a3653011ef0c18bc80a
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Dec 14 16:29:05 2015 +0100

    Show the right menu in the toolbar
    
    We were showing the context menu instead of the toolbar menu in the
    toolbar. Fix this, and remove the items which we don't support yet
    (rotation, print and edit).

 src/application.js |    6 ++++--
 src/lokview.js     |   23 +++++++++++++++++++++--
 2 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 8a69823..78e435f 100644
--- a/src/application.js
+++ b/src/application.js
@@ -574,7 +574,8 @@ const Application = new Lang.Class({
                              WindowMode.WindowMode.SEARCH] },
             { name: 'open-current',
               callback: this._onActionOpenCurrent,
-              window_mode: WindowMode.WindowMode.PREVIEW },
+              window_modes: [WindowMode.WindowMode.PREVIEW,
+                             WindowMode.WindowMode.PREVIEW_LOK] },
             { name: 'edit-current' },
             { name: 'view-current',
               window_mode: WindowMode.WindowMode.EDIT },
@@ -613,7 +614,8 @@ const Application = new Lang.Class({
                              WindowMode.WindowMode.SEARCH] },
             { name: 'properties',
               callback: this._onActionProperties,
-              window_mode: WindowMode.WindowMode.PREVIEW },
+              window_modes: [WindowMode.WindowMode.PREVIEW,
+                             WindowMode.WindowMode.PREVIEW_LOK] },
             { name: 'bookmark-page',
               callback: this._onActionToggle,
               state: GLib.Variant.new('b', false),
diff --git a/src/lokview.js b/src/lokview.js
index 309b709..6c9af4b 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -265,8 +265,27 @@ const LOKViewToolbar = new Lang.Class({
 
     _getLOKViewMenu: function() {
         let builder = new Gtk.Builder();
-        builder.add_from_resource('/org/gnome/Documents/ui/preview-context-menu.ui');
-        let menu = builder.get_object('preview-context-menu');
+        builder.add_from_resource('/org/gnome/Documents/ui/preview-menu.ui');
+        let menu = builder.get_object('preview-menu');
+        let section = builder.get_object('open-section');
+
+        let doc = Application.documentManager.getActiveItem();
+        if (doc && doc.defaultAppName) {
+            section.remove(0);
+            section.prepend(_("Open with %s").format(doc.defaultAppName), 'app.open-current');
+        }
+
+        // No edit support yet
+        section.remove(1);
+        // No print support yet
+        section.remove(1);
+        // No present support yet
+        section.remove(1);
+
+        // No rotate support
+        section = builder.get_object('rotate-section');
+        section.remove(0);
+        section.remove(0);
 
         return menu;
     },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]