Bug 342329: Install updates should be disabled if all add-ons have been deselected for update. r=dtownsend
authorJae-Seong Lee-Russo <lusian@gmail.com>
Mon, 19 Oct 2009 12:08:12 -0700
changeset 34250 8e1ea35b129498f73ad127f32a42bfd1b3d6270c
parent 34249 914f639bc64535449a705f5b3ddb494ec53dbdee
child 34251 3314dc670ff48b1420ee6564e15d98cd047c751c
push id115
push userbmcbride@mozilla.com
push dateMon, 19 Oct 2009 23:27:00 +0000
reviewersdtownsend
bugs342329
milestone1.9.3a1pre
Bug 342329: Install updates should be disabled if all add-ons have been deselected for update. r=dtownsend
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/content/extensions.xml
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -1111,16 +1111,31 @@ function togglePluginDisabled(aName, aDe
   gPluginsDS.Change(gRDF.GetResource(PREFIX_ITEM_URI + plugin.filename),
                     gRDF.GetResource(PREFIX_NS_EM + "isDisabled"),
                     gRDF.GetLiteral(isDisabled ? "false" : "true"),
                     gRDF.GetLiteral(isDisabled ? "true" : "false"));
   gExtensionsViewController.onCommandUpdate();
   gExtensionsView.selectedItem.focus();
 }
 
+// Disable the "Install Updates" button when no Add-ons are selected for update
+function toggleInstallUpdates()
+{
+  var disableInstallUpdate = true;
+  var children = gExtensionsView.children;
+  for (var i = 0; i < children.length; ++i) {
+    var includeUpdate = document.getAnonymousElementByAttribute(children[i], "anonid", "includeUpdate");
+    if (includeUpdate && includeUpdate.checked) {
+      disableInstallUpdate = false;
+      break;
+    }
+  }
+  setElementDisabledByID("cmd_installUpdatesAll", disableInstallUpdate);
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // Startup, Shutdown
 function Startup()
 {
   gExtensionStrings = document.getElementById("extensionsStrings");
   gPref = Components.classes["@mozilla.org/preferences-service;1"]
                     .getService(nsIPrefBranch2);
   var defaultPref = gPref.QueryInterface(Components.interfaces.nsIPrefService)
@@ -2889,16 +2904,18 @@ var gExtensionsViewController = {
       updateOptionalViews();
       updateGlobalCommands();
     },
 
     cmd_includeUpdate: function (aSelectedItem)
     {
       var includeUpdate = document.getAnonymousElementByAttribute(aSelectedItem, "anonid", "includeUpdate");
       includeUpdate.checked = !includeUpdate.checked;
+
+      toggleInstallUpdates();
     },
 
     cmd_uninstall: function (aSelectedItem)
     {
       // Confirm the uninstall
       var name = aSelectedItem.getAttribute("name");
       var dependentItems = [];
       if (!aSelectedItem.hasAttribute("lwtheme")) {
--- a/toolkit/mozapps/extensions/content/extensions.xml
+++ b/toolkit/mozapps/extensions/content/extensions.xml
@@ -815,17 +815,18 @@
         <xul:vbox flex="1">
           <xul:hbox class="addon-name-version" xbl:inherits="name, version"/>
           <xul:hbox>
             <xul:label xbl:inherits="value=updateAvailableMsg" flex="1" crop="end"/>
           </xul:hbox>
           <xul:hbox pack="end" align="end">
             <xul:checkbox anonid="includeUpdate" class="includeUpdate" checked="true"
             label="&includeUpdate.label;" tooltiptext="&includeUpdate.tooltip;"
-            includeUpdateAccesskey="&includeUpdate.accesskey;" accesskey="&includeUpdate.accesskey;"/>
+            includeUpdateAccesskey="&includeUpdate.accesskey;" accesskey="&includeUpdate.accesskey;"
+            oncommand="toggleInstallUpdates();"/>
           </xul:hbox>
         </xul:vbox>
       </xul:hbox>
     </content>
 
     <implementation>
       <constructor>
         var updatedVersion = this.getAttribute('availableUpdateVersion');