commit 8bc5d37dd1ee4d8293e2b13d2f2a759831a2fcf8
parent 2d93b072204bafa7ccc8bfe4f06e18131b8ae00c
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date: Mon, 20 Mar 2017 19:22:24 +0200
Update word plugin status after installation. Closes #1200
Diffstat:
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/resource/word-processor-plugin-installer.js b/resource/word-processor-plugin-installer.js
@@ -60,6 +60,8 @@ var ZoteroPluginInstaller = function(addon, failSilently, force) {
var prefService = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);
this.prefBranch = prefService.getBranch(this._addon.EXTENSION_PREF_BRANCH);
+
+ this.prefPaneDoc = null;
var me = this;
var extensionIDs = [this._addon.EXTENSION_ID].concat(this._addon.REQUIRED_ADDONS.map(req => req.id));
@@ -145,7 +147,7 @@ ZoteroPluginInstaller.prototype = {
installationInProgress = false;
this.closeProgressWindow();
this.prefBranch.setCharPref("version", this._version);
- this.prefBranch.setBoolPref("installed", true);
+ this.updateInstallStatus(true);
this.prefBranch.setBoolPref("skipInstallation", false);
if(this.force && !this._addon.DISABLE_PROGRESS_WINDOW) {
var addon = this._addon;
@@ -163,7 +165,7 @@ ZoteroPluginInstaller.prototype = {
this.closeProgressWindow();
if(!notFailure) {
this.prefBranch.setCharPref("version", this._version);
- this.prefBranch.setBoolPref("installed", false);
+ this.updateInstallStatus(false);
}
if(this.failSilently) return;
if(this._errorDisplayed) return;
@@ -184,6 +186,7 @@ ZoteroPluginInstaller.prototype = {
},
showPreferences: function(document) {
+ this.prefPaneDoc = document;
var isInstalled = this.isInstalled(),
groupbox = document.createElement("groupbox");
groupbox.id = this._addon.EXTENSION_DIR;
@@ -224,6 +227,23 @@ ZoteroPluginInstaller.prototype = {
}
},
+ updateInstallStatus: function(status) {
+ this.prefBranch.setBoolPref("installed", status);
+ if (! this.prefPaneDoc) return;
+ var isInstalled = this.isInstalled();
+ var description = this.prefPaneDoc.querySelector(`#${this._addon.EXTENSION_DIR} description`);
+ description.replaceChild(this.prefPaneDoc.createTextNode(
+ isInstalled ?
+ Zotero.getString('zotero.preferences.wordProcessors.installed', this._addon.APP) :
+ Zotero.getString('zotero.preferences.wordProcessors.notInstalled', this._addon.APP)
+ ), description.childNodes[0]);
+ var button = this.prefPaneDoc.querySelector(`#${this._addon.EXTENSION_DIR} button`);
+ button.setAttribute("label",
+ (isInstalled ?
+ Zotero.getString('zotero.preferences.wordProcessors.reinstall', this._addon.APP) :
+ Zotero.getString('zotero.preferences.wordProcessors.install', this._addon.APP)));
+ },
+
_firstRunListener: function() {
this._progressWindowLabel = this._progressWindow.document.getElementById("progress-label");
this._progressWindowLabel.value = Zotero.getString('zotero.preferences.wordProcessors.installing', this._addon.EXTENSION_STRING);