Skip to content

Commit

Permalink
Use "CustomizableUI" API to add toolbar button, if available
Browse files Browse the repository at this point in the history
  • Loading branch information
Infocatcher committed Dec 12, 2013
1 parent 64c447f commit 34d610d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,12 @@ var windowsObserver = {
.getElementsByAttribute("id", this.toolbarButtonId);
return btns.length && btns[0];
},
addButtonToPalette: function(window, btn) {
_log("Insert toolbar button #" + btn.id + " into palette");
this.getToolbox(window)
.palette
.appendChild(btn);
},
getNewTabButton: function(window) {
return window.document.getAnonymousElementByAttribute(
window.gBrowser.tabContainer,
Expand Down Expand Up @@ -1978,6 +1984,16 @@ var windowsObserver = {
window.addEventListener("aftercustomization", this, false);
}

if("CustomizableUI" in window) try { // Australis
this.addButtonToPalette(window, tb);
window.CustomizableUI.ensureWidgetPlacedInWindow(tb.id, window);
_log("Toolbar button: use CustomizableUI.ensureWidgetPlacedInWindow()");
return;
}
catch(e) {
Components.utils.reportError(e);
}

var toolbars = document.getElementsByTagName("toolbar");
function isSep(id) {
return id == "separator" || id == "spring" || id == "spacer";
Expand Down Expand Up @@ -2034,11 +2050,7 @@ var windowsObserver = {
_log("Insert toolbar button " + (insPos ? "before " + insPos.id : "at the end"));
return;
}

_log("Insert toolbar button into palette");
this.getToolbox(window)
.palette
.appendChild(tb);
this.addButtonToPalette(window, tb);
},
hasNodeAfter: function(node, id) {
for(var ns = node.nextSibling; ns; ns = ns.nextSibling)
Expand Down

0 comments on commit 34d610d

Please sign in to comment.