[gnome-documents] DocumentManager: Use a stack to navigate collections



commit 9420a42571c0329752749dc5fb5cb80708daada5
Author: Volker Sobek <reklov live com>
Date:   Wed Sep 12 17:24:58 2012 -0400

    DocumentManager: Use a stack to navigate collections
    
    Allow to navigate back in nested collections by adding a stack to keep
    track of the visited collections. So far the back button in the main
    toolbar did simply reset the active collection to null in any case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680000

 src/documents.js   |   10 ++++++++++
 src/mainToolbar.js |    2 +-
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index a4b1244..c33b4ad 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -881,6 +881,10 @@ const DocumentManager = new Lang.Class({
         this._activeDocModelIds = [];
         this._loaderCancellable = null;
 
+        // a stack containing the collections which were used to
+        // navigate to the active document or collection
+        this._collectionPath = [];
+
         Global.changeMonitor.connect('changes-pending',
                                      Lang.bind(this, this._onChangesPending));
     },
@@ -998,6 +1002,7 @@ const DocumentManager = new Lang.Class({
             return;
 
         if (doc.collection) {
+            this._collectionPath.push(Global.collectionManager.getActiveItem());
             Global.collectionManager.setActiveItem(doc);
             return;
         }
@@ -1010,6 +1015,11 @@ const DocumentManager = new Lang.Class({
         this.emit('load-started', doc);
     },
 
+    activatePreviousCollection: function() {
+        this._clearActiveDocModel();
+        Global.collectionManager.setActiveItem(this._collectionPath.pop());
+    },
+
     _clearActiveDocModel: function() {
         // cancel any pending load operation
         if (this._loaderCancellable) {
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 1883c94..73cb0fa 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -226,7 +226,7 @@ const OverviewToolbar = new Lang.Class({
                 this.widget.add_button('go-previous-symbolic', _("Back"), true);
             this._collBackButton.connect('clicked', Lang.bind(this,
                 function() {
-                    Global.collectionManager.setActiveItem(null);
+                    Global.documentManager.activatePreviousCollection();
                 }));
         } else if (!item && this._collBackButton) {
             this._collBackButton.destroy();



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