diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 6a035fc5311249ca0b4fa1b3c61fcf7567da2809..70940dc4655415a97e9222a8603ca8bc314ae03a 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -29,6 +29,7 @@ #include "nsIAppShell.h" #include "nsIWidget.h" +#include "nsIWebShellWindow.h" #include "nsWebShellWindow.h" #include "nsWidgetsCID.h" @@ -48,6 +49,7 @@ static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID); static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID); static NS_DEFINE_IID(kIAppShellIID, NS_IAPPSHELL_IID); +static NS_DEFINE_IID(kIWebShellWindowIID, NS_IWEBSHELL_WINDOW_IID); @@ -162,6 +164,27 @@ nsAppShellService::DispatchNativeEvent(void * aEvent) NS_IMETHODIMP nsAppShellService::Shutdown(void) { + //mAppShell->Exit(); + while (mWindowList->Count() > 0) { + nsISupports * winSupports = mWindowList->ElementAt(0); + nsCOMPtr<nsIWidget> window(do_QueryInterface(winSupports)); + if (window) { + mWindowList->RemoveElementAt(0); + CloseTopLevelWindow(window); + } else { + nsCOMPtr<nsIWebShellWindow> webShellWin(do_QueryInterface(winSupports)); + if (webShellWin) { + nsIWidget * win; + webShellWin->GetWidget(win); + CloseTopLevelWindow(win); + } + //nsCOMPtr<nsIWebShellContainer> wsc(do_QueryInterface(winSupports)); + //if (wsc) { + // + //} + break; + } + } return NS_OK; } @@ -255,11 +278,18 @@ nsAppShellService::RegisterTopLevelWindow(nsIWidget* aWindow) rv = NS_ERROR_NULL_POINTER; else { nsWebShellWindow* window = (nsWebShellWindow *) data; + nsIWebShellWindow * webShellWin; + rv = window->QueryInterface(kIWebShellWindowIID, (void **) &webShellWin); + if (NS_SUCCEEDED(rv)) { + mWindowList->AppendElement(webShellWin); + } + // nsCOMPtr<nsIWebShellContainer> wsc(window); DRaM - nsIWebShellContainer* wsc; + /*nsIWebShellContainer* wsc; rv = window->QueryInterface(kIWebShellContainerIID, (void **) &wsc); if (NS_SUCCEEDED(rv)) mWindowList->AppendElement(wsc); + */ } return rv; } diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 9e44ae84e7620939f27aec5526441d85c45af9f3..5aed747032feefac4868dd2666b38f684e154dd8 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -640,6 +640,26 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi // Make nsMenuItem a child of nsMenu //pnsMenu->AddMenuItem(pnsMenuItem); // XXX adds an additional item ConnectCommandToOneGUINode(menuitemNode); + //----------------------------------------------------------- + // This block contains temporary menu hookup code. + //----------------------------------------------------------- + { + nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(menuitemNode)); + if (!domElement) + return; + + nsAutoString cmdAtom("cmd"); + nsString cmdName; + + domElement->GetAttribute(cmdAtom, cmdName); + nsCOMPtr<nsIXULCommand> cmd(FindCommandByName(cmdName)); + if (cmd) { + nsCOMPtr<nsIMenuListener> listener(do_QueryInterface(cmd)); + pnsMenuItem->AddMenuListener(listener); + } + + } + //----------------------------------------------------------- } }