diff --git a/toolkit/mozapps/downloads/content/downloads.js b/toolkit/mozapps/downloads/content/downloads.js index a4264221fc7..f4d55bc361b 100644 --- a/toolkit/mozapps/downloads/content/downloads.js +++ b/toolkit/mozapps/downloads/content/downloads.js @@ -629,19 +629,47 @@ var gDownloadDNDObserver = var gDownloadViewController = { supportsCommand: function (aCommand) { - return aCommand == "cmd_cleanUp"; + var commandNode = document.getElementById(aCommand); + return commandNode && commandNode.parentNode == document.getElementById("downloadsCommands"); }, isCommandEnabled: function (aCommand) { - if (aCommand == "cmd_cleanUp") + if (!window.gDownloadsView) + return false; + + switch (aCommand) { + case "cmd_cleanup": return gDownloadManager.canCleanUp; + case "cmd_remove": + return gDownloadsView.selectedItem != null; + } return false; }, doCommand: function (aCommand) { - if (aCommand == "cmd_cleanUp" && this.isCommandEnabled(aCommand)) { + if (this.isCommandEnabled(aCommand)) + this.commands[aCommand](gDownloadsView.selectedItem); + }, + + onCommandUpdate: function () + { + var downloadsCommands = document.getElementById("downloadsCommands"); + for (var i = 0; i < downloadsCommands.childNodes.length; ++i) + this.updateCommand(downloadsCommands.childNodes[i]); + }, + + updateCommand: function (command) + { + if (this.isCommandEnabled(command.id)) + command.removeAttribute("disabled"); + else + command.setAttribute("disabled", "true"); + }, + + commands: { + cmd_cleanup: function() { gDownloadManager.cleanUp(); // Update UI @@ -655,15 +683,12 @@ var gDownloadViewController = { gDownloadsView.removeChild(gDownloadsView.children[i]); } - this.onCommandUpdate(); + gDownloadViewController.onCommandUpdate(); + }, + + cmd_remove: function(aSelectedItem) { + fireEventForElement(aSelectedItem, 'remove'); } - }, - - onCommandUpdate: function () - { - var command = "cmd_cleanUp"; - var enabled = this.isCommandEnabled(command); - goSetCommandEnabled(command, enabled); } }; diff --git a/toolkit/mozapps/downloads/content/downloads.xul b/toolkit/mozapps/downloads/content/downloads.xul index 54be7e7b018..8dc21e1b973 100644 --- a/toolkit/mozapps/downloads/content/downloads.xul +++ b/toolkit/mozapps/downloads/content/downloads.xul @@ -78,10 +78,12 @@ commandupdater="true" oncommandupdate="gDownloadViewController.onCommandUpdate();"> + + #ifdef XP_GNOME diff --git a/toolkit/mozapps/extensions/content/extensions.xul b/toolkit/mozapps/extensions/content/extensions.xul index a1c3921de0f..c4831b296d1 100644 --- a/toolkit/mozapps/extensions/content/extensions.xul +++ b/toolkit/mozapps/extensions/content/extensions.xul @@ -79,6 +79,8 @@ oncommand="gExtensionsViewController.doCommand('cmd_about');"/> +