[gnome-documents] toolbar: add a Select All/Select None menu



commit 88896ab05cfe83a3bc50e21e120d05ff5149bca1
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Aug 27 22:14:01 2012 -0400

    toolbar: add a Select All/Select None menu
    
    As seen in recent mockups. This commit implements that menu using the
    new method of GdMainToolbar.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677050

 src/Makefile.am                   |    3 ++-
 src/application.js                |    6 +++++-
 src/gnome-documents.gresource.xml |    1 +
 src/mainToolbar.js                |    6 ++++++
 src/resources/selection-menu.ui   |   14 ++++++++++++++
 src/view.js                       |   12 ++++++++++++
 6 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 6aa8651..8a1773d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,7 +45,8 @@ gnome-documents.gresource: gnome-documents.gresource.xml $(shell $(GLIB_COMPILE_
 	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) $<
 EXTRA_DIST += gnome-documents.gresource.xml \
 	resources/app-menu.ui \
-	resources/preview-menu.ui
+	resources/preview-menu.ui \
+	resources/selection-menu.ui
 
 resourcedir = $(pkgdatadir)
 resource_DATA = gnome-documents.gresource
diff --git a/src/application.js b/src/application.js
index 7950bb2..aebfcd4 100644
--- a/src/application.js
+++ b/src/application.js
@@ -158,7 +158,11 @@ const Application = new Lang.Class({
             { name: 'rotate-left', accel: '<Primary>Left',
               window_mode: WindowMode.WindowMode.PREVIEW },
             { name: 'rotate-right', accel: '<Primary>Right',
-              window_mode: WindowMode.WindowMode.PREVIEW }
+              window_mode: WindowMode.WindowMode.PREVIEW },
+            { name: 'select-all', accel: '<Primary>a',
+              window_mode: WindowMode.WindowMode.OVERVIEW },
+            { name: 'select-none',
+              window_mode: WindowMode.WindowMode.OVERVIEW }
         ];
 
         actionEntries.forEach(Lang.bind(this,
diff --git a/src/gnome-documents.gresource.xml b/src/gnome-documents.gresource.xml
index bd3cff0..e3256fd 100644
--- a/src/gnome-documents.gresource.xml
+++ b/src/gnome-documents.gresource.xml
@@ -3,5 +3,6 @@
   <gresource prefix="/org/gnome/documents">
     <file alias="app-menu.ui" preprocess="xml-stripblanks">resources/app-menu.ui</file>
     <file alias="preview-menu.ui" preprocess="xml-stripblanks">resources/preview-menu.ui</file>
+    <file alias="selection-menu.ui" preprocess="xml-stripblanks">resources/selection-menu.ui</file>
   </gresource>
 </gresources>
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index d360f7d..e1eb8e4 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -199,6 +199,11 @@ const OverviewToolbar = new Lang.Class({
 
         this.addSearchButton();
 
+        let builder = new Gtk.Builder();
+        builder.add_from_resource('/org/gnome/documents/selection-menu.ui');
+        let selectionMenu = builder.get_object('selection-menu');
+        this.widget.set_labels_menu(selectionMenu);
+
         let selectionButton =
             this.widget.add_button(null, _("Done"), false);
         selectionButton.get_style_context().add_class('suggested-action');
@@ -250,6 +255,7 @@ const OverviewToolbar = new Lang.Class({
 
     _clearStateData: function() {
         this._collBackButton = null;
+        this.widget.set_labels_menu(null);
 
         if (this._collectionId != 0) {
             Global.collectionManager.disconnect(this._collectionId);
diff --git a/src/resources/selection-menu.ui b/src/resources/selection-menu.ui
new file mode 100644
index 0000000..76d0761
--- /dev/null
+++ b/src/resources/selection-menu.ui
@@ -0,0 +1,14 @@
+<interface>
+  <menu id="selection-menu">
+    <section>
+      <item>
+        <attribute name="action">app.select-all</attribute>
+        <attribute name="label" translatable="yes">Select All</attribute>
+      </item>
+      <item>
+        <attribute name="action">app.select-none</attribute>
+        <attribute name="label" translatable="yes">Select None</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/src/view.js b/src/view.js
index 1d63691..df499c9 100644
--- a/src/view.js
+++ b/src/view.js
@@ -206,6 +206,18 @@ const ViewContainer = new Lang.Class({
                                       Lang.bind(this, this._onWindowModeChanged));
         this._onWindowModeChanged();
 
+        let selectAll = Global.application.lookup_action('select-all');
+        selectAll.connect('activate', Lang.bind(this,
+            function() {
+                this.view.select_all();
+            }));
+
+        let selectNone = Global.application.lookup_action('select-none');
+        selectNone.connect('activate', Lang.bind(this,
+            function() {
+                this.view.unselect_all();
+            }));
+
         this._queryId =
             Global.trackerController.connect('query-status-changed',
                                              Lang.bind(this, this._onQueryStatusChanged));



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