[gnome-documents] documents: Let DocCommon children indicate whether they support editing



commit b6f8b0c6074c3a10f5bf311c10da4be804659524
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Mar 5 17:22:25 2014 +0100

    documents: Let DocCommon children indicate whether they support editing
    
    Create a new canEdit virtual method, which can be implemented by the
    individual classes. This is better than littering the rest of the code
    with source-specific code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723491

 src/documents.js |   20 ++++++++++++++++++++
 src/edit.js      |    2 +-
 2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 81d7fd2..feec7f6 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -354,6 +354,10 @@ const DocCommon = new Lang.Class({
         }
     },
 
+    canEdit: function() {
+        log('Error: DocCommon implementations must override canEdit');
+    },
+
     canShare: function() {
         log('Error: DocCommon implementations must override canShare');
     },
@@ -686,6 +690,10 @@ const LocalDocument = new Lang.Class({
             }));
     },
 
+    canEdit: function() {
+        return false;
+    },
+
     canShare: function() {
         return false;
     },
@@ -853,6 +861,10 @@ const GoogleDocument = new Lang.Class({
         this.parent(cursor);
     },
 
+    canEdit: function() {
+        return true;
+    },
+
     canShare: function() {
         return true;
     },
@@ -913,6 +925,10 @@ const OwncloudDocument = new Lang.Class({
             }));
     },
 
+    canEdit: function() {
+        return false;
+    },
+
     canShare: function() {
         return false;
     },
@@ -1009,6 +1025,10 @@ const SkydriveDocument = new Lang.Class({
         this.typeDescription = description;
     },
 
+    canEdit: function() {
+        return false;
+    },
+
     canShare: function() {
         return false;
     },
diff --git a/src/edit.js b/src/edit.js
index ade8632..080a5d0 100644
--- a/src/edit.js
+++ b/src/edit.js
@@ -102,7 +102,7 @@ const EditView = new Lang.Class({
 
     _onLoadFinished: function(manager, doc, docModel) {
         if (doc.uri) {
-            if (doc instanceof Documents.GoogleDocument)
+            if (doc.canEdit())
                 this._editAction.enabled = true;
             this._viewAction.enabled = true;
         }


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