[Project_owners] Opening "Customize Toolbar" window

Michael Buckley michael.buckley at hotmail.com
Sat Sep 2 09:59:56 EDT 2006


Brian King wrote:
>Bartosz Piec wrote:
>>Hello,
>>
>>How to open a "Customize Toolbar" window from my extension's preference 
>>window? I've tried to execute the code from Firefox's browser.js file:
>>
>>function BrowserCustomizeToolbar()
>>{
>>   // Disable the toolbar context menu items
>>   var menubar = document.getElementById("main-menubar");
>>   for (var i = 0; i < menubar.childNodes.length;   i)
>>     menubar.childNodes[i].setAttribute("disabled", true);
>>
>>   var cmd = document.getElementById("cmd_CustomizeToolbars");
>>   cmd.setAttribute("disabled", "true");
>>
>>   window.openDialog("chrome://global/content/customizeToolbar.xul", 
>>"CustomizeToolbar",
>>                     "chrome,all,dependent", 
>>document.getElementById("navigator-toolbox"));
>>}
>>
>>but the menubar variable is null.
>
>Sounds like the wrong scope, i.e. Try using the window manager to get the 
>browser window (lets call it win), then replace all occurrences of 
>document.getElementById with win.document.getElementById.
>
>However, the Customize dialog may not function properly if not opened by 
>the main browser window.
>
I think you should try to run the BrowserCustomizeToolbar() that belongs
to the main window.  This code should work though I have not tested it.

function CustomizeToolbar() {
  var win =
Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).
        getMostRecentWindow("navigator:browser");

       win.BrowserCustomizeToolbar();

}

_________________________________________________________________
Nothing but cars & over 100,000 of them at carsales.com.au 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801577%2Fpi%5F1005244%2Fai%5F836752&_t=12345&_r=emailtagline_tig_over100k&_m=EXT



More information about the Project_owners mailing list