Part of bug #75745. Get modal dialogs from the window watcher service working on linux. r=ccarlen, sr=tor

This commit is contained in:
blizzard%redhat.com 2001-05-02 02:49:07 +00:00
Родитель 12f8a59772
Коммит a6e6c3a8f2
5 изменённых файлов: 73 добавлений и 198 удалений

Просмотреть файл

@ -54,7 +54,7 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
// give the widget a chance to attach any listeners
mOwner->ContentStateChange();
// if we've got the start flag, emit the signal
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT) &&
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
(aStateFlags & GTK_MOZ_EMBED_FLAG_START))
{
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
@ -80,7 +80,7 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
(const char *)uriString, aStateFlags, aStatus);
// and for stop, too
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT) &&
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
(aStateFlags & GTK_MOZ_EMBED_FLAG_STOP))
{
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),

Просмотреть файл

@ -34,10 +34,12 @@ EmbedWindow::EmbedWindow(void)
NS_INIT_REFCNT();
mOwner = nsnull;
mVisibility = PR_FALSE;
mIsModal = PR_FALSE;
}
EmbedWindow::~EmbedWindow(void)
{
ExitModalEventLoop(PR_FALSE);
}
nsresult
@ -86,6 +88,8 @@ EmbedWindow::CreateWindow(void)
void
EmbedWindow::ReleaseChildren(void)
{
ExitModalEventLoop(PR_FALSE);
mBaseWindow->Destroy();
mBaseWindow = 0;
mWebBrowser = 0;
@ -102,7 +106,6 @@ NS_INTERFACE_MAP_BEGIN(EmbedWindow)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_END
@ -218,19 +221,32 @@ EmbedWindow::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
NS_IMETHODIMP
EmbedWindow::ShowAsModal(void)
{
return NS_ERROR_NOT_IMPLEMENTED;
mIsModal = PR_TRUE;
GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
gtk_grab_add(toplevel);
gtk_main();
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::IsWindowModal(PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
*_retval = mIsModal;
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::ExitModalEventLoop(nsresult aStatus)
{
return NS_ERROR_NOT_IMPLEMENTED;
if (mIsModal) {
GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
gtk_grab_remove(toplevel);
mIsModal = PR_FALSE;
gtk_main_quit();
}
return NS_OK;
}
// nsIWebBrowserChromeFocus
@ -410,190 +426,6 @@ EmbedWindow::OnHideTooltip(void)
return NS_OK;
}
// nsIPrompt
NS_IMETHODIMP
EmbedWindow::Alert(const PRUnichar *aDialogTitle, const PRUnichar *aText)
{
EmbedPrompter prompter;
prompter.SetTitle(aDialogTitle);
prompter.SetMessageText(aText);
prompter.Create(EmbedPrompter::TYPE_ALERT);
prompter.Run();
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::AlertCheck(const PRUnichar *aDialogTitle,
const PRUnichar *aText,
const PRUnichar *aCheckMsg, PRBool *aCheckValue)
{
EmbedPrompter prompter;
prompter.SetTitle(aDialogTitle);
prompter.SetMessageText(aText);
prompter.SetCheckMessage(aCheckMsg);
prompter.SetCheckValue(*aCheckValue);
prompter.Create(EmbedPrompter::TYPE_ALERT_CHECK);
prompter.Run();
prompter.GetCheckValue(aCheckValue);
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::Confirm(const PRUnichar *aDialogTitle, const PRUnichar *aText,
PRBool *_retval)
{
EmbedPrompter prompter;
prompter.SetTitle(aDialogTitle);
prompter.SetMessageText(aText);
prompter.Create(EmbedPrompter::TYPE_CONFIRM);
prompter.Run();
prompter.GetConfirmValue(_retval);
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::ConfirmCheck(const PRUnichar *aDialogTitle,
const PRUnichar *aText, const PRUnichar *aCheckMsg,
PRBool *aCheckValue, PRBool *_retval)
{
EmbedPrompter prompter;
prompter.SetTitle(aDialogTitle);
prompter.SetMessageText(aText);
prompter.SetCheckMessage(aCheckMsg);
prompter.SetCheckValue(*aCheckValue);
prompter.Create(EmbedPrompter::TYPE_CONFIRM);
prompter.Run();
prompter.GetConfirmValue(_retval);
if (*_retval)
prompter.GetCheckValue(aCheckValue);
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::ConfirmEx(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUint32 button0And1Flags, const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
EmbedWindow::Prompt(const PRUnichar *aDialogTitle, const PRUnichar *aText,
PRUnichar **result,
const PRUnichar *aCheckMsg, PRBool *aCheckValue,
PRBool *_retval)
{
EmbedPrompter prompter;
prompter.SetTitle(aDialogTitle);
prompter.SetMessageText(aText);
if (result && *result)
prompter.SetTextValue(*result);
if (aCheckValue) {
prompter.SetCheckValue(*aCheckValue);
if (aCheckMsg)
prompter.SetCheckMessage(aCheckMsg);
else
prompter.SetCheckMessage(NS_LITERAL_STRING("Save This Value").get());
}
prompter.Create(EmbedPrompter::TYPE_PROMPT);
prompter.Run();
prompter.GetConfirmValue(_retval);
if (*_retval) {
if (result && *result) {
nsMemory::Free(*result);
*result = nsnull;
}
prompter.GetTextValue(result);
if (aCheckValue)
prompter.GetCheckValue(aCheckValue);
}
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::PromptUsernameAndPassword(const PRUnichar *aDialogTitle,
const PRUnichar *aText,
PRUnichar **aUser, PRUnichar **aPwd,
const PRUnichar *aCheckMsg, PRBool *aCheckValue,
PRBool *_retval)
{
EmbedPrompter prompter;
prompter.SetTitle(aDialogTitle);
prompter.SetMessageText(aText);
if (aUser && *aUser)
prompter.SetUser(*aUser);
if (aPwd && *aPwd)
prompter.SetPassword(*aPwd);
if (aCheckValue) {
prompter.SetCheckValue(*aCheckValue);
if (aCheckMsg)
prompter.SetCheckMessage(aCheckMsg);
else
prompter.SetCheckMessage(NS_LITERAL_STRING("Save These Values").get());
}
prompter.Create(EmbedPrompter::TYPE_PROMPT_USER_PASS);
prompter.Run();
prompter.GetConfirmValue(_retval);
if (*_retval) {
if (aUser && *aUser) {
nsMemory::Free(*aUser);
*aUser = nsnull;
}
prompter.GetUser(aUser);
if (aPwd && *aPwd) {
nsMemory::Free(*aPwd);
*aPwd = nsnull;
}
prompter.GetPassword(aPwd);
if (aCheckValue)
prompter.GetCheckValue(aCheckValue);
}
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::PromptPassword(const PRUnichar *aDialogTitle,
const PRUnichar *aText, PRUnichar **aPwd,
const PRUnichar *aCheckMsg, PRBool *aCheckValue,
PRBool *_retval)
{
EmbedPrompter prompter;
prompter.SetTitle(aDialogTitle);
prompter.SetMessageText(aText);
if (aPwd && *aPwd)
prompter.SetPassword(*aPwd);
if (aCheckValue) {
prompter.SetCheckValue(*aCheckValue);
if (aCheckMsg)
prompter.SetCheckMessage(aCheckMsg);
else
prompter.SetCheckMessage(NS_LITERAL_STRING("Save Password").get());
}
prompter.Create(EmbedPrompter::TYPE_PROMPT_PASS);
prompter.Run();
prompter.GetConfirmValue(_retval);
if (*_retval) {
if (aPwd && *aPwd) {
nsMemory::Free(*aPwd);
*aPwd = nsnull;
}
prompter.GetPassword(aPwd);
if (aCheckValue)
prompter.GetCheckValue(aCheckValue);
}
return NS_OK;
}
NS_IMETHODIMP
EmbedWindow::Select(const PRUnichar *aDialogTitle, const PRUnichar *aText,
PRUint32 aCount, const PRUnichar **aSelectList,
PRInt32 *aOutSelection, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// nsIInterfaceRequestor
NS_IMETHODIMP

Просмотреть файл

@ -26,7 +26,6 @@
#include <nsIWebBrowserChromeFocus.h>
#include <nsIEmbeddingSiteWindow.h>
#include <nsITooltipListener.h>
#include <nsIPrompt.h>
#include <nsISupports.h>
#include <nsIWebBrowser.h>
#include <nsIBaseWindow.h>
@ -41,7 +40,6 @@ class EmbedWindow : public nsIWebBrowserChrome,
public nsIWebBrowserChromeFocus,
public nsIEmbeddingSiteWindow,
public nsITooltipListener,
public nsIPrompt,
public nsIInterfaceRequestor
{
@ -64,8 +62,6 @@ class EmbedWindow : public nsIWebBrowserChrome,
NS_DECL_NSITOOLTIPLISTENER
NS_DECL_NSIPROMPT
NS_DECL_NSIINTERFACEREQUESTOR
nsString mTitle;
@ -79,6 +75,7 @@ private:
nsCOMPtr<nsIBaseWindow> mBaseWindow; // [OWNER]
static GtkWidget *sTipWindow;
PRBool mVisibility;
PRBool mIsModal;
};

Просмотреть файл

@ -38,7 +38,6 @@ CPPSRCS = \
EmbedContentListener.cpp \
EmbedEventListener.cpp \
EmbedWindowCreator.cpp \
EmbedPrompter.cpp \
EmbedStream.cpp
SHARED_LIBRARY_LIBS= \

Просмотреть файл

@ -58,6 +58,18 @@
#include "nsIWebNavigation.h"
#include "nsIWindowCreator.h"
#include "nsIXPConnect.h"
#ifdef XP_UNIX
// please see bug 78421 for the eventual "right" fix for this
#define HAVE_LAME_APPSHELL
#endif
#ifdef HAVE_LAME_APPSHELL
#include "nsIAppShell.h"
// for NS_APPSHELL_CID
#include <nsWidgetsCID.h>
#endif
#ifdef USEWEAKREFS
#include "nsIWeakReference.h"
#endif
@ -65,6 +77,10 @@
#define NOTIFICATION_OPENED NS_LITERAL_STRING("domwindowopened")
#define NOTIFICATION_CLOSED NS_LITERAL_STRING("domwindowclosed")
#ifdef HAVE_LAME_APPSHELL
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#endif
static const char *sJSStackContractID="@mozilla.org/js/xpc/ContextStack;1";
/****************************************************************
@ -242,6 +258,9 @@ public:
protected:
nsCOMPtr<nsIEventQueueService> mService;
nsCOMPtr<nsIEventQueue> mQueue;
#ifdef HAVE_LAME_APPSHELL
nsCOMPtr<nsIAppShell> mAppShell;
#endif
};
EventQueueAutoPopper::EventQueueAutoPopper() : mQueue(nsnull)
@ -250,6 +269,15 @@ EventQueueAutoPopper::EventQueueAutoPopper() : mQueue(nsnull)
EventQueueAutoPopper::~EventQueueAutoPopper()
{
#ifdef HAVE_LAME_APPSHELL
if (mAppShell) {
if (mQueue)
mAppShell->ListenToEventQueue(mQueue, PR_FALSE);
mAppShell->Spindown();
mAppShell = nsnull;
}
#endif
if(mQueue)
mService->PopThreadEventQueue(mQueue);
}
@ -260,9 +288,28 @@ nsresult EventQueueAutoPopper::Push()
return NS_ERROR_FAILURE;
mService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
if(mService)
mService->PushThreadEventQueue(getter_AddRefs(mQueue));
return mQueue ? NS_OK : NS_ERROR_FAILURE;
if (!mService)
return NS_ERROR_FAILURE;
// push a new queue onto it
mService->PushThreadEventQueue(getter_AddRefs(mQueue));
if (!mQueue)
return NS_ERROR_FAILURE;
#ifdef HAVE_LAME_APPSHELL
// listen to the event queue
mAppShell = do_CreateInstance(kAppShellCID);
if (!mAppShell)
return NS_ERROR_FAILURE;
mAppShell->Create(0, nsnull);
mAppShell->Spinup();
// listen to the new queue
mAppShell->ListenToEventQueue(mQueue, PR_TRUE);
#endif
return NS_OK;
}
/****************************************************************