I have cobbled something together that works fine. But it seems that the
application must know of its open windows. Is there any way for my
add-on to get access to this information? I cannot seem to find it.
Thanks,
David
Use the window mediator
<http://lxr.mozilla.org/mozilla/source/xpfe/appshell/public/nsIWindowMediator.idl>
to iterate over open windows, f.e.:
var mediator =
Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator);
// Grab browser windows; for all windows, pass null as the parameter.
var windows = mediator.getEnumerator("navigator:browser");
while (windows.hasMoreElements()) {
var win = windows.getNext();
// Do something with the window...
}
-myk
The window type is set by the "windowtype" attribute of the XUL "window"
tag. For Sunbird, the type appears to be "calendarMainWindow"
<http://lxr.mozilla.org/mozilla/source/calendar/sunbird/base/content/calendar.xul#64>.
For Thunderbird, I think it's "mail:3pane"
<http://lxr.mozilla.org/mozilla/source/mail/base/content/messenger.xul#56>.
-myk
http://developer.mozilla.org/en/docs/
nsIWindowMediator#Enumerating_windows
However, none of the searches I tried to use in order to find it
worked (I only found it by searching on nsIWindowMediator). I've
made some edits to the document that I think once the page is
reindexed by the search system (I don't know how often that happens,
but it oughtn't to be long) will make it easier to find this
information doing a search.
Eric Shepherd
Developer Documentation Lead
she...@mozilla.com