Quit rather than restart when changing data directory
This commit is contained in:
parent
5f2f120a98
commit
1f1c6d16ff
4 changed files with 74 additions and 30 deletions
|
@ -59,11 +59,7 @@ var Zotero_Preferences = {
|
|||
}
|
||||
},
|
||||
|
||||
openHelpLink: function () {
|
||||
var url = "http://www.zotero.org/support/preferences/";
|
||||
var helpTopic = document.getElementsByTagName("prefwindow")[0].currentPane.helpTopic;
|
||||
url += helpTopic;
|
||||
|
||||
openURL: function (url, windowName) {
|
||||
// Non-instantApply prefwindows are usually modal, so we can't open in the topmost window,
|
||||
// since it's probably behind the window
|
||||
var instantApply = Zotero.Prefs.get("browser.preferences.instantApply", true);
|
||||
|
@ -88,7 +84,7 @@ var Zotero_Preferences = {
|
|||
var win = ww.openWindow(
|
||||
window,
|
||||
url,
|
||||
"helpWindow",
|
||||
windowName ? windowName : null,
|
||||
"chrome=no,menubar=yes,location=yes,toolbar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes",
|
||||
null
|
||||
);
|
||||
|
@ -96,6 +92,14 @@ var Zotero_Preferences = {
|
|||
}
|
||||
},
|
||||
|
||||
openHelpLink: function () {
|
||||
var url = "http://www.zotero.org/support/preferences/";
|
||||
var helpTopic = document.getElementsByTagName("prefwindow")[0].currentPane.helpTopic;
|
||||
url += helpTopic;
|
||||
|
||||
this.openURL(url, "helpWindow");
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Opens a URI in the basic viewer in Standalone, or a new window in Firefox
|
||||
|
|
|
@ -191,7 +191,8 @@ Zotero_Preferences.Advanced = {
|
|||
var useDataDir = Zotero.Prefs.get('useDataDir');
|
||||
|
||||
// If triggered from the Choose button, don't show the dialog, since
|
||||
// Zotero.chooseZoteroDirectory() shows its own
|
||||
// Zotero.chooseZoteroDirectory() (called below due to the radio button
|
||||
// change) shows its own
|
||||
if (event.originalTarget && event.originalTarget.tagName == 'button') {
|
||||
return true;
|
||||
}
|
||||
|
@ -200,25 +201,31 @@ Zotero_Preferences.Advanced = {
|
|||
return true;
|
||||
}
|
||||
|
||||
// If directory not set or invalid, prompt for location
|
||||
if (!this.getDataDirPath()) {
|
||||
// If changing from default to custom
|
||||
if (!useDataDir) {
|
||||
event.stopPropagation();
|
||||
var file = Zotero.chooseZoteroDirectory(true);
|
||||
var file = Zotero.chooseZoteroDirectory(true, false, function () {
|
||||
Zotero_Preferences.openURL('http://zotero.org/support/zotero_data');
|
||||
});
|
||||
radiogroup.selectedIndex = file ? 1 : 0;
|
||||
return !!file;
|
||||
}
|
||||
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
|
||||
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
|
||||
var app = Zotero.isStandalone ? Zotero.getString('app.standalone') : Zotero.getString('app.firefox');
|
||||
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
|
||||
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL
|
||||
+ ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
|
||||
var app = Zotero.appName;
|
||||
var index = ps.confirmEx(window,
|
||||
Zotero.getString('general.restartRequired'),
|
||||
Zotero.getString('general.restartRequiredForChange', app),
|
||||
Zotero.getString('general.restartRequiredForChange', app) + '\n\n'
|
||||
+ Zotero.getString('dataDir.moveFilesToNewLocation', app),
|
||||
buttonFlags,
|
||||
Zotero.getString('general.restartNow'),
|
||||
null, null, null, {});
|
||||
Zotero.getString('general.quitApp', app),
|
||||
null,
|
||||
Zotero.getString('general.moreInformation'),
|
||||
null, {});
|
||||
|
||||
if (index == 0) {
|
||||
useDataDir = !!radiogroup.selectedIndex;
|
||||
|
@ -226,8 +233,10 @@ Zotero_Preferences.Advanced = {
|
|||
Zotero.Prefs.set('useDataDir', useDataDir);
|
||||
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Components.interfaces.nsIAppStartup);
|
||||
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit
|
||||
| Components.interfaces.nsIAppStartup.eRestart);
|
||||
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
|
||||
}
|
||||
else if (index == 2) {
|
||||
Zotero_Preferences.openURL('http://zotero.org/support/zotero_data');
|
||||
}
|
||||
|
||||
radiogroup.selectedIndex = useDataDir ? 1 : 0;
|
||||
|
|
|
@ -1029,7 +1029,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
}
|
||||
|
||||
|
||||
function chooseZoteroDirectory(forceRestartNow, useProfileDir) {
|
||||
function chooseZoteroDirectory(forceQuitNow, useProfileDir, moreInfoCallback) {
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow('navigator:browser');
|
||||
|
@ -1057,28 +1057,55 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
// Warn if non-empty and no zotero.sqlite
|
||||
if (!dbfile.exists()) {
|
||||
var buttonFlags = ps.STD_YES_NO_BUTTONS;
|
||||
if (moreInfoCallback) {
|
||||
buttonFlags += ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
|
||||
}
|
||||
var index = ps.confirmEx(null,
|
||||
Zotero.getString('dataDir.selectedDirNonEmpty.title'),
|
||||
Zotero.getString('dataDir.selectedDirNonEmpty.text'),
|
||||
buttonFlags, null, null, null, null, {});
|
||||
buttonFlags,
|
||||
null,
|
||||
null,
|
||||
moreInfoCallback ? Zotero.getString('general.help') : null,
|
||||
null, {});
|
||||
|
||||
// Not OK -- return to file picker
|
||||
if (index == 1) {
|
||||
continue;
|
||||
}
|
||||
else if (index == 2) {
|
||||
setTimeout(function () {
|
||||
moreInfoCallback();
|
||||
}, 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var buttonFlags = ps.STD_YES_NO_BUTTONS;
|
||||
if (moreInfoCallback) {
|
||||
buttonFlags += ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
|
||||
}
|
||||
var index = ps.confirmEx(null,
|
||||
Zotero.getString('dataDir.selectedDirEmpty.title'),
|
||||
Zotero.getString('dataDir.selectedDirEmpty.text'),
|
||||
buttonFlags, null, null, null, null, {});
|
||||
Zotero.getString('dataDir.selectedDirEmpty.text', Zotero.appName) + '\n\n'
|
||||
+ Zotero.getString('dataDir.selectedDirEmpty.useNewDir'),
|
||||
buttonFlags,
|
||||
null,
|
||||
null,
|
||||
moreInfoCallback ? Zotero.getString('general.moreInformation') : null,
|
||||
null, {});
|
||||
|
||||
// Not OK -- return to file picker
|
||||
if (index == 1) {
|
||||
continue;
|
||||
}
|
||||
else if (index == 2) {
|
||||
setTimeout(function () {
|
||||
moreInfoCallback();
|
||||
}, 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1096,23 +1123,23 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
}
|
||||
|
||||
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
|
||||
if (!forceRestartNow) {
|
||||
if (!forceQuitNow) {
|
||||
buttonFlags += (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING);
|
||||
}
|
||||
var app = Zotero.isStandalone ? Zotero.getString('app.standalone') : Zotero.getString('app.firefox');
|
||||
var app = Zotero.appName;
|
||||
var index = ps.confirmEx(null,
|
||||
Zotero.getString('general.restartRequired'),
|
||||
Zotero.getString('general.restartRequiredForChange', app),
|
||||
Zotero.getString('general.restartRequiredForChange', app)
|
||||
+ "\n\n" + Zotero.getString('dataDir.moveFilesToNewLocation', app),
|
||||
buttonFlags,
|
||||
Zotero.getString('general.restartNow'),
|
||||
forceRestartNow ? null : Zotero.getString('general.restartLater'),
|
||||
Zotero.getString('general.quitApp', app),
|
||||
forceQuitNow ? null : Zotero.getString('general.restartLater'),
|
||||
null, null, {});
|
||||
|
||||
if (index == 0) {
|
||||
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Components.interfaces.nsIAppStartup);
|
||||
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit
|
||||
| Components.interfaces.nsIAppStartup.eRestart);
|
||||
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
|
||||
}
|
||||
|
||||
return useProfileDir ? true : file;
|
||||
|
|
|
@ -12,6 +12,7 @@ general.restartRequiredForChanges = %S must be restarted for the changes to take
|
|||
general.restartNow = Restart now
|
||||
general.restartLater = Restart later
|
||||
general.restartApp = Restart %S
|
||||
general.quitApp = Quit %S
|
||||
general.errorHasOccurred = An error has occurred.
|
||||
general.unknownErrorOccurred = An unknown error occurred.
|
||||
general.invalidResponseServer = Invalid response from server.
|
||||
|
@ -35,6 +36,7 @@ general.character.singular = character
|
|||
general.character.plural = characters
|
||||
general.create = Create
|
||||
general.delete = Delete
|
||||
general.moreInformation = More Information
|
||||
general.seeForMoreInformation = See %S for more information.
|
||||
general.enable = Enable
|
||||
general.disable = Disable
|
||||
|
@ -101,7 +103,9 @@ dataDir.selectDir = Select a Zotero data directory
|
|||
dataDir.selectedDirNonEmpty.title = Directory Not Empty
|
||||
dataDir.selectedDirNonEmpty.text = The directory you selected is not empty and does not appear to be a Zotero data directory.\n\nCreate Zotero files in this directory anyway?
|
||||
dataDir.selectedDirEmpty.title = Directory Empty
|
||||
dataDir.selectedDirEmpty.text = The directory you selected is empty. To move an existing Zotero data directory, you will need to manually copy files from the existing data directory to the new location. See http://zotero.org/support/zotero_data for more information.\n\nUse the new directory?
|
||||
dataDir.selectedDirEmpty.text = The directory you selected is empty. To move an existing Zotero data directory, you will need to manually move files from the existing data directory to the new location after %1$S has closed.
|
||||
dataDir.selectedDirEmpty.useNewDir = Use the new directory?
|
||||
dataDir.moveFilesToNewLocation = Be sure to move files from your existing Zotero data directory to the new location before reopening %1$S.
|
||||
dataDir.incompatibleDbVersion.title = Incompatible Database Version
|
||||
dataDir.incompatibleDbVersion.text = The currently selected data directory is not compatible with Zotero Standalone, which can share a database only with Zotero for Firefox 2.1b3 or later.\n\nUpgrade to the latest version of Zotero for Firefox first or select a different data directory for use with Zotero Standalone.
|
||||
dataDir.standaloneMigration.title = Existing Zotero Library Found
|
||||
|
|
Loading…
Reference in a new issue