[gnome-documents] properties: avoid using instanceof
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] properties: avoid using instanceof
- Date: Mon, 5 Aug 2019 14:03:16 +0000 (UTC)
commit c28f8bcbc603aeb7f0e9f7b8b1a1a4f3a7b8020b
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Aug 2 18:29:03 2019 +0200
properties: avoid using instanceof
Instead add a method to the document class to know whether its title
can be edited, false by default.
src/documents.js | 8 ++++++++
src/properties.js | 3 +--
2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index a8e385c1..5c81d77a 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -464,6 +464,10 @@ const DocCommon = new Lang.Class({
throw(new Error('DocCommon implementations must override canEdit'));
},
+ canEditTitle: function() {
+ return false;
+ },
+
canShare: function() {
throw(new Error('DocCommon implementations must override canShare'));
},
@@ -920,6 +924,10 @@ var LocalDocument = new Lang.Class({
return this.collection;
},
+ canEditTitle: function() {
+ return true;
+ },
+
canShare: function() {
return false;
},
diff --git a/src/properties.js b/src/properties.js
index 3647ef35..88a52f18 100644
--- a/src/properties.js
+++ b/src/properties.js
@@ -27,7 +27,6 @@ const _ = imports.gettext.gettext;
const C_ = imports.gettext.pgettext;
const Application = imports.application;
-const Documents = imports.documents;
const Mainloop = imports.mainloop;
const TrackerUtils = imports.trackerUtils;
@@ -122,7 +121,7 @@ var PropertiesDialog = new Lang.Class({
grid.add (this._docType);
// Title value
- if (doc instanceof Documents.LocalDocument) {
+ if (doc.canEditTitle()) {
this._titleEntry = new Gtk.Entry({ activates_default: true,
text: doc.name,
editable: true,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]