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



commit 051683b7f48356d727cad4e771865b5089076808
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 11b295b..e535c60 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
@@ -354,6 +354,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');
     },
@@ -678,6 +682,10 @@ const LocalDocument = new Lang.Class({
             }));
     },
 
+    canShare: function() {
+        return false;
+    },
+
     canTrash: function() {
         return this.collection;
     },
@@ -841,6 +849,10 @@ const GoogleDocument = new Lang.Class({
         this.parent(cursor);
     },
 
+    canShare: function() {
+        return true;
+    },
+
     canTrash: function() {
         return false;
     }
@@ -897,6 +909,10 @@ const OwncloudDocument = new Lang.Class({
             }));
     },
 
+    canShare: function() {
+        return false;
+    },
+
     canTrash: function() {
         return false;
     }
@@ -989,6 +1005,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 16032de..e65f649 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]