From 958ea5842bb35fde2d3e01aecfe9044d670ef2de Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Tue, 25 Feb 2014 14:19:19 +0100
Subject: [PATCH 1/2] 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 | 18 +++++++++++++++++-
src/selections.js | 2 +-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/documents.js b/src/documents.js
index d444c86..8ca30d2 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
@@ -358,6 +358,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');
},
@@ -662,6 +666,10 @@ const LocalDocument = new Lang.Class({
}));
},
+ canShare: function() {
+ return false;
+ },
+
canTrash: function() {
return this.collection;
},
@@ -825,6 +833,10 @@ const GoogleDocument = new Lang.Class({
this.parent(cursor);
},
+ canShare: function() {
+ return true;
+ },
+
canTrash: function() {
return false;
}
@@ -917,6 +929,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 8500cc1..2ea7478 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -852,7 +852,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;
--
1.8.4.2
From 5a768903d3ee90a26e3c72276bfa4f3ba6b32228 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Tue, 25 Feb 2014 12:33:27 +0100
Subject: [PATCH 2/2] documents: Warn that DocCommon implementations must
override canTrash
https://bugzilla.gnome.org/show_bug.cgi?id=725128
---
src/documents.js | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/documents.js b/src/documents.js
index 8ca30d2..de13aed 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -362,6 +362,10 @@ const DocCommon = new Lang.Class({
log('Error: DocCommon implementations must override canShare');
},
+ canTrash: function(callback) {
+ log('Error: DocCommon implementations must override canTrash');
+ },
+
createThumbnail: function(callback) {
log('Error: DocCommon implementations must override createThumbnail');
},
--
1.8.4.2