Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How To Enumerate Application Windows?

8 views
Skip to first unread message

us...@domain.invalid

unread,
Nov 29, 2006, 9:12:00 PM11/29/06
to
I am trying to remove some of the ugly hacks in my add-on. For
multi-window applications, it needs to occasionally iterate over each of
the application windows and do something to my add-on's UI.

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

Myk Melez

unread,
Nov 29, 2006, 9:55:40 PM11/29/06
to
us...@domain.invalid wrote:

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

us...@domain.invalid

unread,
Nov 30, 2006, 11:09:31 AM11/30/06
to
Thanks so much for the response. It works exactly as I'd hoped. It does
seem, however, that the window type string ("navigator:browser") for top
level windows varies from application to application. I am supporting
Sunbird and T-Bird in my add-on as well. Any idea where I can get/see
the appropriate string for these applications? Thanks.

Myk Melez

unread,
Nov 30, 2006, 2:34:07 AM11/30/06
to
us...@domain.invalid wrote:
> Thanks so much for the response. It works exactly as I'd hoped. It does
> seem, however, that the window type string ("navigator:browser") for top
> level windows varies from application to application. I am supporting
> Sunbird and T-Bird in my add-on as well. Any idea where I can get/see
> the appropriate string for these applications? Thanks.

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

Eric Shepherd

unread,
Nov 30, 2006, 6:56:39 PM11/30/06
to dev-ext...@lists.mozilla.org
This is actually documented:

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

0 new messages