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



commit 18dfeb07677e34ae02bb809c2e2102dab4ca0d8c
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).

 data/ui/preview-menu.ui |    2 +-
 src/application.js      |    6 ++++--
 src/lokview.js          |   23 +++++++++++++++++++++--
 3 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/data/ui/preview-menu.ui b/data/ui/preview-menu.ui
index c0cd2b0..56d63c4 100644
--- a/data/ui/preview-menu.ui
+++ b/data/ui/preview-menu.ui
@@ -32,7 +32,7 @@
         <attribute name="accel">&lt;Primary&gt;minus</attribute>
       </item>
     </section>
-    <section>
+    <section id='rotate-section'>
       <item>
         <attribute name="action">app.rotate-left</attribute>
         <attribute name="label" translatable="yes">Rotate ↶</attribute>
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]