From c9b4daf1524b9e405ad6eae28e8aad85acc7ef51 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Fri, 22 Dec 2023 21:05:36 -0800 Subject: [PATCH] Add Help -> Restart in Safe Mode... and a toolbar indicator (#3209) --- .../content/zotero/standalone/standalone.js | 23 +++++++++++++++++++ chrome/content/zotero/zoteroPane.js | 12 +++++++++- chrome/content/zotero/zoteroPane.xhtml | 3 +++ chrome/locale/en-US/zotero/zotero.ftl | 8 ++++++- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index c668d20e59..83262f0e0c 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -645,6 +645,29 @@ const ZoteroStandalone = new function() { }; + this.promptForRestartInSafeMode = async function () { + let ps = Services.prompt; + let [title, description] = await document.l10n.formatValues([ + 'restart-in-safe-mode-dialog-title', + 'restart-in-safe-mode-dialog-description' + ]); + let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING + + ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL; + let index = ps.confirmEx( + null, + title, + description, + buttonFlags, + Zotero.getString('general.restartNow'), + null, null, null, {} + ); + + if (index == 0) { + Services.startup.restartInSafeMode(Ci.nsIAppStartup.eAttemptQuit); + } + }; + + this.updateAddonsPane = function (doc) { //var rootWindow = doc.ownerGlobal.windowRoot.ownerGlobal; diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index b52f66a70e..fd83ed14ae 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -415,7 +415,7 @@ var ZoteroPane = new function() Zotero.hiDPI = window.devicePixelRatio > 1; Zotero.hiDPISuffix = Zotero.hiDPI ? "@2x" : ""; - // Show warning in toolbar for 'dev' channel builds + // Show warning in toolbar for 'dev' channel builds and safe mode try { let isDevBuild = Zotero.version.includes('-dev'); // Uncomment to test @@ -430,6 +430,16 @@ var ZoteroPane = new function() let syncStop = document.getElementById('zotero-tb-sync-stop'); syncStop.parentNode.insertBefore(label, syncStop); } + else if (Services.appinfo.inSafeMode) { + let label = document.createElement('span'); + label.setAttribute('style', 'font-weight: bold; color: darkblue; cursor: pointer; margin-right: .5em'); + label.onclick = function () { + Zotero.Utilities.Internal.quit(true); + }; + label.textContent = 'Safe Mode'; + let syncStop = document.getElementById('zotero-tb-sync-stop'); + syncStop.parentNode.insertBefore(label, syncStop); + } } catch (e) { Zotero.logError(e); diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml index eb272d1cab..e23e051b9f 100644 --- a/chrome/content/zotero/zoteroPane.xhtml +++ b/chrome/content/zotero/zoteroPane.xhtml @@ -673,6 +673,9 @@ oncommand="ZoteroStandalone.DebugOutput.restartEnabled()"/> + Considerations for licensors before placing your work under a CC license. Note that the license you apply cannot be revoked, even if you later choose different terms or cease publishing the work. -licenses-cc0-more-info = Be sure you have read the Creative Commons CC0 FAQ before applying CC0 to your work. Please note that dedicating your work to the public domain is irreversible, even if you later choose different terms or cease publishing the work. \ No newline at end of file +licenses-cc0-more-info = Be sure you have read the Creative Commons CC0 FAQ before applying CC0 to your work. Please note that dedicating your work to the public domain is irreversible, even if you later choose different terms or cease publishing the work. + +restart-in-safe-mode-menuitem = + .label = Restart in Safe Mode… + .accesskey = S +restart-in-safe-mode-dialog-title = Restart in Safe Mode +restart-in-safe-mode-dialog-description = { -app-name } will restart with all plugins disabled. Some features may not function correctly while Safe Mode is enabled.