Bug 407899 - "SeaMonkey would like separate default modes/iconsizes for each toolbar" (Each toolbar can have defaults different from that of the toolbox) [p=philip.chee@gmail.com (Philip Chee) r=gavin a1.9=beltzner]
authorreed@reedloden.com
Wed, 06 Feb 2008 13:52:29 -0800
changeset 11280 7b12cb9c8c2009a3817b689dc6bf0d54dfbc89df
parent 11279 fe7e152ddb182c74fbe851b04a971777e6fee403
child 11281 bf7ad73a6b8cb161dbda95a25c1914c641d6bef4
push idunknown
push userunknown
push dateunknown
reviewersgavin
bugs407899
milestone1.9b4pre
Bug 407899 - "SeaMonkey would like separate default modes/iconsizes for each toolbar" (Each toolbar can have defaults different from that of the toolbox) [p=philip.chee@gmail.com (Philip Chee) r=gavin a1.9=beltzner]
toolkit/content/customizeToolbar.js
--- a/toolkit/content/customizeToolbar.js
+++ b/toolkit/content/customizeToolbar.js
@@ -575,50 +575,48 @@ function addNewToolbar()
  * remove all custom toolbars, and rebuild the palette.
  */
 function restoreDefaultSet()
 {
   // Save disabled/command states, because we're
   // going to recreate the wrappers and lose this
   var savedAttributes = saveItemAttributes(["itemdisabled", "itemcommand"]);
 
-  // Restore the defaultset for fixed toolbars.
-  var toolbar = gToolbox.firstChild;
-  while (toolbar) {
-    if (isCustomizableToolbar(toolbar)) {
-      if (!toolbar.hasAttribute("customindex")) {
-        var defaultSet = toolbar.getAttribute("defaultset");
-        if (defaultSet)
-          toolbar.currentSet = defaultSet;
-      }
-    }
-    toolbar = toolbar.nextSibling;
-  }
-
-  // Restore the default icon size and mode.
-  var defaultMode = gToolbox.getAttribute("defaultmode");
-  var defaultIconsSmall = gToolbox.getAttribute("defaulticonsize") == "small";
-
-  updateIconSize(defaultIconsSmall);
-  document.getElementById("smallicons").checked = defaultIconsSmall;
-  updateToolbarMode(defaultMode);
-  document.getElementById("modelist").value = defaultMode;
-  
   // Remove all of the customized toolbars.
   var child = gToolbox.lastChild;
   while (child) {
     if (child.hasAttribute("customindex")) {
       var thisChild = child;
       child = child.previousSibling;
       gToolbox.removeChild(thisChild);
     } else {
       child = child.previousSibling;
     }
   }
-  
+
+  // Restore the defaultset for fixed toolbars.
+  var toolbar = gToolbox.firstChild;
+  while (toolbar) {
+    if (isCustomizableToolbar(toolbar)) {
+      var defaultSet = toolbar.getAttribute("defaultset");
+      if (defaultSet)
+        toolbar.currentSet = defaultSet;
+    }
+    toolbar = toolbar.nextSibling;
+  }
+
+  // Restore the default icon size and mode.
+  var defaultMode = gToolbox.getAttribute("defaultmode");
+  var defaultIconsSmall = gToolbox.getAttribute("defaulticonsize") == "small";
+
+  updateIconSize(defaultIconsSmall, true);
+  document.getElementById("smallicons").checked = defaultIconsSmall;
+  updateToolbarMode(defaultMode, true);
+  document.getElementById("modelist").value = defaultMode;
+
   // Now rebuild the palette.
   buildPalette();
 
   // Now re-wrap the items on the toolbar.
   wrapToolbarItems();
 
   // Restore the disabled and command states
   restoreItemAttributes(["itemdisabled", "itemcommand"], savedAttributes);
@@ -658,41 +656,47 @@ function restoreItemAttributes(aAttribut
       var savedAttr = aSavedAttrList[j];
       if (paletteItem.id == savedAttr[0]) {
         paletteItem.setAttribute(savedAttr[1], savedAttr[2]);
       }
     }
   }
 }
 
-function updateIconSize(aUseSmallIcons)
+function updateIconSize(aUseSmallIcons, localDefault)
 {
   gToolboxIconSize = aUseSmallIcons ? "small" : "large";
   
   setAttribute(gToolbox, "iconsize", gToolboxIconSize);
   gToolboxDocument.persist(gToolbox.id, "iconsize");
   
   for (var i = 0; i < gToolbox.childNodes.length; ++i) {
     var toolbar = getToolbarAt(i);
     if (isCustomizableToolbar(toolbar)) {
-      setAttribute(toolbar, "iconsize", gToolboxIconSize);
+      var toolbarIconSize = (localDefault && toolbar.hasAttribute("defaulticonsize")) ?
+                            toolbar.getAttribute("defaulticonsize") :
+                            gToolboxIconSize;
+      setAttribute(toolbar, "iconsize", toolbarIconSize);
       gToolboxDocument.persist(toolbar.id, "iconsize");
     }
   }
 }
 
-function updateToolbarMode(aModeValue)
+function updateToolbarMode(aModeValue, localDefault)
 {
   setAttribute(gToolbox, "mode", aModeValue);
   gToolboxDocument.persist(gToolbox.id, "mode");
 
   for (var i = 0; i < gToolbox.childNodes.length; ++i) {
     var toolbar = getToolbarAt(i);
     if (isCustomizableToolbar(toolbar)) {
-      setAttribute(toolbar, "mode", aModeValue);
+      var toolbarMode = (localDefault && toolbar.hasAttribute("defaultmode")) ?
+                        toolbar.getAttribute("defaultmode") :
+                        aModeValue;
+      setAttribute(toolbar, "mode", toolbarMode);
       gToolboxDocument.persist(toolbar.id, "mode");
     }
   }
 
   var iconSizeCheckbox = document.getElementById("smallicons");
   iconSizeCheckbox.disabled = aModeValue == "text";
 }