Add "check for updates" to main menu and AppMenu v2

Tag #963.
pull/1/head
wolfbeast 4 years ago committed by Roy Tam
parent 24fda598ca
commit 114e3529bc
  1. 10
      application/palemoon/base/content/baseMenuOverlay.xul
  2. 9
      application/palemoon/base/content/browser-appmenu.inc
  3. 111
      application/palemoon/base/content/utilityOverlay.js
  4. 1
      application/palemoon/locales/en-US/chrome/browser/baseMenuOverlay.dtd
  5. 16
      application/palemoon/locales/en-US/chrome/browser/browser.properties

@ -41,7 +41,7 @@
label="&helpMenu.label;"
accesskey="&helpMenu.accesskey;">
#endif
<menupopup id="menu_HelpPopup">
<menupopup id="menu_HelpPopup" onpopupshowing="buildHelpMenu();">
<menuitem id="menu_openHelp"
oncommand="openHelpLink('firefox-help')"
onclick="checkForMiddleClick(this, event);"
@ -66,6 +66,14 @@
accesskey="&helpSafeMode.accesskey;"
label="&helpSafeMode.label;"
oncommand="restart(true);"/>
<menuseparator id="updateSeparator"/>
<menuitem id="checkForUpdates" class="menuitem-iconic"
#ifdef MOZ_UPDATER
label="&updateCmd.label;"
oncommand="checkForUpdates();"/>
#else
hidden="true"/>
#endif
<menuseparator id="aboutSeparator"/>
<menuitem id="aboutName"
accesskey="&aboutProduct.accesskey;"

@ -341,7 +341,7 @@
<splitmenu id="appmenu_help"
label="&helpMenu.label;"
oncommand="openHelpLink('firefox-help')">
<menupopup id="appmenu_helpMenupopup">
<menupopup id="appmenu_helpMenupopup" onpopupshowing="buildHelpMenu();">
<menuitem id="appmenu_openHelp"
label="&helpMenu.label;"
oncommand="openHelpLink('firefox-help')"
@ -358,6 +358,13 @@
<menuitem id="appmenu_safeMode"
label="&appMenuSafeMode.label;"
oncommand="restart(true);"/>
#ifdef MOZ_UPDATER
<menuseparator/>
<menuitem id="appmenu_checkForUpdates"
class="menuitem-iconic"
label="&updateCmd.label;"
oncommand="checkForUpdates();"/>
#endif
<menuseparator/>
<menuitem id="appmenu_about"
label="&aboutProduct.label;"

