[gnome-documents] selections: Prevent nested collections



commit 06636dc63122f2a0ac04f21441afa8f5028d8ee9
Author: Alessandro Bono <shadow openaliasbox org>
Date:   Wed Aug 26 12:41:45 2015 +0200

    selections: Prevent nested collections
    
    Disable the Collections button in the collections overview.
    If we are inside a collection, show the Collections button,
    but disable the delete entry for the active collection in
    the collections dialog.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=665885

 src/selections.js |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/selections.js b/src/selections.js
index 98821aa..2d9382a 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -360,7 +360,8 @@ const CollectionRow = new Lang.Class({
         else
             menu.append(_("Renameā€¦"), 'dialog.action-disabled');
 
-        if (this.collection.canTrash())
+        let activeCollection = Application.documentManager.getActiveCollection();
+        if (this.collection.canTrash() && this.collection != activeCollection)
             menu.append(_("Delete"), 'dialog.delete-collection(\'' + this.collection.id + '\')');
         else
             menu.append(_("Delete"), 'dialog.action-disabled');
@@ -887,6 +888,10 @@ const SelectionToolbar = new Lang.Class({
         this._toolbarCollection = new Gtk.Button({ label: _("Collections") });
         toolbar.pack_end(this._toolbarCollection);
         this._toolbarCollection.connect('clicked', Lang.bind(this, this._onToolbarCollection));
+        Application.modeController.connect('window-mode-changed',
+            Lang.bind(this, this._updateCollectionsButton));
+        Application.documentManager.connect('active-collection-changed',
+            Lang.bind(this, this._updateCollectionsButton));
 
         this.show_all();
 
@@ -896,6 +901,15 @@ const SelectionToolbar = new Lang.Class({
             Lang.bind(this, this._onSelectionChanged));
     },
 
+    _updateCollectionsButton: function() {
+        let windowMode = Application.modeController.getWindowMode();
+        let activeCollection = Application.documentManager.getActiveCollection();
+        if (windowMode == WindowMode.WindowMode.COLLECTIONS && !activeCollection)
+            this._toolbarCollection.hide();
+        else
+            this._toolbarCollection.show();
+    },
+
     _onSelectionModeChanged: function(controller, mode) {
         if (mode)
             this._onSelectionChanged();


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