[gnome-documents/wip/pranavk/lokdocview: 5/5] Let LOKView has its own menu



commit 449d3f34ee8f84103d91e35e4a83884b0e8c8a25
Author: Pranav Kant <pranavk gnome org>
Date:   Sun Aug 16 22:45:03 2015 +0530

    Let LOKView has its own menu

 data/org.gnome.Documents.data.gresource.xml |    1 +
 data/ui/lokview-menu.ui                     |   16 ++++++++++++++++
 src/lokview.js                              |   25 ++++++++++++++++++++-----
 3 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/data/org.gnome.Documents.data.gresource.xml b/data/org.gnome.Documents.data.gresource.xml
index cd0d41e..c426275 100644
--- a/data/org.gnome.Documents.data.gresource.xml
+++ b/data/org.gnome.Documents.data.gresource.xml
@@ -5,6 +5,7 @@
     <file preprocess="xml-stripblanks">ui/app-menu.ui</file>
     <file preprocess="xml-stripblanks">ui/preview-context-menu.ui</file>
     <file preprocess="xml-stripblanks">ui/preview-menu.ui</file>
+    <file preprocess="xml-stripblanks">ui/lokview-menu.ui</file>
     <file preprocess="xml-stripblanks">ui/selection-menu.ui</file>
     <file alias="ui/collections-placeholder.png" 
preprocess="to-pixdata">media/collections-placeholder.png</file>
     <file alias="ui/dnd-counter.svg" preprocess="to-pixdata">media/dnd-counter.svg</file>
diff --git a/data/ui/lokview-menu.ui b/data/ui/lokview-menu.ui
new file mode 100644
index 0000000..5bd5f4a
--- /dev/null
+++ b/data/ui/lokview-menu.ui
@@ -0,0 +1,16 @@
+<interface>
+  <menu id="lokview-menu">
+    <section>
+      <item>
+        <attribute name="action">app.zoom-in</attribute>
+        <attribute name="label" translatable="yes">Zoom In</attribute>
+        <attribute name="accel">&lt;Primary&gt;plus</attribute>
+      </item>
+      <item>
+        <attribute name="action">app.zoom-out</attribute>
+        <attribute name="label" translatable="yes">Zoom Out</attribute>
+        <attribute name="accel">&lt;Primary&gt;minus</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/src/lokview.js b/src/lokview.js
index dab1a01..8d2c41a 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -119,6 +119,9 @@ const LOKViewToolbar = new Lang.Class({
         this.parent();
         this.toolbar.set_show_close_button(true);
 
+        this._gearMenu = Application.application.lookup_action('gear-menu');
+        this._gearMenu.enabled = true;
+
         // back button, on the left of the toolbar
         let backButton = this.addBackButton();
         backButton.connect('clicked', Lang.bind(this,
@@ -127,10 +130,15 @@ const LOKViewToolbar = new Lang.Class({
                 Application.modeController.goBack();
             }));
 
-        let viewButton = new Gtk.Button({ label: _("View"),
-                                          action_name: 'app.view-current' });
-        viewButton.get_style_context().add_class('suggested-action');
-        //this.toolbar.pack_end(viewButton);
+        // menu button, on the right of the toolbar
+        let previewMenu = this._getPreviewMenu();
+        let menuButton = new Gtk.MenuButton({ image: new Gtk.Image ({ icon_name: 'open-menu-symbolic' }),
+                                              menu_model: previewMenu,
+                                              action_name: 'app.gear-menu' });
+        this.toolbar.pack_end(menuButton);
+
+        // search button, on the right of the toolbar
+        this.addSearchButton();
 
         this._setToolbarTitle();
         this.toolbar.show_all();
@@ -139,6 +147,14 @@ const LOKViewToolbar = new Lang.Class({
     createSearchbar: function() {
     },
 
+    _getPreviewMenu: function() {
+        let builder = new Gtk.Builder();
+        builder.add_from_resource('/org/gnome/Documents/ui/lokview-menu.ui');
+        let menu = builder.get_object('lokview-menu');
+
+        return menu;
+    },
+
     handleEvent: function(event) {
         return false;
     },
@@ -153,4 +169,3 @@ const LOKViewToolbar = new Lang.Class({
         this.toolbar.set_title(primary);
     }
 });
-


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