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



commit e85b234d101d536ac1ed1606c12fa4b798541e49
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 25 14:19:19 2014 +0100

    documents: Let DocCommon children indicate whether they support sharing
    
    Create a new canShare 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=725128

 src/documents.js  |   22 +++++++++++++++++++++-
 src/selections.js |    2 +-
 2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 45920a5..17d2c70 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, 2013 Red Hat, Inc.
+ * Copyright (c) 2011, 2012, 2013, 2014 Red Hat, Inc.
  *
  * Gnome Documents is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by the
@@ -355,6 +355,10 @@ const DocCommon = new Lang.Class({
         }
     },
 
+    canShare: function(callback) {
+        log('Error: DocCommon implementations must override canShare');
+    },
+
     createThumbnail: function(callback) {
         log('Error: DocCommon implementations must override createThumbnail');
     },
@@ -659,6 +663,10 @@ const LocalDocument = new Lang.Class({
             }));
     },
 
+    canShare: function() {
+        return false;
+    },
+
     canTrash: function() {
         return this.collection;
     },
@@ -822,6 +830,10 @@ const GoogleDocument = new Lang.Class({
         this.parent(cursor);
     },
 
+    canShare: function() {
+        return true;
+    },
+
     canTrash: function() {
         return false;
     }
@@ -878,6 +890,10 @@ const OwncloudDocument = new Lang.Class({
             }));
     },
 
+    canShare: function() {
+        return false;
+    },
+
     canTrash: function() {
         return false;
     }
@@ -970,6 +986,10 @@ const SkydriveDocument = new Lang.Class({
         this.typeDescription = description;
     },
 
+    canShare: function() {
+        return false;
+    },
+
     canTrash: function() {
         return false;
     }
diff --git a/src/selections.js b/src/selections.js
index 1c1a907..c8df771 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -834,7 +834,7 @@ const SelectionToolbar = new Lang.Class({
                 if ((doc.defaultAppName) &&
                     (apps.indexOf(doc.defaultAppName) == -1))
                     apps.push(doc.defaultAppName);
-                if ((doc instanceof Documents.LocalDocument) ||
+                if (!doc.canShare() ||
                     (doc.collection != false) ||
                     (selection.length > 1))
                     showShare = false;


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