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



commit 1fd520ca18c3ec4cbf00c19126a0774f42b54355
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 f1a7895..8c8c7d2 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -355,6 +355,10 @@ const DocCommon = new Lang.Class({
         }
     },
 
+    canEdit: function() {
+        log('Error: DocCommon implementations must override canEdit');
+    },
+
     canShare: function() {
         log('Error: DocCommon implementations must override canShare');
     },
@@ -667,6 +671,10 @@ const LocalDocument = new Lang.Class({
             }));
     },
 
+    canEdit: function() {
+        return false;
+    },
+
     canShare: function() {
         return false;
     },
@@ -834,6 +842,10 @@ const GoogleDocument = new Lang.Class({
         this.parent(cursor);
     },
 
+    canEdit: function() {
+        return true;
+    },
+
     canShare: function() {
         return true;
     },
@@ -894,6 +906,10 @@ const OwncloudDocument = new Lang.Class({
             }));
     },
 
+    canEdit: function() {
+        return false;
+    },
+
     canShare: function() {
         return false;
     },
@@ -990,6 +1006,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]