Skip to content

Commit

Permalink
Update word plugin status after installation. Closes zotero#1200
Browse files Browse the repository at this point in the history
  • Loading branch information
adomasven committed Mar 20, 2017
1 parent 2d93b07 commit 8bc5d37
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions resource/word-processor-plugin-installer.js
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8bc5d37

Please sign in to comment.