@ -541,6 +541,117 @@ function isBidiEnabled() {
return rv;
}
#ifdef MOZ_UPDATER
/**
* Opens the update manager and checks for updates to the application.
*/
function checkForUpdates()
{
var um =
Components.classes["@mozilla.org/updates/update-manager;1"].
getService(Components.interfaces.nsIUpdateManager);
var prompter =
Components.classes["@mozilla.org/updates/update-prompt;1"].
createInstance(Components.interfaces.nsIUpdatePrompt);
// If there's an update ready to be applied, show the "Update Downloaded"
// UI instead and let the user know they have to restart the application for
// the changes to be applied.
if (um.activeUpdate && um.activeUpdate.state == "pending")
prompter.showUpdateDownloaded(um.activeUpdate);
else
prompter.checkForUpdates();
}
#endif
/**
* Set up the help menu software update items to show proper status,
* also disabling the items if update is disabled.
*/
function buildHelpMenu()
{
#ifdef MOZ_UPDATER
var updates =
Components.classes["@mozilla.org/updates/update-service;1"].
getService(Components.interfaces.nsIApplicationUpdateService);
var um =
Components.classes["@mozilla.org/updates/update-manager;1"].
getService(Components.interfaces.nsIUpdateManager);
// Disable the UI if the update enabled pref has been locked by the
// administrator or if we cannot update for some other reason.
var checkForUpdates = document.getElementById("checkForUpdates");
var appMenuCheckForUpdates = document.getElementById("appmenu_checkForUpdates");
var canCheckForUpdates = updates.canCheckForUpdates;
checkForUpdates.setAttribute("disabled", !canCheckForUpdates);
appMenuCheckForUpdates.setAttribute("disabled", !canCheckForUpdates);
if (!canCheckForUpdates)
return;
var strings = document.getElementById("bundle_browser");
var activeUpdate = um.activeUpdate;
// If there's an active update, substitute its name into the label
// we show for this item, otherwise display a generic label.
function getStringWithUpdateName(key) {
if (activeUpdate && activeUpdate.name)
return strings.getFormattedString(key, [activeUpdate.name]);
return strings.getString(key + "Fallback");
}
// By default, show "Check for Updates..." from updatesItem_default or
// updatesItem_defaultFallback
var key = "default";
if (activeUpdate) {
switch (activeUpdate.state) {
case "downloading":
// If we're downloading an update at present, show the text:
// "Downloading Thunderbird x.x..." from updatesItem_downloading or
// updatesItem_downloadingFallback, otherwise we're paused, and show
// "Resume Downloading Thunderbird x.x..." from updatesItem_resume or
// updatesItem_resumeFallback
key = updates.isDownloading ? "downloading" : "resume";
break;
case "pending":
// If we're waiting for the user to restart, show: "Apply Downloaded
// Updates Now..." from updatesItem_pending or
// updatesItem_pendingFallback
key = "pending";
break;
}
}
checkForUpdates.label = getStringWithUpdateName("updatesItem_" + key);
appMenuCheckForUpdates.label = getStringWithUpdateName("updatesItem_" + key);
// updatesItem_default.accesskey, updatesItem_downloading.accesskey,
// updatesItem_resume.accesskey or updatesItem_pending.accesskey
checkForUpdates.accessKey = strings.getString("updatesItem_" + key +
".accesskey");
appMenuCheckForUpdates.accessKey = strings.getString("updatesItem_" + key +
".accesskey");
if (um.activeUpdate && updates.isDownloading) {
checkForUpdates.setAttribute("loading", "true");
appMenuCheckForUpdates.setAttribute("loading", "true");
} else {
checkForUpdates.removeAttribute("loading");
appMenuCheckForUpdates.removeAttribute("loading");
}
#else
#ifndef XP_MACOSX
// Some extensions may rely on these being present so only hide the about
// separator when there are no elements besides the check for updates menuitem
// in between the about separator and the updates separator.
var updatesSeparator = document.getElementById("updatesSeparator");
var aboutSeparator = document.getElementById("aboutSeparator");
var checkForUpdates = document.getElementById("checkForUpdates");
if (updatesSeparator.nextSibling === checkForUpdates &&
checkForUpdates.nextSibling === aboutSeparator)
updatesSeparator.hidden = true;
#endif
#endif
}
function openAboutDialog() {
var enumerator = Services.wm.getEnumerator("Browser:About");
while (enumerator.hasMoreElements()) {

@ -14,6 +14,7 @@
for the help button in the menubar but Gnome does not. -->
<!ENTITY helpMenuWin.label "Help">
<!ENTITY helpMenuWin.accesskey "H">
<!ENTITY updateCmd.label "Check for Updates…">
<!ENTITY aboutProduct.label "About &brandShortName;">
<!ENTITY aboutProduct.accesskey "A">
<!ENTITY productHelp.label "&brandShortName; Help">

@ -201,6 +201,22 @@ update.openUpdateUI.upgradeButton.accesskey=U
update.restart.upgradeButton.label=Upgrade Now
update.restart.upgradeButton.accesskey=U
# Check for Updates in the Help Menu
# LOCALIZATION NOTE (updatesItem_*): these are alternative labels for Check for Update item in Help menu.
# Which one is used depends on Update process state.
updatesItem_default=Check for Updates…
updatesItem_defaultFallback=Check for Updates…
updatesItem_default.accesskey=C
updatesItem_downloading=Downloading %S…
updatesItem_downloadingFallback=Downloading Update…
updatesItem_downloading.accesskey=D
updatesItem_resume=Resume Downloading %S…
updatesItem_resumeFallback=Resume Downloading Update…
updatesItem_resume.accesskey=D
updatesItem_pending=Apply Downloaded Update Now…
updatesItem_pendingFallback=Apply Downloaded Update Now…
updatesItem_pending.accesskey=D
# RSS Pretty Print
feedShowFeedNew=Subscribe to '%S'…

Loading…
Cancel
Save