mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-05 16:22:53 +00:00
Backing out all changes to embedding/browser/gtk/ to '2006-11-01 20:00' due to massive landings of unreviewed changes (MICROB Landings). b=408238, r=bsmedberg, sr=brendan, a=vlad. Good changes/reviewed changes that we backed up will be landing in the next few days.
This commit is contained in:
parent
fe2e46d0b3
commit
71febd0dec
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -38,6 +36,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <strings.h>
|
||||
#include <nsXPIDLString.h>
|
||||
|
||||
#include "nsIURI.h"
|
||||
|
||||
@ -70,15 +69,10 @@ EmbedContentListener::Init(EmbedPrivate *aOwner)
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
|
||||
PRBool *aAbortOpen)
|
||||
PRBool *aAbortOpen)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (mOwner->mOpenBlock) {
|
||||
*aAbortOpen = mOwner->mOpenBlock;
|
||||
mOwner->mOpenBlock = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsCAutoString specString;
|
||||
rv = aURI->GetSpec(specString);
|
||||
|
||||
@ -86,69 +80,52 @@ EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
|
||||
return rv;
|
||||
|
||||
gint return_val = FALSE;
|
||||
|
||||
/* checks if URI scheme is mailto */
|
||||
aURI->SchemeIs("mailto", &return_val);
|
||||
if (return_val) {
|
||||
/* stops URI opening to emit "mailto" signal */
|
||||
*aAbortOpen = TRUE;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[MAILTO],
|
||||
specString.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// otherwise ...
|
||||
return_val = FALSE;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[OPEN_URI],
|
||||
specString.get(), &return_val);
|
||||
moz_embed_signals[OPEN_URI],
|
||||
specString.get(), &return_val);
|
||||
|
||||
*aAbortOpen = !!return_val;
|
||||
*aAbortOpen = return_val;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::DoContent(const char *aContentType,
|
||||
PRBool aIsContentPreferred,
|
||||
nsIRequest *aRequest,
|
||||
nsIStreamListener **aContentHandler,
|
||||
PRBool *aAbortProcess)
|
||||
PRBool aIsContentPreferred,
|
||||
nsIRequest *aRequest,
|
||||
nsIStreamListener **aContentHandler,
|
||||
PRBool *aAbortProcess)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::IsPreferred(const char *aContentType,
|
||||
char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
char **aDesiredContentType,
|
||||
PRBool *aCanHandleContent)
|
||||
{
|
||||
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
|
||||
aCanHandleContent);
|
||||
aCanHandleContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedContentListener::CanHandleContent(const char *aContentType,
|
||||
PRBool aIsContentPreferred,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
PRBool aIsContentPreferred,
|
||||
char **aDesiredContentType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
*aDesiredContentType = nsnull;
|
||||
|
||||
|
||||
if (aContentType) {
|
||||
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
|
||||
if (webNavInfo) {
|
||||
PRUint32 canHandle;
|
||||
nsresult rv =
|
||||
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mOwner ? mOwner->mNavigation.get() : nsnull,
|
||||
&canHandle); //FIXME XXX MEMLEAK
|
||||
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||
mOwner ? mOwner->mNavigation.get() : nsnull,
|
||||
&canHandle);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -40,8 +38,8 @@
|
||||
#ifndef __EmbedContentListener_h
|
||||
#define __EmbedContentListener_h
|
||||
|
||||
#include "nsIURIContentListener.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include <nsIURIContentListener.h>
|
||||
#include <nsWeakReference.h>
|
||||
|
||||
class EmbedPrivate;
|
||||
|
||||
@ -53,7 +51,7 @@ class EmbedContentListener : public nsIURIContentListener,
|
||||
EmbedContentListener();
|
||||
virtual ~EmbedContentListener();
|
||||
|
||||
nsresult Init(EmbedPrivate *aOwner);
|
||||
nsresult Init (EmbedPrivate *aOwner);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@ -62,7 +60,7 @@ class EmbedContentListener : public nsIURIContentListener,
|
||||
private:
|
||||
|
||||
EmbedPrivate *mOwner;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* __EmbedContentListener_h */
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,14 +14,12 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
* Tomaz Noleto <tnoleto@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -39,26 +35,14 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include <nsCOMPtr.h>
|
||||
#include <nsIDOMMouseEvent.h>
|
||||
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMUIEvent.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
#include "EmbedEventListener.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#include "gtkmozembed_internal.h"
|
||||
|
||||
static PRInt32 sLongPressTimer = 0, mLongMPressDelay = 1000;
|
||||
static PRInt32 sX = 0, sY = 0;
|
||||
static PRBool sMPressed = PR_FALSE, sIsScrolling = PR_FALSE;
|
||||
static char* gFavLocation = NULL;
|
||||
|
||||
EmbedEventListener::EmbedEventListener(void)
|
||||
{
|
||||
@ -67,7 +51,6 @@ EmbedEventListener::EmbedEventListener(void)
|
||||
|
||||
EmbedEventListener::~EmbedEventListener()
|
||||
{
|
||||
delete mCtxInfo;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(EmbedEventListener)
|
||||
@ -78,160 +61,25 @@ NS_INTERFACE_MAP_BEGIN(EmbedEventListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMUIListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseMotionListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
nsresult
|
||||
EmbedEventListener::Init(EmbedPrivate *aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
mCtxInfo = nsnull;
|
||||
mClickCount = 1;
|
||||
mCtxInfo = new EmbedContextMenuInfo(aOwner);
|
||||
mOwner->mNeedFav = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::HandleLink(nsIDOMNode* node)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> linkElement;
|
||||
linkElement = do_QueryInterface(node);
|
||||
if (!linkElement) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString name;
|
||||
rv = linkElement->GetAttribute(NS_LITERAL_STRING("rel"), name);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString link;
|
||||
rv = linkElement->GetAttribute(NS_LITERAL_STRING("href"), link);
|
||||
if (NS_FAILED(rv) || link.IsEmpty()) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
rv = node->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(rv) || !domDoc) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOM3Node> domnode = do_QueryInterface(domDoc);
|
||||
if (!domnode) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString spec;
|
||||
domnode->GetBaseURI(spec);
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
rv = NewURI(getter_AddRefs(baseURI), NS_ConvertUTF16toUTF8(spec).get());
|
||||
if (NS_FAILED(rv) || !baseURI) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCString url;
|
||||
rv = baseURI->Resolve(NS_ConvertUTF16toUTF8(link), url);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString type;
|
||||
rv = linkElement->GetAttribute(NS_LITERAL_STRING("type"), type);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsString title;
|
||||
rv = linkElement->GetAttribute(NS_LITERAL_STRING("title"), title);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
// XXX This does not handle |BLAH ICON POWER"
|
||||
if (mOwner->mNeedFav && (name.LowerCaseEqualsLiteral("icon") ||
|
||||
name.LowerCaseEqualsLiteral("shortcut icon"))) {
|
||||
mOwner->mNeedFav = PR_FALSE;
|
||||
this->GetFaviconFromURI(url.get());
|
||||
}
|
||||
else if (name.LowerCaseEqualsLiteral("alternate") &&
|
||||
type.LowerCaseEqualsLiteral("application/rss+xml")) {
|
||||
|
||||
NS_ConvertUTF16toUTF8 narrowTitle(title);
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[RSS_REQUEST],
|
||||
(gchar *)url.get(),
|
||||
narrowTitle.get());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::HandleEvent(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsString eventType;
|
||||
aDOMEvent->GetType(eventType);
|
||||
|
||||
if (eventType.EqualsLiteral("focus"))
|
||||
if (mCtxInfo->GetFormControlType(aDOMEvent)) {
|
||||
if (mCtxInfo->mEmbedCtxType & GTK_MOZ_EMBED_CTX_INPUT) {
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_FOCUS],
|
||||
(void *)aDOMEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (eventType.EqualsLiteral("DOMLinkAdded")) {
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMEventTarget> eventTarget;
|
||||
|
||||
aDOMEvent->GetTarget(getter_AddRefs(eventTarget));
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(eventTarget, &rv);
|
||||
if (NS_FAILED(rv) || !node)
|
||||
return NS_ERROR_FAILURE;
|
||||
HandleLink(node);
|
||||
} else if (eventType.EqualsLiteral("load")) {
|
||||
|
||||
nsIWebBrowser *webBrowser = nsnull;
|
||||
gtk_moz_embed_get_nsIWebBrowser(mOwner->mOwningWidget, &webBrowser);
|
||||
if (!webBrowser) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> DOMWindow;
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(DOMWindow));
|
||||
if (!DOMWindow) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
DOMWindow->GetDocument(getter_AddRefs(doc));
|
||||
if (!doc) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> nodelist = nsnull;
|
||||
doc->GetElementsByTagName( NS_LITERAL_STRING( "rss" ), getter_AddRefs( nodelist ));
|
||||
if (nodelist) {
|
||||
PRUint32 length = 0;
|
||||
nodelist->GetLength(&length);
|
||||
if (length >= 1) {
|
||||
char *url = gtk_moz_embed_get_location(mOwner->mOwningWidget);
|
||||
char *title = gtk_moz_embed_get_title(mOwner->mOwningWidget);
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[RSS_REQUEST],
|
||||
(gchar*)url,
|
||||
(gchar*)title);
|
||||
if (url)
|
||||
NS_Free(url);
|
||||
if (title)
|
||||
NS_Free(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mOwner->mNeedFav) {
|
||||
mOwner->mNeedFav = PR_FALSE;
|
||||
nsCString favicon_url = mOwner->mPrePath;
|
||||
favicon_url.AppendLiteral("/favicon.ico");
|
||||
this->GetFaviconFromURI(favicon_url.get());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::KeyDown(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent;
|
||||
nsCOMPtr <nsIDOMKeyEvent> keyEvent;
|
||||
keyEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!keyEvent)
|
||||
return NS_OK;
|
||||
@ -239,8 +87,8 @@ EmbedEventListener::KeyDown(nsIDOMEvent* aDOMEvent)
|
||||
// consumed...
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_KEY_DOWN],
|
||||
(void *)keyEvent, &return_val);
|
||||
moz_embed_signals[DOM_KEY_DOWN],
|
||||
(void *)keyEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -251,7 +99,7 @@ EmbedEventListener::KeyDown(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::KeyUp(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent;
|
||||
nsCOMPtr <nsIDOMKeyEvent> keyEvent;
|
||||
keyEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!keyEvent)
|
||||
return NS_OK;
|
||||
@ -259,13 +107,11 @@ EmbedEventListener::KeyUp(nsIDOMEvent* aDOMEvent)
|
||||
// consumed...
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_KEY_UP],
|
||||
(void *)keyEvent, &return_val);
|
||||
moz_embed_signals[DOM_KEY_UP],
|
||||
(void *)keyEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
} else {
|
||||
//mCtxInfo->UpdateContextData(aDOMEvent);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -273,15 +119,15 @@ EmbedEventListener::KeyUp(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::KeyPress(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent;
|
||||
nsCOMPtr <nsIDOMKeyEvent> keyEvent;
|
||||
keyEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!keyEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_KEY_PRESS],
|
||||
(void *)keyEvent, &return_val);
|
||||
moz_embed_signals[DOM_KEY_PRESS],
|
||||
(void *)keyEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -289,81 +135,37 @@ EmbedEventListener::KeyPress(nsIDOMEvent* aDOMEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sLongMPress(void *aOwningWidget)
|
||||
{
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
if (!sMPressed || sIsScrolling)
|
||||
return FALSE;
|
||||
sMPressed = PR_FALSE;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(aOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_LONG_PRESS],
|
||||
(void *)0, &return_val);
|
||||
if (return_val) {
|
||||
sMPressed = PR_FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseDown(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
|
||||
nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
|
||||
mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
sMPressed = PR_TRUE;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_DOWN],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_DOWN],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
mClickCount = 2;
|
||||
sMPressed = PR_FALSE;
|
||||
#if 1
|
||||
if (sLongPressTimer)
|
||||
g_source_remove(sLongPressTimer);
|
||||
#else
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
#endif
|
||||
} else {
|
||||
mClickCount = 1;
|
||||
sLongPressTimer = g_timeout_add(mLongMPressDelay, sLongMPress, mOwner->mOwningWidget);
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetScreenX(&sX);
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetScreenY(&sY);
|
||||
}
|
||||
|
||||
// handling event internally.
|
||||
HandleSelection(mouseEvent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseUp(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
|
||||
nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
|
||||
mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
|
||||
// handling event internally, first.
|
||||
HandleSelection(mouseEvent);
|
||||
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
if (sLongPressTimer)
|
||||
g_source_remove(sLongPressTimer);
|
||||
sMPressed = PR_FALSE;
|
||||
mOwner->mOpenBlock = sIsScrolling;
|
||||
sIsScrolling = sMPressed;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_UP],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_UP],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -374,16 +176,15 @@ EmbedEventListener::MouseUp(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseClick(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
|
||||
nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
|
||||
mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
sMPressed = PR_FALSE;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_CLICK],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_CLICK],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -394,18 +195,15 @@ EmbedEventListener::MouseClick(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseDblClick(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
|
||||
nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
|
||||
mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
if (sLongPressTimer)
|
||||
g_source_remove(sLongPressTimer);
|
||||
sMPressed = PR_FALSE;
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_DBL_CLICK],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_DBL_CLICK],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -416,20 +214,18 @@ EmbedEventListener::MouseDblClick(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseOver(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
|
||||
nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
|
||||
mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_OVER],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_OVER],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
} else {
|
||||
//mCtxInfo->UpdateContextData(aDOMEvent);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -437,15 +233,15 @@ EmbedEventListener::MouseOver(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseOut(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
|
||||
nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
|
||||
mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_OUT],
|
||||
(void *)mouseEvent, &return_val);
|
||||
moz_embed_signals[DOM_MOUSE_OUT],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (return_val) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
@ -456,7 +252,7 @@ EmbedEventListener::MouseOut(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::Activate(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
|
||||
nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!uiEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
@ -474,7 +270,7 @@ EmbedEventListener::Activate(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::FocusIn(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
|
||||
nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!uiEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
@ -492,7 +288,7 @@ EmbedEventListener::FocusIn(nsIDOMEvent* aDOMEvent)
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::FocusOut(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
|
||||
nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!uiEvent)
|
||||
return NS_OK;
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
@ -506,435 +302,3 @@ EmbedEventListener::FocusOut(nsIDOMEvent* aDOMEvent)
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::MouseMove(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
if (mCurSelCon)
|
||||
mCurSelCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
|
||||
if (sMPressed &&
|
||||
gtk_signal_handler_pending(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_SCROLL], TRUE)) {
|
||||
// Return TRUE from your signal handler to mark the event as consumed.
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aDOMEvent);
|
||||
if (!mouseEvent)
|
||||
return NS_OK;
|
||||
PRInt32 newX, newY, subX, subY;
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetScreenX(&newX);
|
||||
((nsIDOMMouseEvent*)mouseEvent)->GetScreenY(&newY);
|
||||
subX = newX - sX;
|
||||
subY = newY - sY;
|
||||
nsresult rv = NS_OK;
|
||||
if (ABS(subX) > 10 || ABS(subY) > 10 || (sIsScrolling && sMPressed)) {
|
||||
if (!sIsScrolling) {
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_MOUSE_SCROLL],
|
||||
(void *)mouseEvent, &return_val);
|
||||
if (!return_val) {
|
||||
sIsScrolling = PR_TRUE;
|
||||
if (mCtxInfo)
|
||||
rv = mCtxInfo->GetElementForScroll(aDOMEvent);
|
||||
} else {
|
||||
sMPressed = PR_FALSE;
|
||||
sIsScrolling = PR_FALSE;
|
||||
}
|
||||
}
|
||||
if (sIsScrolling)
|
||||
{
|
||||
if (sLongPressTimer)
|
||||
g_source_remove(sLongPressTimer);
|
||||
if (mCtxInfo->mNSHHTMLElementSc) {
|
||||
PRInt32 x, y;
|
||||
mCtxInfo->mNSHHTMLElementSc->GetScrollTop(&y);
|
||||
mCtxInfo->mNSHHTMLElementSc->GetScrollLeft(&x);
|
||||
#ifdef MOZ_SCROLL_TOP_LEFT_HACK
|
||||
rv = mCtxInfo->mNSHHTMLElementSc->ScrollTopLeft(y - subY, x - subX);
|
||||
#endif
|
||||
} else {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
if (rv == NS_ERROR_UNEXPECTED) {
|
||||
nsCOMPtr<nsIDOMWindow> DOMWindow;
|
||||
nsIWebBrowser *webBrowser = nsnull;
|
||||
gtk_moz_embed_get_nsIWebBrowser(mOwner->mOwningWidget, &webBrowser);
|
||||
webBrowser->GetContentDOMWindow(getter_AddRefs(DOMWindow));
|
||||
DOMWindow->ScrollBy(-subX, -subY);
|
||||
}
|
||||
}
|
||||
sX = newX;
|
||||
sY = newY;
|
||||
sIsScrolling = sMPressed;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::DragMove(nsIDOMEvent* aMouseEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsString eventType;
|
||||
aEvent->GetType(eventType);
|
||||
|
||||
if (eventType.EqualsLiteral("focus") &&
|
||||
mCtxInfo->GetFormControlType(aEvent) &&
|
||||
mCtxInfo->mEmbedCtxType & GTK_MOZ_EMBED_CTX_INPUT) {
|
||||
gint return_val = FALSE;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DOM_FOCUS],
|
||||
(void *)aEvent, &return_val);
|
||||
if (return_val) {
|
||||
aEvent->StopPropagation();
|
||||
aEvent->PreventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::Blur(nsIDOMEvent* aEvent)
|
||||
{
|
||||
gint return_val = FALSE;
|
||||
mFocusInternalFrame = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
|
||||
nsCOMPtr<nsIDOMEventTarget> target;
|
||||
nsevent->GetOriginalTarget(getter_AddRefs(target));
|
||||
|
||||
if (!target)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIContent> targetContent = do_QueryInterface(target);
|
||||
|
||||
if (targetContent) {
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
if (targetContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) {
|
||||
#else
|
||||
if (targetContent->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL)) {
|
||||
#endif
|
||||
if (sLongPressTimer)
|
||||
g_source_remove(sLongPressTimer);
|
||||
|
||||
sMPressed = sIsScrolling ? PR_FALSE : sMPressed;
|
||||
sIsScrolling = PR_FALSE;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::HandleSelection(nsIDOMMouseEvent* aDOMMouseEvent)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
/* This function gets called everytime that a mousedown or a mouseup
|
||||
* event occurs.
|
||||
*/
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aDOMMouseEvent));
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> target;
|
||||
rv = nsevent->GetOriginalTarget(getter_AddRefs(target));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> eventNode = do_QueryInterface(target);
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
rv = eventNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc, &rv);
|
||||
if (NS_FAILED(rv) || !doc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsIPresShell *presShell = doc->GetPrimaryShell();
|
||||
|
||||
/* Gets nsISelectionController interface for the current context */
|
||||
mCurSelCon = do_QueryInterface(presShell);
|
||||
if (!mCurSelCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
/* Gets event type */
|
||||
nsString eventType;
|
||||
rv = aDOMMouseEvent->GetType(eventType);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
/* Updates context to check which context is being clicked on */
|
||||
mCtxInfo->UpdateContextData(aDOMMouseEvent);
|
||||
|
||||
/* If a mousedown after 1 click is done (and if clicked context is not a XUL
|
||||
* one (e.g. scrollbar), the selection is disabled for that context.
|
||||
*/
|
||||
if (mCtxInfo->mEmbedCtxType & GTK_MOZ_EMBED_CTX_XUL || mCtxInfo->mEmbedCtxType & GTK_MOZ_EMBED_CTX_RICHEDIT)
|
||||
return rv;
|
||||
|
||||
if (eventType.EqualsLiteral("mousedown")) {
|
||||
|
||||
if (mClickCount == 1)
|
||||
rv = mCurSelCon->SetDisplaySelection(nsISelectionController::SELECTION_OFF);
|
||||
|
||||
} // mousedown
|
||||
|
||||
/* If a mouseup occurs, the selection for context is enabled again (despite of
|
||||
* number of clicks). If this event occurs after 1 click, the selection of
|
||||
* both last and current contexts are cleaned up.
|
||||
*/
|
||||
if (eventType.EqualsLiteral("mouseup")) {
|
||||
|
||||
/* Selection controller of current event context */
|
||||
if (mCurSelCon) {
|
||||
rv = mCurSelCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
if (mClickCount == 1) {
|
||||
nsCOMPtr<nsISelection> domSel;
|
||||
mCurSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(domSel));
|
||||
rv = domSel->RemoveAllRanges();
|
||||
}
|
||||
}
|
||||
/* Selection controller of previous event context */
|
||||
if (mLastSelCon) {
|
||||
rv = mLastSelCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
||||
if (mClickCount == 1) {
|
||||
nsCOMPtr<nsISelection> domSel;
|
||||
mLastSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||
getter_AddRefs(domSel));
|
||||
rv = domSel->RemoveAllRanges();
|
||||
}
|
||||
}
|
||||
|
||||
/* If 1 click was done (despite the event type), sets the last context's
|
||||
* selection controller with current one
|
||||
*/
|
||||
if (mClickCount == 1)
|
||||
mLastSelCon = mCurSelCon;
|
||||
} // mouseup
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedEventListener::NewURI(nsIURI **result,
|
||||
const char *spec)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCString cSpec(spec);
|
||||
nsCOMPtr<nsIIOService> ioService;
|
||||
rv = GetIOService(getter_AddRefs(ioService));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = ioService->NewURI(cSpec, nsnull, nsnull, result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedEventListener::GetIOService(nsIIOService **ioService)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> mgr;
|
||||
NS_GetServiceManager(getter_AddRefs(mgr));
|
||||
if (!mgr) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = mgr->GetServiceByContractID("@mozilla.org/network/io-service;1",
|
||||
NS_GET_IID(nsIIOService),
|
||||
(void **)ioService);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedEventListener::GeneratePixBuf()
|
||||
{
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
pixbuf = gdk_pixbuf_new_from_file(::gFavLocation, NULL);
|
||||
if (!pixbuf) {
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[ICON_CHANGED],
|
||||
NULL );
|
||||
|
||||
// remove the wrong favicon
|
||||
// FIXME: need better impl...
|
||||
nsCOMPtr<nsILocalFile> faviconFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
|
||||
if (!faviconFile) {
|
||||
NS_Free(::gFavLocation);
|
||||
gFavLocation = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString faviconLocation(::gFavLocation);
|
||||
faviconFile->InitWithNativePath(faviconLocation);
|
||||
faviconFile->Remove(FALSE);
|
||||
NS_Free(::gFavLocation);
|
||||
gFavLocation = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[ICON_CHANGED],
|
||||
pixbuf );
|
||||
//mOwner->mNeedFav = PR_FALSE;
|
||||
NS_Free(::gFavLocation);
|
||||
gFavLocation = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedEventListener::GetFaviconFromURI(const char* aURI)
|
||||
{
|
||||
gchar *file_name = NS_strdup(aURI);
|
||||
gchar *favicon_uri = NS_strdup(aURI);
|
||||
|
||||
gint i = 0;
|
||||
gint rv = 0;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPersist> persist = do_CreateInstance(NS_WEBBROWSERPERSIST_CONTRACTID);
|
||||
if (!persist) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
return;
|
||||
}
|
||||
persist->SetProgressListener(this);
|
||||
|
||||
while (file_name[i] != '\0') {
|
||||
if (file_name[i] == '/' || file_name[i] == ':')
|
||||
file_name[i] = '_';
|
||||
i++;
|
||||
}
|
||||
|
||||
nsCString fileName(file_name);
|
||||
|
||||
nsCOMPtr<nsILocalFile> favicon_dir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
|
||||
if (!favicon_dir) {
|
||||
NS_Free(favicon_uri);
|
||||
NS_Free(file_name);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCString faviconDir("~/.mozilla/favicon");
|
||||
favicon_dir->InitWithNativePath(faviconDir);
|
||||
|
||||
PRBool isExist;
|
||||
rv = favicon_dir->Exists(&isExist);
|
||||
if (NS_SUCCEEDED(rv) && !isExist) {
|
||||
rv = favicon_dir->Create(nsIFile::DIRECTORY_TYPE,0775);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsCAutoString favicon_path("~/.mozilla/favicon");
|
||||
nsCOMPtr<nsILocalFile> target_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
if (!target_file) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
return;
|
||||
}
|
||||
target_file->InitWithNativePath(favicon_path);
|
||||
target_file->Append(NS_ConvertUTF8toUTF16(fileName));
|
||||
|
||||
nsString path;
|
||||
target_file->GetPath(path);
|
||||
::gFavLocation = NS_strdup(NS_ConvertUTF16toUTF8(path).get());
|
||||
nsCOMPtr<nsIIOService> ios(do_GetService(NS_IOSERVICE_CONTRACTID));
|
||||
if (!ios) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
NS_Free(::gFavLocation);
|
||||
gFavLocation = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
rv = ios->NewURI(nsDependentCString(favicon_uri), "", nsnull, getter_AddRefs(uri));
|
||||
if (!uri) {
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
NS_Free(::gFavLocation);
|
||||
gFavLocation = nsnull;
|
||||
return;
|
||||
}
|
||||
NS_Free(file_name);
|
||||
NS_Free(favicon_uri);
|
||||
|
||||
// save the favicon if the icon does not exist
|
||||
rv = target_file->Exists(&isExist);
|
||||
if (NS_SUCCEEDED(rv) && !isExist) {
|
||||
rv = persist->SaveURI(uri, nsnull, nsnull, nsnull, "", target_file);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
GeneratePixBuf();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
/* if (!(aStateFlags & (STATE_STOP | STATE_IS_NETWORK | STATE_IS_DOCUMENT))){*/
|
||||
|
||||
if (aStateFlags & STATE_STOP)
|
||||
/* FINISH DOWNLOADING */
|
||||
/* XXX sometimes this==0x0 and it cause crash in GeneratePixBuf, need workaround check for this */
|
||||
if (NS_SUCCEEDED(aStatus) && this)
|
||||
GeneratePixBuf();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsIURI *aLocation)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnStatusChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar *aMessage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedEventListener::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aState)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,13 +14,12 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -41,46 +38,15 @@
|
||||
#ifndef __EmbedEventListener_h
|
||||
#define __EmbedEventListener_h
|
||||
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMUIListener.h"
|
||||
|
||||
#include "nsIDOMMouseMotionListener.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "EmbedContextMenuInfo.h"
|
||||
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIWebBrowserPersist.h"
|
||||
#include "nsCWebBrowserPersist.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsXPCOMStrings.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include <nsIDOMKeyListener.h>
|
||||
#include <nsIDOMMouseListener.h>
|
||||
#include <nsIDOMUIListener.h>
|
||||
|
||||
class EmbedPrivate;
|
||||
|
||||
class EmbedEventListener : public nsIDOMKeyListener,
|
||||
public nsIDOMMouseListener,
|
||||
public nsIDOMUIListener,
|
||||
public nsIDOMMouseMotionListener,
|
||||
public nsIWebProgressListener,
|
||||
public nsIDOMFocusListener
|
||||
public nsIDOMUIListener
|
||||
{
|
||||
public:
|
||||
|
||||
@ -91,13 +57,12 @@ class EmbedEventListener : public nsIDOMKeyListener,
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// NS_DECL_NSIDOMEVENTLISTENER
|
||||
// nsIDOMEventListener
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD HandleLink(nsIDOMNode* node);
|
||||
// nsIDOMKeyListener
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIDOMKeyListener
|
||||
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aDOMEvent);
|
||||
NS_IMETHOD KeyUp(nsIDOMEvent* aDOMEvent);
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aDOMEvent);
|
||||
@ -117,33 +82,9 @@ class EmbedEventListener : public nsIDOMKeyListener,
|
||||
NS_IMETHOD FocusIn(nsIDOMEvent* aDOMEvent);
|
||||
NS_IMETHOD FocusOut(nsIDOMEvent* aDOMEvent);
|
||||
|
||||
// nsIDOMMouseMotionListener
|
||||
NS_IMETHOD MouseMove(nsIDOMEvent* aDOMEvent);
|
||||
NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent);
|
||||
EmbedContextMenuInfo* GetContextInfo() { return mCtxInfo; }
|
||||
|
||||
// nsIDOMFocusListener
|
||||
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD HandleSelection(nsIDOMMouseEvent* aDOMMouseEvent);
|
||||
|
||||
nsresult NewURI (nsIURI **result,
|
||||
const char *spec);
|
||||
nsresult GetIOService (nsIIOService **ioService);
|
||||
|
||||
void GeneratePixBuf ();
|
||||
|
||||
void GetFaviconFromURI (const char* aURI);
|
||||
private:
|
||||
|
||||
EmbedPrivate *mOwner;
|
||||
EmbedContextMenuInfo *mCtxInfo;
|
||||
|
||||
// Selection and some clipboard stuff
|
||||
nsCOMPtr<nsISelectionController> mCurSelCon;
|
||||
nsCOMPtr<nsISelectionController> mLastSelCon;
|
||||
PRBool mFocusInternalFrame;
|
||||
PRInt32 mClickCount;
|
||||
};
|
||||
|
||||
#endif /* __EmbedEventListener_h */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -40,40 +38,22 @@
|
||||
#ifndef __EmbedPrivate_h
|
||||
#define __EmbedPrivate_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#endif
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsISHistory.h"
|
||||
#include <nsCOMPtr.h>
|
||||
#include <nsString.h>
|
||||
#include <nsIWebNavigation.h>
|
||||
#include <nsISHistory.h>
|
||||
// for our one function that gets the EmbedPrivate via the chrome
|
||||
// object.
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsPIDOMEventTarget.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
#include <nsIWebBrowserChrome.h>
|
||||
#include <nsIAppShell.h>
|
||||
#include <nsPIDOMEventTarget.h>
|
||||
#include <nsVoidArray.h>
|
||||
// app component registration
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include <nsIGenericFactory.h>
|
||||
#include <nsIComponentRegistrar.h>
|
||||
|
||||
#include "nsIDocCharset.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIWebBrowserFind.h"
|
||||
// for the focus hacking we need to do
|
||||
#include "nsIFocusController.h"
|
||||
// for frames
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "gtkmozembedprivate.h"
|
||||
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
|
||||
#include "EmbedGtkTools.h"
|
||||
class EmbedProgress;
|
||||
class EmbedWindow;
|
||||
class EmbedContentListener;
|
||||
@ -82,17 +62,6 @@ class EmbedEventListener;
|
||||
class nsPIDOMWindow;
|
||||
class nsIDirectoryServiceProvider;
|
||||
|
||||
class EmbedCommon {
|
||||
public:
|
||||
EmbedCommon() {
|
||||
}
|
||||
~EmbedCommon() { }
|
||||
static EmbedCommon* GetInstance();
|
||||
static void DeleteInstance();
|
||||
nsresult Init(void);
|
||||
GtkObject *mCommon;
|
||||
static GtkMozEmbed* GetAnyLiveWidget();
|
||||
};
|
||||
class EmbedPrivate {
|
||||
|
||||
public:
|
||||
@ -118,7 +87,6 @@ class EmbedPrivate {
|
||||
static void PopStartup (void);
|
||||
static void SetPath (const char *aPath);
|
||||
static void SetCompPath (const char *aPath);
|
||||
|
||||
static void SetAppComponents (const nsModuleComponentInfo* aComps,
|
||||
int aNumComponents);
|
||||
static void SetProfilePath (const char *aDir, const char *aName);
|
||||
@ -143,33 +111,17 @@ class EmbedPrivate {
|
||||
// visibility is set.
|
||||
void ContentFinishedLoading(void);
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// these let the widget code know when the toplevel window gets and
|
||||
// looses focus.
|
||||
void TopLevelFocusIn (void);
|
||||
void TopLevelFocusOut(void);
|
||||
#endif
|
||||
|
||||
// these are when the widget itself gets focus in and focus out
|
||||
// events
|
||||
void ChildFocusIn (void);
|
||||
void ChildFocusOut(void);
|
||||
PRBool ClipBoardAction(GtkMozEmbedClipboard type);
|
||||
char* GetEncoding ();
|
||||
nsresult SetEncoding (const char *encoding);
|
||||
PRBool FindText(const char *exp, PRBool reverse,
|
||||
PRBool whole_word, PRBool case_sensitive,
|
||||
PRBool restart);
|
||||
void SetScrollTop(PRUint32 aTop);
|
||||
nsresult ScrollToSelectedNode(nsIDOMNode *aDOMNode);
|
||||
nsresult InsertTextToNode(nsIDOMNode *aDOMNode, const char *string);
|
||||
nsresult GetFocusController(nsIFocusController **controller);
|
||||
nsresult GetDOMWindowByNode(nsIDOMNode *aNode, nsIDOMWindow * *aDOMWindow);
|
||||
nsresult GetZoom(PRInt32 *aZoomLevel, nsISupports *aContext = nsnull);
|
||||
nsresult SetZoom(PRInt32 aZoomLevel, nsISupports *aContext = nsnull);
|
||||
nsresult HasFrames(PRUint32 *numberOfFrames);
|
||||
nsresult GetMIMEInfo(const char **aMime, nsIDOMNode *aDOMNode = nsnull);
|
||||
nsresult GetCacheEntry(const char *aStorage,
|
||||
const char *aKeyName,
|
||||
PRUint32 aAccess,
|
||||
PRBool aIsBlocking,
|
||||
nsICacheEntryDescriptor **aDescriptor);
|
||||
nsresult GetSHistoryList(GtkMozHistoryItem **GtkHI,
|
||||
GtkMozEmbedSessionHistory type, gint *count);
|
||||
|
||||
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
void *GetAtkObjectForCurrentDocument();
|
||||
@ -190,11 +142,11 @@ class EmbedPrivate {
|
||||
nsCOMPtr<nsIWebNavigation> mNavigation;
|
||||
nsCOMPtr<nsISHistory> mSessionHistory;
|
||||
|
||||
nsCOMPtr<nsPIDOMEventTarget> mEventTarget;
|
||||
// our event receiver
|
||||
nsCOMPtr<nsPIDOMEventTarget> mEventReceiver;
|
||||
|
||||
// the currently loaded uri
|
||||
nsString mURI;
|
||||
nsCString mPrePath;
|
||||
|
||||
// the number of widgets that have been created
|
||||
static PRUint32 sWidgetCount;
|
||||
@ -221,24 +173,15 @@ class EmbedPrivate {
|
||||
PRBool mIsChrome;
|
||||
// has the chrome finished loading?
|
||||
PRBool mChromeLoaded;
|
||||
|
||||
// has the network finished loading?
|
||||
PRBool mLoadFinished;
|
||||
|
||||
// saved window ID for reparenting later
|
||||
GtkWidget *mMozWindowWidget;
|
||||
// has someone called Destroy() on us?
|
||||
PRBool mIsDestroyed;
|
||||
|
||||
//Open Blocker for Create Window class //Fixme...
|
||||
//I just tried to block it on earlier moment
|
||||
PRBool mOpenBlock;
|
||||
PRBool mNeedFav;
|
||||
private:
|
||||
|
||||
// is the chrome listener attached yet?
|
||||
PRBool mListenersAttached;
|
||||
PRBool mDoResizeEmbed;
|
||||
|
||||
void GetListener (void);
|
||||
void AttachListeners(void);
|
||||
@ -246,7 +189,7 @@ class EmbedPrivate {
|
||||
|
||||
// this will get the PIDOMWindow for this widget
|
||||
nsresult GetPIDOMWindow (nsPIDOMWindow **aPIWin);
|
||||
|
||||
|
||||
static nsresult RegisterAppComponents();
|
||||
|
||||
// offscreen window methods and the offscreen widget
|
||||
@ -254,7 +197,7 @@ class EmbedPrivate {
|
||||
static void DestroyOffscreenWindow(void);
|
||||
static GtkWidget *sOffscreenWindow;
|
||||
static GtkWidget *sOffscreenFixed;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* __EmbedPrivate_h */
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,14 +14,12 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Antonio Gomes <tonikitoo@gmail.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -41,32 +37,14 @@
|
||||
|
||||
#include "EmbedProgress.h"
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsXPIDLString.h"
|
||||
#endif
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "EmbedPasswordMgr.h"
|
||||
#include <nsXPIDLString.h>
|
||||
#include <nsIChannel.h>
|
||||
#include <nsIWebProgress.h>
|
||||
#include <nsIDOMWindow.h>
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
static PRInt32 sStopSignalTimer = 0;
|
||||
static gboolean
|
||||
progress_emit_stop(void * data)
|
||||
{
|
||||
g_return_val_if_fail(data, FALSE);
|
||||
EmbedPrivate *owner = (EmbedPrivate*)data;
|
||||
if (!owner->mLoadFinished) {
|
||||
owner->mLoadFinished = PR_TRUE;
|
||||
gtk_signal_emit(GTK_OBJECT(owner->mOwningWidget),
|
||||
moz_embed_signals[NET_STOP]);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
EmbedProgress::EmbedProgress(void)
|
||||
{
|
||||
mOwner = nsnull;
|
||||
@ -77,146 +55,100 @@ EmbedProgress::~EmbedProgress()
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(EmbedProgress,
|
||||
nsIWebProgressListener,
|
||||
nsISupportsWeakReference)
|
||||
nsIWebProgressListener,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
nsresult
|
||||
EmbedProgress::Init(EmbedPrivate *aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
mStopLevel = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
// give the widget a chance to attach any listeners
|
||||
mOwner->ContentStateChange();
|
||||
|
||||
if (sStopSignalTimer &&
|
||||
(
|
||||
(aStateFlags & GTK_MOZ_EMBED_FLAG_TRANSFERRING)
|
||||
|| (aStateFlags & GTK_MOZ_EMBED_FLAG_REDIRECTING)
|
||||
|| (aStateFlags & GTK_MOZ_EMBED_FLAG_NEGOTIATING)
|
||||
)
|
||||
) {
|
||||
g_source_remove(sStopSignalTimer);
|
||||
mStopLevel = 0;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_START]);
|
||||
mOwner->mLoadFinished = PR_FALSE;
|
||||
}
|
||||
|
||||
// if we've got the start flag, emit the signal
|
||||
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
|
||||
(aStateFlags & GTK_MOZ_EMBED_FLAG_START)) {
|
||||
// FIXME: workaround for broken progress values.
|
||||
mOwner->mOwningWidget->current_number_of_requests = 0;
|
||||
mOwner->mOwningWidget->total_number_of_requests = 0;
|
||||
|
||||
if (mOwner->mLoadFinished) {
|
||||
mOwner->mLoadFinished = PR_FALSE;
|
||||
mStopLevel = 0;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_START]);
|
||||
}
|
||||
}
|
||||
// get the uri for this request
|
||||
nsCString tmpString;
|
||||
RequestToURIString(aRequest, tmpString);
|
||||
|
||||
// FIXME: workaround for broken progress values.
|
||||
if (mOwner->mOwningWidget) {
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_REQUEST) {
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_START)
|
||||
mOwner->mOwningWidget->total_number_of_requests ++;
|
||||
else if (aStateFlags & GTK_MOZ_EMBED_FLAG_STOP)
|
||||
mOwner->mOwningWidget->current_number_of_requests++;
|
||||
}
|
||||
|
||||
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
|
||||
(aStateFlags & GTK_MOZ_EMBED_FLAG_START))
|
||||
{
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[PROGRESS_ALL],
|
||||
(const gchar *) tmpString.get(),
|
||||
mOwner->mOwningWidget->current_number_of_requests,
|
||||
mOwner->mOwningWidget->total_number_of_requests);
|
||||
moz_embed_signals[NET_START]);
|
||||
}
|
||||
|
||||
// get the uri for this request
|
||||
nsXPIDLCString uriString;
|
||||
RequestToURIString(aRequest, getter_Copies(uriString));
|
||||
nsString tmpString;
|
||||
CopyUTF8toUTF16(uriString, tmpString);
|
||||
|
||||
// is it the same as the current URI?
|
||||
if (mOwner->mURI.Equals(NS_ConvertUTF8toUTF16(tmpString))) {
|
||||
if (mOwner->mURI.Equals(tmpString))
|
||||
{
|
||||
// for people who know what they are doing
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_STATE],
|
||||
aStateFlags, aStatus);
|
||||
moz_embed_signals[NET_STATE],
|
||||
aStateFlags, aStatus);
|
||||
}
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_STATE_ALL],
|
||||
(const gchar *)tmpString.get(),
|
||||
(gint)aStateFlags, (gint)aStatus);
|
||||
|
||||
moz_embed_signals[NET_STATE_ALL],
|
||||
(const char *)uriString,
|
||||
(gint)aStateFlags, (gint)aStatus);
|
||||
// and for stop, too
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_STOP) {
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_REQUEST)
|
||||
mStopLevel = 1;
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT)
|
||||
mStopLevel = mStopLevel == 1 ? 2 : 0;
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_WINDOW) {
|
||||
mStopLevel = mStopLevel == 2 ? 3 : 0;
|
||||
}
|
||||
if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
|
||||
(aStateFlags & GTK_MOZ_EMBED_FLAG_STOP))
|
||||
{
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NET_STOP]);
|
||||
// let our owner know that the load finished
|
||||
mOwner->ContentFinishedLoading();
|
||||
}
|
||||
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_STOP) {
|
||||
if (aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) {
|
||||
if (sStopSignalTimer)
|
||||
g_source_remove(sStopSignalTimer);
|
||||
progress_emit_stop(mOwner);
|
||||
// let our owner know that the load finished
|
||||
mOwner->ContentFinishedLoading();
|
||||
|
||||
} else if (mStopLevel == 3) {
|
||||
if (sStopSignalTimer)
|
||||
g_source_remove(sStopSignalTimer);
|
||||
mStopLevel = 0;
|
||||
sStopSignalTimer = g_timeout_add(1000, progress_emit_stop, mOwner);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnProgressChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress)
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
nsCString tmpString;
|
||||
RequestToURIString(aRequest, tmpString);
|
||||
|
||||
nsXPIDLCString uriString;
|
||||
RequestToURIString(aRequest, getter_Copies(uriString));
|
||||
|
||||
nsString tmpString;
|
||||
CopyUTF8toUTF16(uriString, tmpString);
|
||||
|
||||
// is it the same as the current uri?
|
||||
if (mOwner->mURI.Equals(NS_ConvertUTF8toUTF16(tmpString))) {
|
||||
if (mOwner->mURI.Equals(tmpString)) {
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[PROGRESS],
|
||||
aCurTotalProgress, aMaxTotalProgress);
|
||||
moz_embed_signals[PROGRESS],
|
||||
aCurTotalProgress, aMaxTotalProgress);
|
||||
}
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[PROGRESS_ALL],
|
||||
(const char *)uriString,
|
||||
aCurTotalProgress, aMaxTotalProgress);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsIURI *aLocation)
|
||||
nsIRequest *aRequest,
|
||||
nsIURI *aLocation)
|
||||
{
|
||||
nsCAutoString newURI;
|
||||
nsCAutoString prePath;
|
||||
NS_ENSURE_ARG_POINTER(aLocation);
|
||||
aLocation->GetSpec(newURI);
|
||||
aLocation->GetPrePath(prePath);
|
||||
|
||||
// Make sure that this is the primary frame change and not
|
||||
// just a subframe.
|
||||
@ -237,88 +169,62 @@ EmbedProgress::OnLocationChange(nsIWebProgress *aWebProgress,
|
||||
|
||||
if (!isSubFrameLoad) {
|
||||
mOwner->SetURI(newURI.get());
|
||||
mOwner->mPrePath.Assign(prePath.get());
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[LOCATION]);
|
||||
moz_embed_signals[LOCATION]);
|
||||
}
|
||||
mOwner->mNeedFav = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnStatusChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar *aMessage)
|
||||
nsIRequest *aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar *aMessage)
|
||||
{
|
||||
// need to make a copy so we can safely cast to a void *
|
||||
PRUnichar *tmpString = NS_strdup(aMessage);
|
||||
PRUnichar *tmpString = nsCRT::strdup(aMessage);
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[STATUS_CHANGE],
|
||||
static_cast<void *>(aRequest),
|
||||
static_cast<gint>(aStatus),
|
||||
static_cast<void *>(tmpString));
|
||||
moz_embed_signals[STATUS_CHANGE],
|
||||
static_cast<void *>(aRequest),
|
||||
static_cast<int>(aStatus),
|
||||
static_cast<void *>(tmpString));
|
||||
|
||||
NS_Free(tmpString);
|
||||
nsMemory::Free(tmpString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aState)
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aState)
|
||||
{
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[SECURITY_CHANGE],
|
||||
static_cast<void *>(aRequest),
|
||||
aState);
|
||||
moz_embed_signals[SECURITY_CHANGE],
|
||||
static_cast<void *>(aRequest),
|
||||
aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
EmbedProgress::RequestToURIString(nsIRequest *aRequest, nsCString& aString)
|
||||
EmbedProgress::RequestToURIString(nsIRequest *aRequest, char **aString)
|
||||
{
|
||||
// is it a channel
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
channel = do_QueryInterface(aRequest);
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
if (!uri)
|
||||
return;
|
||||
|
||||
nsCAutoString uriString;
|
||||
uri->GetSpec(uriString);
|
||||
|
||||
uri->GetSpec(aString);
|
||||
*aString = strdup(uriString.get());
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedProgress::HandleHTTPStatus(nsIRequest *aRequest, const char *aUri, PRBool &aSucceeded)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest, &rv));
|
||||
aSucceeded = PR_FALSE;
|
||||
|
||||
if (NS_FAILED(rv) || !httpChannel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = httpChannel->GetRequestSucceeded(&aSucceeded);
|
||||
|
||||
if (aSucceeded)
|
||||
return NS_OK;
|
||||
|
||||
PRUint32 responseCode = 0;
|
||||
nsCString responseText;
|
||||
rv = httpChannel->GetResponseStatus(&responseCode);
|
||||
// it has to handle more http errors code ??? 401 ? responseCode >= 500 && responseCode <= 505
|
||||
rv = httpChannel->GetResponseStatusText(responseText);
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[NETWORK_ERROR],
|
||||
responseCode, responseText.get(), (const gchar*)aUri);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -40,8 +38,8 @@
|
||||
#ifndef __EmbedProgress_h
|
||||
#define __EmbedProgress_h
|
||||
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include <nsIWebProgressListener.h>
|
||||
#include <nsWeakReference.h>
|
||||
#include "EmbedPrivate.h"
|
||||
|
||||
class EmbedProgress : public nsIWebProgressListener,
|
||||
@ -59,11 +57,10 @@ class EmbedProgress : public nsIWebProgressListener,
|
||||
|
||||
private:
|
||||
|
||||
static void RequestToURIString(nsIRequest *aRequest, nsCString& aString);
|
||||
nsresult HandleHTTPStatus(nsIRequest *aRequest, const char *aUri, PRBool &aSucceeded);
|
||||
static void RequestToURIString (nsIRequest *aRequest, char **aString);
|
||||
|
||||
EmbedPrivate *mOwner;
|
||||
PRBool mStopLevel;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __EmbedProgress_h */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=4 sts=2 et cindent: */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -38,416 +38,372 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "EmbedPrompter.h"
|
||||
|
||||
#include <gtk/gtkversion.h>
|
||||
|
||||
#if GTK_CHECK_VERSION(2,3,1)
|
||||
#define USE_GTK_COMBOBOX
|
||||
#endif
|
||||
|
||||
#define ALLOC_NOT_CHECKED(newed) PR_BEGIN_MACRO \
|
||||
/* This might not crash, but the code probably isn't really \
|
||||
* designed to handle it, perhaps the code should be fixed? \
|
||||
*/ \
|
||||
if (!newed) { \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
enum {
|
||||
INCLUDE_USERNAME = 1 << 0,
|
||||
INCLUDE_PASSWORD = 1 << 1,
|
||||
INCLUDE_CHECKBOX = 1 << 2,
|
||||
INCLUDE_CANCEL = 1 << 3
|
||||
INCLUDE_USERNAME = 1 << 0,
|
||||
INCLUDE_PASSWORD = 1 << 1,
|
||||
INCLUDE_CHECKBOX = 1 << 2,
|
||||
INCLUDE_CANCEL = 1 << 3
|
||||
};
|
||||
|
||||
struct DialogDescription {
|
||||
int flags;
|
||||
gchar* icon;
|
||||
int flags;
|
||||
gchar* icon;
|
||||
};
|
||||
|
||||
// This table contains the optional widgets and icons associated with
|
||||
// each type of dialog.
|
||||
|
||||
static const DialogDescription DialogTable[] = {
|
||||
{ 0, GTK_STOCK_DIALOG_WARNING }, // ALERT
|
||||
{ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_WARNING }, // ALERT_CHECK
|
||||
{ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM
|
||||
{ INCLUDE_CHECKBOX |
|
||||
INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM_CHECK
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_USERNAME |
|
||||
INCLUDE_PASSWORD |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_USER_PASS
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_PASSWORD |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_PASS
|
||||
{ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // SELECT
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION } // UNIVERSAL
|
||||
{ 0, GTK_STOCK_DIALOG_WARNING }, // ALERT
|
||||
{ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_WARNING }, // ALERT_CHECK
|
||||
{ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM
|
||||
{ INCLUDE_CHECKBOX |
|
||||
INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM_CHECK
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_USERNAME |
|
||||
INCLUDE_PASSWORD |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_USER_PASS
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_PASSWORD |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_PASS
|
||||
{ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // SELECT
|
||||
{ INCLUDE_CANCEL |
|
||||
INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION } // UNIVERSAL
|
||||
};
|
||||
|
||||
EmbedPrompter::EmbedPrompter(void)
|
||||
: mCheckValue(PR_FALSE),
|
||||
mItemList(nsnull),
|
||||
mItemCount(0),
|
||||
mButtonPressed(0),
|
||||
mConfirmResult(PR_FALSE),
|
||||
mSelectedItem(0),
|
||||
mWindow(NULL),
|
||||
mUserField(NULL),
|
||||
mPassField(NULL),
|
||||
mTextField(NULL),
|
||||
mOptionMenu(NULL),
|
||||
mCheckBox(NULL)
|
||||
: mCheckValue(PR_FALSE),
|
||||
mItemList(nsnull),
|
||||
mItemCount(0),
|
||||
mButtonPressed(0),
|
||||
mConfirmResult(PR_FALSE),
|
||||
mSelectedItem(0),
|
||||
mWindow(NULL),
|
||||
mUserField(NULL),
|
||||
mPassField(NULL),
|
||||
mTextField(NULL),
|
||||
mOptionMenu(NULL),
|
||||
mCheckBox(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
EmbedPrompter::~EmbedPrompter(void)
|
||||
{
|
||||
if (mItemList)
|
||||
delete[] mItemList;
|
||||
if (mItemList)
|
||||
delete[] mItemList;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedPrompter::Create(PromptType aType, GtkWindow* aParentWindow)
|
||||
|
||||
{
|
||||
mWindow = gtk_dialog_new_with_buttons(
|
||||
mTitle.get(),
|
||||
aParentWindow,
|
||||
(GtkDialogFlags)0,
|
||||
NULL);
|
||||
// only add the dialog to the window group if the parent already has a window group,
|
||||
// so as not to break app's expectations about modal dialogs.
|
||||
if (aParentWindow && aParentWindow->group) {
|
||||
gtk_window_group_add_window(aParentWindow->group, GTK_WINDOW(mWindow));
|
||||
}
|
||||
mWindow = gtk_dialog_new_with_buttons(mTitle.get(), aParentWindow,
|
||||
(GtkDialogFlags)0,
|
||||
NULL);
|
||||
|
||||
// gtk will resize this for us as necessary
|
||||
gtk_window_set_default_size(GTK_WINDOW(mWindow), 100, 50);
|
||||
|
||||
// this HBox will contain the icon, and a vbox which contains the
|
||||
// dialog text and other widgets.
|
||||
GtkWidget* dialogHBox = gtk_hbox_new(FALSE, 12);
|
||||
|
||||
|
||||
// Set up dialog properties according to the GNOME HIG
|
||||
// (http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows)
|
||||
|
||||
gtk_container_set_border_width(GTK_CONTAINER(mWindow), 6);
|
||||
gtk_dialog_set_has_separator(GTK_DIALOG(mWindow), FALSE);
|
||||
gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(mWindow)->vbox), 12);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dialogHBox), 6);
|
||||
|
||||
|
||||
// This is the VBox which will contain the label and other controls.
|
||||
GtkWidget* contentsVBox = gtk_vbox_new(FALSE, 12);
|
||||
|
||||
// get the stock icon for this dialog and put it in the box
|
||||
const gchar* iconDesc = DialogTable[aType].icon;
|
||||
GtkWidget* icon = gtk_image_new_from_stock(iconDesc, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
|
||||
gtk_box_pack_start(GTK_BOX(dialogHBox), icon, FALSE, FALSE, 0);
|
||||
|
||||
// now pack the label into the vbox
|
||||
GtkWidget* label = gtk_label_new(mMessageText.get());
|
||||
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
||||
gtk_label_set_selectable(GTK_LABEL(label), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), label, FALSE, FALSE, 0);
|
||||
|
||||
int widgetFlags = DialogTable[aType].flags;
|
||||
|
||||
if (widgetFlags & (INCLUDE_USERNAME | INCLUDE_PASSWORD)) {
|
||||
|
||||
// If we're creating a username and/or password field, make an hbox
|
||||
// which will contain two vboxes, one for the labels and one for the
|
||||
// text fields. This will let us line up the textfields.
|
||||
|
||||
GtkWidget* userPassHBox = gtk_hbox_new(FALSE, 12);
|
||||
GtkWidget* userPassLabels = gtk_vbox_new(TRUE, 6);
|
||||
GtkWidget* userPassFields = gtk_vbox_new(TRUE, 6);
|
||||
|
||||
if (widgetFlags & INCLUDE_USERNAME) {
|
||||
GtkWidget* userLabel = gtk_label_new("User Name:");
|
||||
gtk_box_pack_start(GTK_BOX(userPassLabels), userLabel, FALSE,
|
||||
FALSE, 0);
|
||||
|
||||
mUserField = gtk_entry_new();
|
||||
|
||||
if (!mUser.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mUserField), mUser.get());
|
||||
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mUserField), TRUE);
|
||||
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassFields),
|
||||
mUserField,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
}
|
||||
if (widgetFlags & INCLUDE_PASSWORD) {
|
||||
GtkWidget* passLabel = gtk_label_new("Password:");
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassLabels),
|
||||
passLabel,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
mPassField = gtk_entry_new();
|
||||
if (!mPass.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mPassField), mPass.get());
|
||||
gtk_entry_set_visibility(GTK_ENTRY(mPassField), FALSE);
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mPassField), TRUE);
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassFields),
|
||||
mPassField,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
}
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassHBox),
|
||||
userPassLabels,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(userPassHBox),
|
||||
userPassFields,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(contentsVBox),
|
||||
userPassHBox,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
}
|
||||
if (aType == TYPE_PROMPT) {
|
||||
mTextField = gtk_entry_new();
|
||||
if (!mTextValue.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mTextField), mTextValue.get());
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mTextField), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mTextField, FALSE, FALSE, 0);
|
||||
}
|
||||
// Add a checkbox
|
||||
if ((widgetFlags & INCLUDE_CHECKBOX) && !mCheckMessage.IsEmpty()) {
|
||||
mCheckBox = gtk_check_button_new_with_label(mCheckMessage.get());
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckBox),
|
||||
mCheckValue);
|
||||
gtk_label_set_line_wrap(
|
||||
GTK_LABEL(gtk_bin_get_child(GTK_BIN(mCheckBox))),
|
||||
TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mCheckBox, FALSE, FALSE, 0);
|
||||
}
|
||||
// Add a dropdown menu
|
||||
if (aType == TYPE_SELECT) {
|
||||
#ifdef USE_GTK_COMBOBOX
|
||||
// Build up a GtkComboBox containing the items
|
||||
mOptionMenu = gtk_combo_box_new_text ();
|
||||
|
||||
for (PRUint32 i = 0; i < mItemCount; ++i) {
|
||||
gtk_combo_box_append_text(GTK_COMBO_BOX(mOptionMenu), mItemList[i].get());
|
||||
}
|
||||
#else
|
||||
// Build up a GtkMenu containing the items
|
||||
GtkWidget* menu = gtk_menu_new();
|
||||
for (PRUint32 i = 0; i < mItemCount; ++i) {
|
||||
GtkWidget* item = gtk_menu_item_new_with_label(mItemList[i].get());
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
|
||||
// only add the dialog to the window group if the parent already has a window group,
|
||||
// so as not to break app's expectations about modal dialogs.
|
||||
if (aParentWindow && aParentWindow->group) {
|
||||
gtk_window_group_add_window (aParentWindow->group, GTK_WINDOW (mWindow));
|
||||
}
|
||||
|
||||
// Now create an OptionMenu and set this as the menu
|
||||
mOptionMenu = gtk_option_menu_new();
|
||||
// gtk will resize this for us as necessary
|
||||
gtk_window_set_default_size(GTK_WINDOW(mWindow), 100, 50);
|
||||
|
||||
gtk_option_menu_set_menu(GTK_OPTION_MENU(mOptionMenu), menu);
|
||||
#endif /* USE_GTK_COMBOBOX */
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mOptionMenu, FALSE, FALSE, 0);
|
||||
}
|
||||
// this HBox will contain the icon, and a vbox which contains the
|
||||
// dialog text and other widgets.
|
||||
GtkWidget* dialogHBox = gtk_hbox_new(FALSE, 12);
|
||||
|
||||
if (aType == TYPE_UNIVERSAL) {
|
||||
// Create buttons based on the flags passed in.
|
||||
for (int i = EMBED_MAX_BUTTONS; i >= 0; --i) {
|
||||
if (!mButtonLabels[i].IsEmpty())
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
mButtonLabels[i].get(), i);
|
||||
|
||||
// Set up dialog properties according to the GNOME HIG
|
||||
// (http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows)
|
||||
|
||||
gtk_container_set_border_width(GTK_CONTAINER(mWindow), 6);
|
||||
gtk_dialog_set_has_separator(GTK_DIALOG(mWindow), FALSE);
|
||||
gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(mWindow)->vbox), 12);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dialogHBox), 6);
|
||||
|
||||
|
||||
// This is the VBox which will contain the label and other controls.
|
||||
GtkWidget* contentsVBox = gtk_vbox_new(FALSE, 12);
|
||||
|
||||
// get the stock icon for this dialog and put it in the box
|
||||
const gchar* iconDesc = DialogTable[aType].icon;
|
||||
GtkWidget* icon = gtk_image_new_from_stock(iconDesc, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
|
||||
gtk_box_pack_start(GTK_BOX(dialogHBox), icon, FALSE, FALSE, 0);
|
||||
|
||||
// now pack the label into the vbox
|
||||
GtkWidget* label = gtk_label_new(mMessageText.get());
|
||||
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
||||
gtk_label_set_selectable(GTK_LABEL(label), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), label, FALSE, FALSE, 0);
|
||||
|
||||
int widgetFlags = DialogTable[aType].flags;
|
||||
|
||||
if (widgetFlags & (INCLUDE_USERNAME | INCLUDE_PASSWORD)) {
|
||||
|
||||
// If we're creating a username and/or password field, make an hbox
|
||||
// which will contain two vboxes, one for the labels and one for the
|
||||
// text fields. This will let us line up the textfields.
|
||||
|
||||
GtkWidget* userPassHBox = gtk_hbox_new(FALSE, 12);
|
||||
GtkWidget* userPassLabels = gtk_vbox_new(TRUE, 6);
|
||||
GtkWidget* userPassFields = gtk_vbox_new(TRUE, 6);
|
||||
|
||||
if (widgetFlags & INCLUDE_USERNAME) {
|
||||
GtkWidget* userLabel = gtk_label_new("User Name:");
|
||||
gtk_box_pack_start(GTK_BOX(userPassLabels), userLabel, FALSE,
|
||||
FALSE, 0);
|
||||
|
||||
mUserField = gtk_entry_new();
|
||||
|
||||
if (!mUser.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mUserField), mUser.get());
|
||||
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mUserField), TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(userPassFields), mUserField, FALSE,
|
||||
FALSE, 0);
|
||||
}
|
||||
if (widgetFlags & INCLUDE_PASSWORD) {
|
||||
GtkWidget* passLabel = gtk_label_new("Password:");
|
||||
gtk_box_pack_start(GTK_BOX(userPassLabels), passLabel, FALSE,
|
||||
FALSE, 0);
|
||||
|
||||
mPassField = gtk_entry_new();
|
||||
|
||||
if (!mPass.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mPassField), mPass.get());
|
||||
|
||||
gtk_entry_set_visibility(GTK_ENTRY(mPassField), FALSE);
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mPassField), TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(userPassFields), mPassField, FALSE,
|
||||
FALSE, 0);
|
||||
}
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(userPassHBox), userPassLabels, FALSE,
|
||||
FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(userPassHBox), userPassFields, FALSE,
|
||||
FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), userPassHBox, FALSE, FALSE, 0);
|
||||
}
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(mWindow), 0);
|
||||
} else {
|
||||
// Create standard ok and cancel buttons
|
||||
if (widgetFlags & INCLUDE_CANCEL)
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow), GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL);
|
||||
|
||||
GtkWidget* okButton = gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
GTK_STOCK_OK,
|
||||
GTK_RESPONSE_ACCEPT);
|
||||
gtk_widget_grab_default(okButton);
|
||||
}
|
||||
// Pack the contentsVBox into the dialogHBox and the dialog.
|
||||
gtk_box_pack_start(GTK_BOX(dialogHBox), contentsVBox, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(
|
||||
GTK_BOX(GTK_DIALOG(mWindow)->vbox),
|
||||
dialogHBox,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
return NS_OK;
|
||||
if (aType == TYPE_PROMPT) {
|
||||
mTextField = gtk_entry_new();
|
||||
|
||||
if (!mTextValue.IsEmpty())
|
||||
gtk_entry_set_text(GTK_ENTRY(mTextField), mTextValue.get());
|
||||
|
||||
gtk_entry_set_activates_default(GTK_ENTRY(mTextField), TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mTextField, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
// Add a checkbox
|
||||
if ((widgetFlags & INCLUDE_CHECKBOX) && !mCheckMessage.IsEmpty()) {
|
||||
mCheckBox = gtk_check_button_new_with_label(mCheckMessage.get());
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckBox),
|
||||
mCheckValue);
|
||||
gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(mCheckBox))),
|
||||
TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mCheckBox, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
// Add a dropdown menu
|
||||
if (aType == TYPE_SELECT) {
|
||||
// Build up a GtkMenu containing the items
|
||||
GtkWidget* menu = gtk_menu_new();
|
||||
for (PRUint32 i = 0; i < mItemCount; ++i) {
|
||||
GtkWidget* item = gtk_menu_item_new_with_label(mItemList[i].get());
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
|
||||
}
|
||||
|
||||
// Now create an OptionMenu and set this as the menu
|
||||
mOptionMenu = gtk_option_menu_new();
|
||||
|
||||
gtk_option_menu_set_menu(GTK_OPTION_MENU(mOptionMenu), menu);
|
||||
gtk_box_pack_start(GTK_BOX(contentsVBox), mOptionMenu, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
if (aType == TYPE_UNIVERSAL) {
|
||||
// Create buttons based on the flags passed in.
|
||||
for (int i = EMBED_MAX_BUTTONS; i >= 0; --i) {
|
||||
if (!mButtonLabels[i].IsEmpty())
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
mButtonLabels[i].get(), i);
|
||||
}
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(mWindow), 0);
|
||||
} else {
|
||||
// Create standard ok and cancel buttons
|
||||
if (widgetFlags & INCLUDE_CANCEL)
|
||||
gtk_dialog_add_button(GTK_DIALOG(mWindow), GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL);
|
||||
|
||||
GtkWidget* okButton = gtk_dialog_add_button(GTK_DIALOG(mWindow),
|
||||
GTK_STOCK_OK,
|
||||
GTK_RESPONSE_ACCEPT);
|
||||
gtk_widget_grab_default(okButton);
|
||||
}
|
||||
|
||||
// Pack the contentsVBox into the dialogHBox and the dialog.
|
||||
gtk_box_pack_start(GTK_BOX(dialogHBox), contentsVBox, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mWindow)->vbox), dialogHBox, FALSE,
|
||||
FALSE, 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetTitle(const PRUnichar *aTitle)
|
||||
{
|
||||
mTitle.Assign(NS_ConvertUTF16toUTF8(aTitle));
|
||||
CopyUTF16toUTF8(aTitle, mTitle);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetTextValue(const PRUnichar *aTextValue)
|
||||
{
|
||||
mTextValue.Assign(NS_ConvertUTF16toUTF8(aTextValue));
|
||||
CopyUTF16toUTF8(aTextValue, mTextValue);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetCheckMessage(const PRUnichar *aMessage)
|
||||
{
|
||||
mCheckMessage.Assign(NS_ConvertUTF16toUTF8(aMessage));
|
||||
CopyUTF16toUTF8(aMessage, mCheckMessage);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetMessageText(const PRUnichar *aMessageText)
|
||||
{
|
||||
mMessageText.Assign(NS_ConvertUTF16toUTF8(aMessageText));
|
||||
CopyUTF16toUTF8(aMessageText, mMessageText);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetUser(const PRUnichar *aUser)
|
||||
{
|
||||
mUser.Assign(NS_ConvertUTF16toUTF8(aUser));
|
||||
CopyUTF16toUTF8(aUser, mUser);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetPassword(const PRUnichar *aPass)
|
||||
{
|
||||
mPass.Assign(NS_ConvertUTF16toUTF8(aPass));
|
||||
CopyUTF16toUTF8(aPass, mPass);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetCheckValue(const PRBool aValue)
|
||||
{
|
||||
mCheckValue = aValue;
|
||||
mCheckValue = aValue;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetItems(const PRUnichar** aItemArray, PRUint32 aCount)
|
||||
{
|
||||
if (mItemList)
|
||||
delete[] mItemList;
|
||||
if (mItemList)
|
||||
delete[] mItemList;
|
||||
|
||||
mItemCount = aCount;
|
||||
mItemList = new nsCString[aCount];
|
||||
ALLOC_NOT_CHECKED(mItemList);
|
||||
for (PRUint32 i = 0; i < aCount; ++i)
|
||||
mItemList[i].Assign(NS_ConvertUTF16toUTF8(aItemArray[i]));
|
||||
mItemCount = aCount;
|
||||
mItemList = new nsCString[aCount];
|
||||
for (PRUint32 i = 0; i < aCount; ++i)
|
||||
CopyUTF16toUTF8(aItemArray[i], mItemList[i]);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SetButtons(const PRUnichar* aButton0Label,
|
||||
const PRUnichar* aButton1Label,
|
||||
const PRUnichar* aButton2Label)
|
||||
const PRUnichar* aButton1Label,
|
||||
const PRUnichar* aButton2Label)
|
||||
{
|
||||
mButtonLabels[0].Assign(NS_ConvertUTF16toUTF8(aButton0Label));
|
||||
mButtonLabels[1].Assign(NS_ConvertUTF16toUTF8(aButton1Label));
|
||||
mButtonLabels[2].Assign(NS_ConvertUTF16toUTF8(aButton2Label));
|
||||
CopyUTF16toUTF8(aButton0Label, mButtonLabels[0]);
|
||||
CopyUTF16toUTF8(aButton1Label, mButtonLabels[1]);
|
||||
CopyUTF16toUTF8(aButton2Label, mButtonLabels[2]);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetCheckValue(PRBool *aValue)
|
||||
{
|
||||
*aValue = mCheckValue;
|
||||
*aValue = mCheckValue;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetConfirmValue(PRBool *aConfirmValue)
|
||||
{
|
||||
*aConfirmValue = mConfirmResult;
|
||||
*aConfirmValue = mConfirmResult;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EmbedPrompter::GetTextValue(PRUnichar **aTextValue)
|
||||
{
|
||||
*aTextValue = ToNewUnicode(NS_ConvertUTF8toUTF16(mTextValue));
|
||||
*aTextValue = UTF8ToNewUnicode(mTextValue);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetUser(PRUnichar **aUser)
|
||||
{
|
||||
*aUser = ToNewUnicode(NS_ConvertUTF8toUTF16(mUser));
|
||||
*aUser = UTF8ToNewUnicode(mUser);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetPassword(PRUnichar **aPass)
|
||||
{
|
||||
*aPass = ToNewUnicode(NS_ConvertUTF8toUTF16(mPass));
|
||||
*aPass = UTF8ToNewUnicode(mPass);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetSelectedItem(PRInt32 *aIndex)
|
||||
{
|
||||
*aIndex = mSelectedItem;
|
||||
*aIndex = mSelectedItem;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::GetButtonPressed(PRInt32 *aButton)
|
||||
{
|
||||
*aButton = mButtonPressed;
|
||||
*aButton = mButtonPressed;
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::Run(void)
|
||||
{
|
||||
gtk_widget_show_all(mWindow);
|
||||
gint response = gtk_dialog_run(GTK_DIALOG(mWindow));
|
||||
switch (response) {
|
||||
case GTK_RESPONSE_NONE:
|
||||
case GTK_RESPONSE_CANCEL:
|
||||
case GTK_RESPONSE_DELETE_EVENT:
|
||||
mConfirmResult = PR_FALSE;
|
||||
break;
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
mConfirmResult = PR_TRUE;
|
||||
SaveDialogValues();
|
||||
break;
|
||||
default:
|
||||
mButtonPressed = response;
|
||||
SaveDialogValues();
|
||||
}
|
||||
gtk_widget_show_all(mWindow);
|
||||
gint response = gtk_dialog_run(GTK_DIALOG(mWindow));
|
||||
switch (response) {
|
||||
case GTK_RESPONSE_NONE:
|
||||
case GTK_RESPONSE_CANCEL:
|
||||
case GTK_RESPONSE_DELETE_EVENT:
|
||||
mConfirmResult = PR_FALSE;
|
||||
break;
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
mConfirmResult = PR_TRUE;
|
||||
SaveDialogValues();
|
||||
break;
|
||||
default:
|
||||
mButtonPressed = response;
|
||||
SaveDialogValues();
|
||||
}
|
||||
|
||||
gtk_widget_destroy(mWindow);
|
||||
gtk_widget_destroy(mWindow);
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrompter::SaveDialogValues()
|
||||
{
|
||||
if (mUserField)
|
||||
mUser.Assign(gtk_entry_get_text(GTK_ENTRY(mUserField)));
|
||||
if (mUserField)
|
||||
mUser.Assign(gtk_entry_get_text(GTK_ENTRY(mUserField)));
|
||||
|
||||
if (mPassField)
|
||||
mPass.Assign(gtk_entry_get_text(GTK_ENTRY(mPassField)));
|
||||
if (mPassField)
|
||||
mPass.Assign(gtk_entry_get_text(GTK_ENTRY(mPassField)));
|
||||
|
||||
if (mCheckBox)
|
||||
mCheckValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mCheckBox));
|
||||
if (mCheckBox)
|
||||
mCheckValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mCheckBox));
|
||||
|
||||
if (mTextField)
|
||||
mTextValue.Assign(gtk_entry_get_text(GTK_ENTRY(mTextField)));
|
||||
if (mTextField)
|
||||
mTextValue.Assign(gtk_entry_get_text(GTK_ENTRY(mTextField)));
|
||||
|
||||
if (mOptionMenu)
|
||||
#ifdef USE_GTK_COMBOBOX
|
||||
mSelectedItem = gtk_combo_box_get_active(GTK_COMBO_BOX(mOptionMenu));
|
||||
#else
|
||||
mSelectedItem = gtk_option_menu_get_history(GTK_OPTION_MENU(mOptionMenu));
|
||||
#endif /* USE_GTK_COMBOBOX */
|
||||
if (mOptionMenu)
|
||||
mSelectedItem = gtk_option_menu_get_history(GTK_OPTION_MENU(mOptionMenu));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +16,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -38,15 +38,9 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#include <nsString.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#define EMBED_MAX_BUTTONS 3
|
||||
|
||||
class EmbedPrompter {
|
||||
@ -70,7 +64,7 @@ public:
|
||||
|
||||
nsresult Create(PromptType aType, GtkWindow* aParentWindow);
|
||||
void SetTitle(const PRUnichar *aTitle);
|
||||
void SetTextValue(const PRUnichar *aTextValue);
|
||||
void SetTextValue (const PRUnichar *aTextValue);
|
||||
void SetCheckMessage(const PRUnichar *aCheckMessage);
|
||||
void SetCheckValue(const PRBool aValue);
|
||||
void SetMessageText(const PRUnichar *aMessageText);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/*
|
||||
* vim:ts=2:et:sw=2
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -17,7 +17,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -38,15 +38,12 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCWebBrowser.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include <nsCWebBrowser.h>
|
||||
#include <nsIComponentManager.h>
|
||||
#include <nsIDocShellTreeItem.h>
|
||||
#include "nsIWidget.h"
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsReadableUtils.h"
|
||||
#else
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#endif
|
||||
|
||||
#include "EmbedWindow.h"
|
||||
#include "EmbedPrivate.h"
|
||||
#include "EmbedPrompter.h"
|
||||
@ -77,7 +74,7 @@ EmbedWindow::Init(EmbedPrivate *aOwner)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome *>(this));
|
||||
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(mWebBrowser);
|
||||
item->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
|
||||
|
||||
@ -94,10 +91,10 @@ EmbedWindow::CreateWindow(void)
|
||||
// create the window.
|
||||
mBaseWindow = do_QueryInterface(mWebBrowser);
|
||||
rv = mBaseWindow->InitWindow(GTK_WIDGET(mOwner->mOwningWidget),
|
||||
nsnull,
|
||||
0, 0,
|
||||
ownerAsWidget->allocation.width,
|
||||
ownerAsWidget->allocation.height);
|
||||
nsnull,
|
||||
0, 0,
|
||||
ownerAsWidget->allocation.width,
|
||||
ownerAsWidget->allocation.height);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -112,7 +109,7 @@ void
|
||||
EmbedWindow::ReleaseChildren(void)
|
||||
{
|
||||
ExitModalEventLoop(PR_FALSE);
|
||||
|
||||
|
||||
mBaseWindow->Destroy();
|
||||
mBaseWindow = 0;
|
||||
mWebBrowser = 0;
|
||||
@ -128,7 +125,7 @@ NS_INTERFACE_MAP_BEGIN(EmbedWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
||||
// NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
@ -138,21 +135,21 @@ NS_IMETHODIMP
|
||||
EmbedWindow::SetStatus(PRUint32 aStatusType, const PRUnichar *aStatus)
|
||||
{
|
||||
switch (aStatusType) {
|
||||
case STATUS_SCRIPT:
|
||||
case STATUS_SCRIPT:
|
||||
{
|
||||
mJSStatus = aStatus; //FIXME MEMORY LEAK
|
||||
mJSStatus = aStatus;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[JS_STATUS]);
|
||||
moz_embed_signals[JS_STATUS]);
|
||||
}
|
||||
break;
|
||||
case STATUS_SCRIPT_DEFAULT:
|
||||
case STATUS_SCRIPT_DEFAULT:
|
||||
// Gee, that's nice.
|
||||
break;
|
||||
case STATUS_LINK:
|
||||
case STATUS_LINK:
|
||||
{
|
||||
mLinkMessage = aStatus;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[LINK_MESSAGE]);
|
||||
moz_embed_signals[LINK_MESSAGE]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -195,7 +192,7 @@ EmbedWindow::DestroyBrowserWindow(void)
|
||||
mOwner->mIsDestroyed = PR_TRUE;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[DESTROY_BROWSER]);
|
||||
moz_embed_signals[DESTROY_BROWSER]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -203,7 +200,7 @@ NS_IMETHODIMP
|
||||
EmbedWindow::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
|
||||
{
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[SIZE_TO], aCX, aCY);
|
||||
moz_embed_signals[SIZE_TO], aCX, aCY);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -243,13 +240,23 @@ EmbedWindow::ExitModalEventLoop(nsresult aStatus)
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::FocusNextElement()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
GtkWidget* parent = GTK_WIDGET(mOwner->mOwningWidget)->parent;
|
||||
|
||||
if (GTK_IS_CONTAINER(parent))
|
||||
gtk_container_focus(GTK_CONTAINER(parent),
|
||||
GTK_DIR_TAB_FORWARD);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
GtkWidget *toplevel;
|
||||
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
|
||||
if (!GTK_WIDGET_TOPLEVEL(toplevel))
|
||||
return NS_OK;
|
||||
|
||||
g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
|
||||
GTK_DIR_TAB_FORWARD);
|
||||
GTK_DIR_TAB_FORWARD);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -257,13 +264,23 @@ EmbedWindow::FocusNextElement()
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::FocusPrevElement()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
GtkWidget* parent = GTK_WIDGET(mOwner->mOwningWidget)->parent;
|
||||
|
||||
if (GTK_IS_CONTAINER(parent))
|
||||
gtk_container_focus(GTK_CONTAINER(parent),
|
||||
GTK_DIR_TAB_BACKWARD);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
GtkWidget *toplevel;
|
||||
toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
|
||||
if (!GTK_WIDGET_TOPLEVEL(toplevel))
|
||||
return NS_OK;
|
||||
|
||||
g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
|
||||
GTK_DIR_TAB_BACKWARD);
|
||||
GTK_DIR_TAB_BACKWARD);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -272,18 +289,18 @@ EmbedWindow::FocusPrevElement()
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY,
|
||||
PRInt32 aCX, PRInt32 aCY)
|
||||
PRInt32 aCX, PRInt32 aCY)
|
||||
{
|
||||
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
|
||||
(aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
return mBaseWindow->SetPositionAndSize(aX, aY, aCX, aCY, PR_TRUE);
|
||||
}
|
||||
else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
|
||||
return mBaseWindow->SetPosition(aX, aY);
|
||||
}
|
||||
else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
return mBaseWindow->SetSize(aCX, aCY, PR_TRUE);
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -291,18 +308,18 @@ EmbedWindow::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY,
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::GetDimensions(PRUint32 aFlags, PRInt32 *aX,
|
||||
PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
|
||||
PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
|
||||
{
|
||||
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
|
||||
(aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
return mBaseWindow->GetPositionAndSize(aX, aY, aCX, aCY);
|
||||
}
|
||||
else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
|
||||
return mBaseWindow->GetPosition(aX, aY);
|
||||
}
|
||||
else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
return mBaseWindow->GetSize(aCX, aCY);
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -327,14 +344,14 @@ EmbedWindow::SetTitle(const PRUnichar *aTitle)
|
||||
{
|
||||
mTitle = aTitle;
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[TITLE]);
|
||||
moz_embed_signals[TITLE]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::GetSiteWindow(void **aSiteWindow)
|
||||
{
|
||||
GtkWidget *ownerAsWidget(GTK_WIDGET(mOwner->mOwningWidget));
|
||||
GtkWidget *ownerAsWidget (GTK_WIDGET(mOwner->mOwningWidget));
|
||||
*aSiteWindow = static_cast<void *>(ownerAsWidget);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -342,10 +359,14 @@ EmbedWindow::GetSiteWindow(void **aSiteWindow)
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::GetVisibility(PRBool *aVisibility)
|
||||
{
|
||||
// XXX See bug 312998
|
||||
// Work around the problem that sometimes the window
|
||||
// is already visible even though mVisibility isn't true
|
||||
// yet.
|
||||
*aVisibility = mVisibility ||
|
||||
!mOwner->mIsChrome &&
|
||||
mOwner->mOwningWidget &&
|
||||
GTK_WIDGET_MAPPED(mOwner->mOwningWidget);
|
||||
(!mOwner->mIsChrome &&
|
||||
mOwner->mOwningWidget &&
|
||||
GTK_WIDGET_MAPPED(mOwner->mOwningWidget));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -362,14 +383,13 @@ EmbedWindow::SetVisibility(PRBool aVisibility)
|
||||
return NS_OK;
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
|
||||
moz_embed_signals[VISIBILITY],
|
||||
aVisibility);
|
||||
moz_embed_signals[VISIBILITY],
|
||||
aVisibility);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsITooltipListener
|
||||
|
||||
#if 0
|
||||
static gint
|
||||
tooltips_paint_window(GtkWidget *window)
|
||||
{
|
||||
@ -382,24 +402,29 @@ tooltips_paint_window(GtkWidget *window)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
const PRUnichar *aTipText)
|
||||
const PRUnichar *aTipText)
|
||||
{
|
||||
nsAutoString tipText(aTipText);
|
||||
nsAutoString tipText ( aTipText );
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
const char* tipString = ToNewCString(tipText);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
const char* tipString = ToNewUTF8String(tipText);
|
||||
#endif
|
||||
|
||||
if (sTipWindow)
|
||||
gtk_widget_destroy(sTipWindow);
|
||||
|
||||
|
||||
// get the root origin for this content window
|
||||
nsCOMPtr<nsIWidget> mainWidget;
|
||||
mBaseWindow->GetMainWidget(getter_AddRefs(mainWidget));
|
||||
GdkWindow *window;
|
||||
window = static_cast<GdkWindow *>
|
||||
(mainWidget->GetNativeData(NS_NATIVE_WINDOW));
|
||||
window = static_cast<GdkWindow *>(mainWidget->GetNativeData(NS_NATIVE_WINDOW));
|
||||
gint root_x, root_y;
|
||||
gdk_window_get_origin(window, &root_x, &root_y);
|
||||
|
||||
@ -407,13 +432,13 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
// tooltips vanish if they show up right at the origin of the
|
||||
// cursor.
|
||||
root_y += 10;
|
||||
|
||||
|
||||
sTipWindow = gtk_window_new(GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_app_paintable(sTipWindow, TRUE);
|
||||
gtk_window_set_policy(GTK_WINDOW(sTipWindow), FALSE, FALSE, TRUE);
|
||||
// needed to get colors + fonts etc correctly
|
||||
gtk_widget_set_name(sTipWindow, "gtk-tooltips");
|
||||
|
||||
|
||||
// set up the popup window as a transient of the widget.
|
||||
GtkWidget *toplevel_window;
|
||||
toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
|
||||
@ -422,8 +447,8 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
gtk_window_set_transient_for(GTK_WINDOW(sTipWindow),
|
||||
GTK_WINDOW(toplevel_window));
|
||||
|
||||
GTK_WINDOW(toplevel_window));
|
||||
|
||||
// realize the widget
|
||||
gtk_widget_realize(sTipWindow);
|
||||
|
||||
@ -438,12 +463,16 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
gtk_container_set_border_width(GTK_CONTAINER(sTipWindow), 4);
|
||||
// set the coords for the widget
|
||||
gtk_widget_set_uposition(sTipWindow, aXCoords + root_x,
|
||||
aYCoords + root_y);
|
||||
aYCoords + root_y);
|
||||
|
||||
// and show it.
|
||||
gtk_widget_show_all(sTipWindow);
|
||||
|
||||
nsMemory::Free((void*)tipString);
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
gtk_widget_popup(sTipWindow, aXCoords + root_x, aYCoords + root_y);
|
||||
#endif /* MOZ_WIDGET_GTK */
|
||||
|
||||
nsMemory::Free( (void*)tipString );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -456,7 +485,6 @@ EmbedWindow::OnHideTooltip(void)
|
||||
sTipWindow = NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
|
||||
@ -464,7 +492,7 @@ NS_IMETHODIMP
|
||||
EmbedWindow::GetInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
||||
rv = QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
// pass it up to the web browser object
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -40,30 +38,27 @@
|
||||
#ifndef __EmbedWindow_h
|
||||
#define __EmbedWindow_h
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include <nsString.h>
|
||||
#include <nsIWebBrowserChrome.h>
|
||||
#include <nsIWebBrowserChromeFocus.h>
|
||||
#include <nsIEmbeddingSiteWindow.h>
|
||||
#include <nsITooltipListener.h>
|
||||
#include <nsISupports.h>
|
||||
#include <nsIWebBrowser.h>
|
||||
#include <nsIBaseWindow.h>
|
||||
#include <nsIInterfaceRequestor.h>
|
||||
#include <nsCOMPtr.h>
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIWebBrowserChromeFocus.h"
|
||||
#include "nsIEmbeddingSiteWindow.h"
|
||||
//#include "nsITooltipListener.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
class EmbedPrivate;
|
||||
|
||||
class EmbedWindow : public nsIWebBrowserChrome,
|
||||
public nsIWebBrowserChromeFocus,
|
||||
public nsIWebBrowserChromeFocus,
|
||||
public nsIEmbeddingSiteWindow,
|
||||
// public nsITooltipListener,
|
||||
public nsIInterfaceRequestor
|
||||
public nsITooltipListener,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
|
||||
public:
|
||||
@ -83,7 +78,7 @@ class EmbedWindow : public nsIWebBrowserChrome,
|
||||
|
||||
NS_DECL_NSIEMBEDDINGSITEWINDOW
|
||||
|
||||
// NS_DECL_NSITOOLTIPLISTENER
|
||||
NS_DECL_NSITOOLTIPLISTENER
|
||||
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
@ -102,6 +97,6 @@ private:
|
||||
PRBool mIsModal;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* __EmbedWindow_h */
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,8 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
*
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -45,9 +42,8 @@
|
||||
// in order to create orphaned windows
|
||||
#include "gtkmozembedprivate.h"
|
||||
|
||||
EmbedWindowCreator::EmbedWindowCreator(PRBool *aOpenBlockPtr)
|
||||
EmbedWindowCreator::EmbedWindowCreator(void)
|
||||
{
|
||||
mOpenBlock = aOpenBlockPtr;
|
||||
}
|
||||
|
||||
EmbedWindowCreator::~EmbedWindowCreator()
|
||||
@ -58,34 +54,29 @@ NS_IMPL_ISUPPORTS1(EmbedWindowCreator, nsIWindowCreator)
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
if (mOpenBlock) {
|
||||
if (*mOpenBlock == PR_TRUE) {
|
||||
*mOpenBlock = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
GtkMozEmbed *newEmbed = nsnull;
|
||||
|
||||
// No parent? Ask via the singleton object instead.
|
||||
if (!aParent) {
|
||||
gtk_moz_embed_single_create_window(&newEmbed,
|
||||
(guint)aChromeFlags);
|
||||
} else {
|
||||
(guint)aChromeFlags);
|
||||
}
|
||||
else {
|
||||
// Find the EmbedPrivate object for this web browser chrome object.
|
||||
EmbedPrivate *embedPrivate = EmbedPrivate::FindPrivateForBrowser(aParent);
|
||||
|
||||
|
||||
if (!embedPrivate)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(embedPrivate->mOwningWidget),
|
||||
moz_embed_signals[NEW_WINDOW],
|
||||
&newEmbed, (guint)aChromeFlags);
|
||||
|
||||
moz_embed_signals[NEW_WINDOW],
|
||||
&newEmbed, (guint)aChromeFlags);
|
||||
|
||||
}
|
||||
|
||||
// check to make sure that we made a new window
|
||||
@ -97,17 +88,15 @@ EmbedWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
// will do things like GetDocShell() and the widget has to be
|
||||
// realized before that can happen.
|
||||
gtk_widget_realize(GTK_WIDGET(newEmbed));
|
||||
|
||||
EmbedPrivate *newEmbedPrivate = static_cast<EmbedPrivate *>
|
||||
(newEmbed->data);
|
||||
|
||||
EmbedPrivate *newEmbedPrivate = static_cast<EmbedPrivate *>(newEmbed->data);
|
||||
|
||||
// set the chrome flag on the new window if it's a chrome open
|
||||
if (aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)
|
||||
newEmbedPrivate->mIsChrome = PR_TRUE;
|
||||
|
||||
*_retval = static_cast<nsIWebBrowserChrome *>
|
||||
((newEmbedPrivate->mWindow));
|
||||
|
||||
*_retval = static_cast<nsIWebBrowserChrome *>(newEmbedPrivate->mWindow);
|
||||
|
||||
if (*_retval) {
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -40,19 +38,17 @@
|
||||
#ifndef __EmbedWindowCreator_h
|
||||
#define __EmbedWindowCreator_h
|
||||
|
||||
#include "nsIWindowCreator.h"
|
||||
#include <nsIWindowCreator.h>
|
||||
|
||||
class EmbedWindowCreator : public nsIWindowCreator
|
||||
{
|
||||
public:
|
||||
EmbedWindowCreator(PRBool *aOpenBlockPtr);
|
||||
EmbedWindowCreator();
|
||||
virtual ~EmbedWindowCreator();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWCREATOR
|
||||
|
||||
private:
|
||||
PRBool *mOpenBlock;
|
||||
|
||||
};
|
||||
|
||||
#endif /* __EmbedWindowCreator_h */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=4 sts=2 et cindent: */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -22,7 +22,6 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -39,33 +38,13 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "GtkPromptService.h"
|
||||
#include "EmbedGtkTools.h"
|
||||
#include "gtkmozembedprivate.h"
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
#include "EmbedPrompter.h"
|
||||
#endif
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIEmbeddingSiteWindow.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#define UNACCEPTABLE_CRASHY_GLIB_ALLOCATION(newed) PR_BEGIN_MACRO \
|
||||
/* OOPS this code is using a glib allocation function which \
|
||||
* will cause the application to crash when it runs out of \
|
||||
* memory. This is not cool. either g_try methods should be \
|
||||
* used or malloc, or new (note that gecko /will/ be replacing \
|
||||
* its operator new such that new will not throw exceptions). \
|
||||
* XXX please fix me. \
|
||||
*/ \
|
||||
if (!newed) { \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
#include <nsString.h>
|
||||
#include <nsIWindowWatcher.h>
|
||||
#include <nsIWebBrowserChrome.h>
|
||||
#include <nsIEmbeddingSiteWindow.h>
|
||||
#include <nsCOMPtr.h>
|
||||
#include <nsIServiceManager.h>
|
||||
|
||||
GtkPromptService::GtkPromptService()
|
||||
{
|
||||
@ -75,513 +54,295 @@ GtkPromptService::~GtkPromptService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(GtkPromptService, nsIPromptService, nsICookiePromptService)
|
||||
NS_IMPL_ISUPPORTS1(GtkPromptService, nsIPromptService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Alert(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText)
|
||||
GtkPromptService::Alert(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[ALERT], TRUE)) {
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[ALERT],
|
||||
(const gchar *) NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
(const gchar *) NS_ConvertUTF16toUTF8(aDialogText).get());
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.Create(EmbedPrompter::TYPE_ALERT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.Create(EmbedPrompter::TYPE_ALERT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::AlertCheck(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue)
|
||||
GtkPromptService::AlertCheck(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
const PRUnichar* aCheckMsg, PRBool* aCheckValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCheckValue);
|
||||
NS_ENSURE_ARG_POINTER(aCheckValue);
|
||||
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[ALERT_CHECK], TRUE)) {
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[ALERT_CHECK],
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aCheckMsg).get(),
|
||||
aCheckValue);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
prompter.Create(EmbedPrompter::TYPE_ALERT_CHECK,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Confirm(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[CONFIRM], TRUE)) {
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[CONFIRM],
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(), NS_ConvertUTF16toUTF8(aDialogText).get(), aConfirm);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.Create(EmbedPrompter::TYPE_CONFIRM,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::ConfirmCheck(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCheckValue);
|
||||
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[CONFIRM_CHECK], TRUE)) {
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[CONFIRM_CHECK],
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aCheckMsg).get(),
|
||||
aCheckValue,
|
||||
aConfirm);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
prompter.Create(EmbedPrompter::TYPE_CONFIRM_CHECK,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::ConfirmEx(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUint32 aButtonFlags,
|
||||
const PRUnichar* aButton0Title,
|
||||
const PRUnichar* aButton1Title,
|
||||
const PRUnichar* aButton2Title,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRInt32* aRetVal)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[CONFIRM_EX], TRUE)) {
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[CONFIRM_EX],
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aDialogText).get(),
|
||||
aButtonFlags,
|
||||
NS_ConvertUTF16toUTF8(aButton0Title).get(),
|
||||
NS_ConvertUTF16toUTF8(aButton1Title).get(),
|
||||
NS_ConvertUTF16toUTF8(aButton2Title).get(),
|
||||
NS_ConvertUTF16toUTF8(aCheckMsg).get(),
|
||||
aCheckValue,
|
||||
aRetVal);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
|
||||
nsAutoString button0Label, button1Label, button2Label;
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_0, aButton0Title, button0Label);
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_1, aButton1Title, button1Label);
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_2, aButton2Title, button2Label);
|
||||
prompter.SetButtons(button0Label.get(),
|
||||
button1Label.get(),
|
||||
button2Label.get());
|
||||
|
||||
if (aCheckMsg)
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Alert").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_UNIVERSAL,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
|
||||
if (aCheckValue)
|
||||
prompter.Create(EmbedPrompter::TYPE_ALERT_CHECK,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
|
||||
prompter.GetButtonPressed(aRetVal);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define XXX_ALLOCATOR_MISMATCH_XPCOM_GLIB(confused) PR_BEGIN_MACRO \
|
||||
/* There is no way that this unforunate and confused object can \
|
||||
* possibly be handled correctly. It started its life as an \
|
||||
* XPCOM allocated pointer. \
|
||||
* Then someone called it a gchar which confused it. \
|
||||
* Then it was passed to a random function which probably \
|
||||
* assumed it had ownership. \
|
||||
* Finally it was freed using g_free. \
|
||||
* This pointer is seriously confused. \
|
||||
* XXX please please please help this pointer find some way to \
|
||||
* rest in peace. \
|
||||
*/ \
|
||||
PR_END_MACRO
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Confirm(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText, PRBool* aConfirm)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.Create(EmbedPrompter::TYPE_CONFIRM,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Prompt(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aValue,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
GtkPromptService::ConfirmCheck(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue, PRBool* aConfirm)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[PROMPT], TRUE)) {
|
||||
gchar * value = ToNewCString(NS_ConvertUTF16toUTF8(*aValue));
|
||||
XXX_ALLOCATOR_MISMATCH_XPCOM_GLIB(value);
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[PROMPT],
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aDialogText).get(),
|
||||
&value,
|
||||
NS_ConvertUTF16toUTF8(aCheckMsg).get(),
|
||||
aCheckValue,
|
||||
aConfirm,
|
||||
NULL);
|
||||
NS_ENSURE_ARG_POINTER(aCheckValue);
|
||||
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
prompter.Create(EmbedPrompter::TYPE_CONFIRM_CHECK,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::ConfirmEx(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUint32 aButtonFlags,
|
||||
const PRUnichar* aButton0Title,
|
||||
const PRUnichar* aButton1Title,
|
||||
const PRUnichar* aButton2Title,
|
||||
const PRUnichar* aCheckMsg, PRBool* aCheckValue,
|
||||
PRInt32* aRetVal)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Confirm").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
|
||||
nsAutoString button0Label, button1Label, button2Label;
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_0, aButton0Title, button0Label);
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_1, aButton1Title, button1Label);
|
||||
GetButtonLabel(aButtonFlags, BUTTON_POS_2, aButton2Title, button2Label);
|
||||
prompter.SetButtons(button0Label.get(), button1Label.get(),
|
||||
button2Label.get());
|
||||
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_UNIVERSAL,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
|
||||
prompter.GetButtonPressed(aRetVal);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Prompt(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText, PRUnichar** aValue,
|
||||
const PRUnichar* aCheckMsg, PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetTextValue(*aValue);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aValue)
|
||||
NS_Free(*aValue);
|
||||
*aValue = ToNewUnicode(NS_ConvertUTF8toUTF16(value));
|
||||
if (*aValue)
|
||||
nsMemory::Free(*aValue);
|
||||
prompter.GetTextValue(aValue);
|
||||
}
|
||||
g_free(value);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetTextValue(*aValue);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aValue)
|
||||
NS_Free(*aValue);
|
||||
prompter.GetTextValue(aValue);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::PromptUsernameAndPassword(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aUsername,
|
||||
PRUnichar** aPassword,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
GtkPromptService::PromptUsernameAndPassword(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aUsername,
|
||||
PRUnichar** aPassword,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[PROMPT_AUTH], TRUE)) {
|
||||
gchar * username = ToNewCString(NS_ConvertUTF16toUTF8(*aUsername));
|
||||
XXX_ALLOCATOR_MISMATCH_XPCOM_GLIB(username);
|
||||
gchar * password = ToNewCString(NS_ConvertUTF16toUTF8(*aPassword));
|
||||
XXX_ALLOCATOR_MISMATCH_XPCOM_GLIB(password);
|
||||
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[PROMPT_AUTH],
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aDialogText).get(),
|
||||
&username, &password,
|
||||
NS_ConvertUTF16toUTF8(aCheckMsg).get(),
|
||||
aCheckValue, aConfirm);
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetUser(*aUsername);
|
||||
prompter.SetPassword(*aPassword);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_USER_PASS,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aUsername)
|
||||
NS_Free(*aUsername);
|
||||
*aUsername = ToNewUnicode(NS_ConvertUTF8toUTF16(username));
|
||||
if (*aPassword)
|
||||
NS_Free(*aPassword);
|
||||
*aPassword = ToNewUnicode(NS_ConvertUTF8toUTF16(password));
|
||||
if (*aUsername)
|
||||
nsMemory::Free(*aUsername);
|
||||
prompter.GetUser(aUsername);
|
||||
|
||||
if (*aPassword)
|
||||
nsMemory::Free(*aPassword);
|
||||
prompter.GetPassword(aPassword);
|
||||
}
|
||||
g_free(username);
|
||||
g_free(password);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetUser(*aUsername);
|
||||
prompter.SetPassword(*aPassword);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_USER_PASS,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aUsername)
|
||||
NS_Free(*aUsername);
|
||||
prompter.GetUser(aUsername);
|
||||
|
||||
if (*aPassword)
|
||||
NS_Free(*aPassword);
|
||||
prompter.GetPassword(aPassword);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::PromptPassword(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aPassword,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue, PRBool* aConfirm)
|
||||
GtkPromptService::PromptPassword(nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUnichar** aPassword,
|
||||
const PRUnichar* aCheckMsg,
|
||||
PRBool* aCheckValue, PRBool* aConfirm)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[PROMPT_AUTH], TRUE)) {
|
||||
gchar * password = ToNewCString(NS_ConvertUTF16toUTF8(*aPassword));
|
||||
XXX_ALLOCATOR_MISMATCH_XPCOM_GLIB(password);
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[PROMPT_AUTH],
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aDialogText).get(),
|
||||
NULL,
|
||||
&password,
|
||||
NS_ConvertUTF16toUTF8(aCheckMsg).get(),
|
||||
aCheckValue,
|
||||
aConfirm);
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetPassword(*aPassword);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_PASS,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aPassword)
|
||||
NS_Free(*aPassword);
|
||||
*aPassword = ToNewUnicode(NS_ConvertUTF8toUTF16(password));
|
||||
if (*aPassword)
|
||||
nsMemory::Free(*aPassword);
|
||||
prompter.GetPassword(aPassword);
|
||||
}
|
||||
g_free(password);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Prompt").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetPassword(*aPassword);
|
||||
if (aCheckMsg)
|
||||
prompter.SetCheckMessage(aCheckMsg);
|
||||
if (aCheckValue)
|
||||
prompter.SetCheckValue(*aCheckValue);
|
||||
|
||||
prompter.Create(EmbedPrompter::TYPE_PROMPT_PASS,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
if (aCheckValue)
|
||||
prompter.GetCheckValue(aCheckValue);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
if (*aConfirm) {
|
||||
if (*aPassword)
|
||||
NS_Free(*aPassword);
|
||||
prompter.GetPassword(aPassword);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::Select(
|
||||
nsIDOMWindow* aParent,
|
||||
const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText,
|
||||
PRUint32 aCount,
|
||||
const PRUnichar** aSelectList,
|
||||
PRInt32* outSelection,
|
||||
PRBool* aConfirm)
|
||||
GtkPromptService::Select(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
|
||||
const PRUnichar* aDialogText, PRUint32 aCount,
|
||||
const PRUnichar** aSelectList, PRInt32* outSelection,
|
||||
PRBool* aConfirm)
|
||||
{
|
||||
GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aParent);
|
||||
if (parentWidget && gtk_signal_handler_pending(parentWidget, moz_embed_signals[SELECT], TRUE)) {
|
||||
GList * list = NULL;
|
||||
nsCString *itemList = new nsCString[aCount];
|
||||
NS_ENSURE_TRUE(itemList, NS_ERROR_OUT_OF_MEMORY);
|
||||
for (PRUint32 i = 0; i < aCount; ++i) {
|
||||
itemList[i] = ToNewCString(NS_ConvertUTF16toUTF8(aSelectList[i]));
|
||||
list = g_list_append(list, (gpointer)itemList[i].get());
|
||||
}
|
||||
gtk_signal_emit(GTK_OBJECT(parentWidget),
|
||||
moz_embed_signals[SELECT],
|
||||
NS_ConvertUTF16toUTF8(aDialogTitle).get(),
|
||||
NS_ConvertUTF16toUTF8(aDialogText).get(),
|
||||
(const GList**)&list,
|
||||
outSelection,
|
||||
aConfirm);
|
||||
delete[] itemList;
|
||||
g_list_free(list);
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Select").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetItems(aSelectList, aCount);
|
||||
prompter.Create(EmbedPrompter::TYPE_SELECT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetSelectedItem(outSelection);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
return NS_OK;
|
||||
}
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
EmbedPrompter prompter;
|
||||
prompter.SetTitle(aDialogTitle ? aDialogTitle : NS_LITERAL_STRING("Select").get());
|
||||
prompter.SetMessageText(aDialogText);
|
||||
prompter.SetItems(aSelectList, aCount);
|
||||
prompter.Create(EmbedPrompter::TYPE_SELECT,
|
||||
GetGtkWindowForDOMWindow(aParent));
|
||||
prompter.Run();
|
||||
prompter.GetSelectedItem(outSelection);
|
||||
prompter.GetConfirmValue(aConfirm);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
/* nsCookiePromptService */
|
||||
NS_IMETHODIMP
|
||||
GtkPromptService::CookieDialog(
|
||||
nsIDOMWindow *aParent,
|
||||
nsICookie *aCookie,
|
||||
const nsACString &aHostname,
|
||||
PRInt32 aCookiesFromHost,
|
||||
PRBool aChangingCookie,
|
||||
PRBool *aRememberDecision,
|
||||
PRInt32 *aAccept)
|
||||
{
|
||||
/* FIXME - missing gint actions and gboolean illegal_path */
|
||||
gint actions = 1;
|
||||
nsCString hostName(aHostname);
|
||||
nsCString aName;
|
||||
aCookie->GetName(aName);
|
||||
nsCString aValue;
|
||||
aCookie->GetValue(aValue);
|
||||
nsCString aDomain;
|
||||
aCookie->GetHost(aDomain);
|
||||
nsCString aPath;
|
||||
aCookie->GetPath(aPath);
|
||||
/* We have to investigate a value to use here */
|
||||
gboolean illegal_path = FALSE;
|
||||
PRUint64 aExpires;
|
||||
aCookie->GetExpires(&aExpires);
|
||||
nsCOMPtr<nsIDOMWindow> domWindow(do_QueryInterface(aParent));
|
||||
GtkMozEmbed *parentWidget = GTK_MOZ_EMBED(GetGtkWidgetForDOMWindow(domWindow));
|
||||
GtkMozEmbedCookie *cookie_struct = g_new0(GtkMozEmbedCookie, 1);
|
||||
UNACCEPTABLE_CRASHY_GLIB_ALLOCATION(cookie_struct);
|
||||
if (parentWidget && cookie_struct) {
|
||||
g_signal_emit_by_name(
|
||||
GTK_OBJECT(parentWidget->common),
|
||||
"ask-cookie",
|
||||
cookie_struct,
|
||||
actions,
|
||||
(const gchar *) hostName.get(),
|
||||
(const gchar *) aName.get(),
|
||||
(const gchar *) aValue.get(),
|
||||
(const gchar *) aDomain.get(),
|
||||
(const gchar *) aPath.get(),
|
||||
illegal_path,
|
||||
aExpires,
|
||||
NULL);
|
||||
}
|
||||
*aRememberDecision = !!(cookie_struct->remember_decision);
|
||||
*aAccept = cookie_struct->accept;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
GtkWindow*
|
||||
GtkPromptService::GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow)
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");
|
||||
|
||||
if (!aDOMWindow)
|
||||
return NULL;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserChrome> chrome;
|
||||
wwatch->GetChromeForWindow(aDOMWindow, getter_AddRefs(chrome));
|
||||
nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow = do_QueryInterface(chrome);
|
||||
|
||||
if (!siteWindow)
|
||||
return NULL;
|
||||
|
||||
GtkWidget* parentWidget;
|
||||
siteWindow->GetSiteWindow((void**)&parentWidget);
|
||||
|
||||
if (!parentWidget)
|
||||
return NULL;
|
||||
|
||||
GtkWidget* gtkWin = gtk_widget_get_toplevel(parentWidget);
|
||||
if (GTK_WIDGET_TOPLEVEL(gtkWin))
|
||||
return GTK_WINDOW(gtkWin);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
GtkPromptService::GetButtonLabel(
|
||||
PRUint32 aFlags,
|
||||
PRUint32 aPos,
|
||||
const PRUnichar* aStringValue,
|
||||
nsAString& aLabel)
|
||||
GtkPromptService::GetButtonLabel(PRUint32 aFlags, PRUint32 aPos,
|
||||
const PRUnichar* aStringValue,
|
||||
nsAString& aLabel)
|
||||
{
|
||||
PRUint32 posFlag = (aFlags & (255 * aPos)) / aPos;
|
||||
switch (posFlag) {
|
||||
case 0:
|
||||
break;
|
||||
case BUTTON_TITLE_OK:
|
||||
aLabel.AssignLiteral(GTK_STOCK_OK);
|
||||
break;
|
||||
case BUTTON_TITLE_CANCEL:
|
||||
aLabel.AssignLiteral(GTK_STOCK_CANCEL);
|
||||
break;
|
||||
case BUTTON_TITLE_YES:
|
||||
aLabel.AssignLiteral(GTK_STOCK_YES);
|
||||
break;
|
||||
case BUTTON_TITLE_NO:
|
||||
aLabel.AssignLiteral(GTK_STOCK_NO);
|
||||
break;
|
||||
case BUTTON_TITLE_SAVE:
|
||||
aLabel.AssignLiteral(GTK_STOCK_SAVE);
|
||||
break;
|
||||
case BUTTON_TITLE_DONT_SAVE:
|
||||
aLabel.AssignLiteral("Don't Save");
|
||||
break;
|
||||
case BUTTON_TITLE_REVERT:
|
||||
aLabel.AssignLiteral("Revert");
|
||||
break;
|
||||
case BUTTON_TITLE_IS_STRING:
|
||||
aLabel = aStringValue;
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unexpected button flags");
|
||||
}
|
||||
PRUint32 posFlag = (aFlags & (255 * aPos)) / aPos;
|
||||
switch (posFlag) {
|
||||
case 0:
|
||||
break;
|
||||
case BUTTON_TITLE_OK:
|
||||
aLabel.AssignLiteral(GTK_STOCK_OK);
|
||||
break;
|
||||
case BUTTON_TITLE_CANCEL:
|
||||
aLabel.AssignLiteral(GTK_STOCK_CANCEL);
|
||||
break;
|
||||
case BUTTON_TITLE_YES:
|
||||
aLabel.AssignLiteral(GTK_STOCK_YES);
|
||||
break;
|
||||
case BUTTON_TITLE_NO:
|
||||
aLabel.AssignLiteral(GTK_STOCK_NO);
|
||||
break;
|
||||
case BUTTON_TITLE_SAVE:
|
||||
aLabel.AssignLiteral(GTK_STOCK_SAVE);
|
||||
break;
|
||||
case BUTTON_TITLE_DONT_SAVE:
|
||||
aLabel.AssignLiteral("Don't Save");
|
||||
break;
|
||||
case BUTTON_TITLE_REVERT:
|
||||
aLabel.AssignLiteral("Revert");
|
||||
break;
|
||||
case BUTTON_TITLE_IS_STRING:
|
||||
aLabel = aStringValue;
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unexpected button flags");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:expandtab:shiftwidth=4:tabstop=4: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -22,7 +22,6 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -38,23 +37,13 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsICookiePromptService.h"
|
||||
#include "nsICookie.h"
|
||||
#include "nsNetCID.h"
|
||||
#include <nsIPromptService.h>
|
||||
#include <nsString.h>
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsStringAPI.h"
|
||||
#endif
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
{0x95611356, 0xf583, 0x46f5, {0x81, 0xff, 0x4b, 0x3e, 0x01, 0x62, 0xc6, 0x19}}
|
||||
|
||||
class nsIDOMWindow;
|
||||
|
||||
class GtkPromptService : public nsIPromptService,
|
||||
public nsICookiePromptService
|
||||
class GtkPromptService : public nsIPromptService
|
||||
{
|
||||
public:
|
||||
GtkPromptService();
|
||||
@ -62,11 +51,9 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROMPTSERVICE
|
||||
NS_DECL_NSICOOKIEPROMPTSERVICE
|
||||
|
||||
#ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
private:
|
||||
GtkWindow* GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow);
|
||||
void GetButtonLabel(PRUint32 aFlags, PRUint32 aPos,
|
||||
const PRUnichar* aStringValue, nsAString &aLabel);
|
||||
#endif
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
#
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
@ -43,76 +43,28 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = gtkembedmoz
|
||||
LIBRARY_NAME = gtkembedmoz
|
||||
LIBXUL_LIBRARY = 1
|
||||
MODULE = gtkembedmoz
|
||||
LIBRARY_NAME = gtkembedmoz
|
||||
LIBXUL_LIBRARY = 1
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
LOCAL_INCLUDES += \
|
||||
-I. \
|
||||
$(NULL)
|
||||
|
||||
#Temporary define for full migration from libxul
|
||||
#MOZ_GTKEMBED_DYN = 1
|
||||
|
||||
ifdef MOZ_GTKEMBED_DYN
|
||||
#DEFINES += -DFIXED_BUG347731
|
||||
FORCE_SHARED_LIB = 1
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
LIBXUL_LIBRARY =
|
||||
endif
|
||||
endif
|
||||
|
||||
DEFINES += -DIMPL_XREAPI
|
||||
|
||||
# New Stuff in GtkMozEmbed
|
||||
ifdef MOZ_MICROBEMBED
|
||||
DEFINES += -DBAD_CERT_LISTENER2
|
||||
#Probably scrolling can be fixed without this hack
|
||||
DEFINES += -DMOZ_SCROLL_TOP_LEFT_HACK
|
||||
|
||||
MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT = 1
|
||||
DEFINES += -DMOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
|
||||
MOZ_GTKPASSWORD_INTERFACE = 1
|
||||
DEFINES += -DMOZ_GTKPASSWORD_INTERFACE
|
||||
endif
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
content \
|
||||
string \
|
||||
docshell \
|
||||
necko \
|
||||
widget \
|
||||
dom \
|
||||
gfx \
|
||||
thebes \
|
||||
intl \
|
||||
imglib2 \
|
||||
layout \
|
||||
locale \
|
||||
unicharutil \
|
||||
uriloader \
|
||||
webbrwsr \
|
||||
shistory \
|
||||
composer \
|
||||
editor \
|
||||
embed_base \
|
||||
windowwatcher \
|
||||
webshell \
|
||||
pipnss \
|
||||
history \
|
||||
pref \
|
||||
nspr \
|
||||
profdirserviceprovider \
|
||||
xulapp \
|
||||
exthandler \
|
||||
mimetype \
|
||||
chardet \
|
||||
find \
|
||||
webbrowserpersist \
|
||||
cookie \
|
||||
nkcache \
|
||||
pipboot \
|
||||
$(NULL)
|
||||
|
||||
ifdef ACCESSIBILITY
|
||||
@ -127,43 +79,14 @@ CPPSRCS = \
|
||||
EmbedContentListener.cpp \
|
||||
EmbedEventListener.cpp \
|
||||
EmbedWindowCreator.cpp \
|
||||
EmbedGtkTools.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
CPPSRCS += \
|
||||
gtkmozembed_common.cpp \
|
||||
gtkmozembed_download.cpp \
|
||||
EmbedContextMenuInfo.cpp \
|
||||
EmbedCertificates.cpp \
|
||||
EmbedDownloadMgr.cpp \
|
||||
EmbedGlobalHistory.cpp \
|
||||
EmbedFilePicker.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_GTKPASSWORD_INTERFACE
|
||||
CPPSRCS += \
|
||||
EmbedPasswordMgr.cpp \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS += \
|
||||
nsIPassword.idl \
|
||||
nsIPasswordInternal.idl \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
CSRCS = \
|
||||
gtkmozembedmarshal.c
|
||||
|
||||
CPPSRCS += \
|
||||
GtkPromptService.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_NO_GECKO_UI_FALLBACK_1_8_COMPAT
|
||||
CPPSRCS += \
|
||||
EmbedPrompter.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
GtkPromptService.cpp
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
@ -171,32 +94,7 @@ include $(topsrcdir)/config/config.mk
|
||||
EXPORTS = \
|
||||
gtkmozembed.h \
|
||||
gtkmozembed_glue.cpp \
|
||||
gtkmozembed_internal.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
EXPORTS += \
|
||||
gtkmozembed_common.h \
|
||||
gtkmozembed_download.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_GTKEMBED_DYN
|
||||
ifneq (,$(filter gtk2 qt,$(MOZ_WIDGET_TOOLKIT)))
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(DIST)/lib/libxpcomglue_s.$(LIB_SUFFIX) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(MOZ_GTK2_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
#Any Idea what can be used instead -lxul in FF configuration?
|
||||
ifndef MOZ_ENABLE_LIBXUL
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
-lxul \
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
gtkmozembed_internal.h
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@ -211,22 +109,8 @@ DEFINES += -D_TIME_H=1
|
||||
endif
|
||||
endif
|
||||
|
||||
CXXFLAGS += $(MOZ_GTK2_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK2_CFLAGS)
|
||||
ifdef MOZ_GNOMEVFS_CFLAGS
|
||||
CXXFLAGS += $(MOZ_GNOMEVFS_CFLAGS)
|
||||
CFLAGS += $(MOZ_GNOMEVFS_CFLAGS)
|
||||
endif
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
|
||||
CFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
|
||||
DEFINES += -D_IMPL_GTKMOZEMBED
|
||||
|
||||
|
||||
MARSHAL_FILE = gtkmozembedmarshal
|
||||
MARSHAL_PREFIX = gtkmozembed
|
||||
|
||||
$(MARSHAL_FILE).h: $(MARSHAL_FILE).list
|
||||
glib-genmarshal --prefix=$(MARSHAL_PREFIX) $(srcdir)/$(MARSHAL_FILE).list --skip-source --header > $(MARSHAL_FILE).h
|
||||
|
||||
$(MARSHAL_FILE).c: $(MARSHAL_FILE).list $(MARSHAL_FILE).h
|
||||
glib-genmarshal --prefix=$(MARSHAL_PREFIX) $(srcdir)/$(MARSHAL_FILE).list --skip-source --body > $(MARSHAL_FILE).c
|
||||
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,15 +14,13 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
* Ramiro Estrugo <ramiro@eazel.com>
|
||||
* Oleg Romashin <romaxa@gmail.com>
|
||||
* Antonio Gomes <tonikitoo@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -49,11 +45,10 @@ extern "C" {
|
||||
|
||||
#include <stddef.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#include "nscore.h"
|
||||
#else /* MOZILLA_CLIENT */
|
||||
#else // MOZILLA_CLIENT
|
||||
#ifndef nscore_h__
|
||||
/* Because this header may be included from files which not part of the mozilla
|
||||
build system, define macros from nscore.h */
|
||||
@ -67,8 +62,8 @@ extern "C" {
|
||||
#define NS_FROZENCALL
|
||||
#define NS_EXPORT_(type) type
|
||||
#define NS_IMPORT_(type) type
|
||||
#endif /* nscore_h__ */
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
#endif // nscore_h__
|
||||
#endif // MOZILLA_CLIENT
|
||||
|
||||
#ifdef XPCOM_GLUE
|
||||
|
||||
@ -76,7 +71,7 @@ extern "C" {
|
||||
typedef type (NS_FROZENCALL * name##Type) params; \
|
||||
extern name##Type name NS_HIDDEN;
|
||||
|
||||
#else /* XPCOM_GLUE */
|
||||
#else // XPCOM_GLUE
|
||||
|
||||
#ifdef _IMPL_GTKMOZEMBED
|
||||
#define GTKMOZEMBED_API(type, name, params) NS_EXPORT_(type) name params;
|
||||
@ -84,20 +79,7 @@ extern "C" {
|
||||
#define GTKMOZEMBED_API(type,name, params) NS_IMPORT_(type) name params;
|
||||
#endif
|
||||
|
||||
#endif /* XPCOM_GLUE */
|
||||
|
||||
/** @struct GtkWebHistoryItem.
|
||||
* Defines a web history item.
|
||||
*/
|
||||
typedef struct _GtkMozHistoryItem GtkMozHistoryItem;
|
||||
struct _GtkMozHistoryItem
|
||||
{
|
||||
const gchar *title; /** < URL title */
|
||||
const gchar *url; /** < URL */
|
||||
long accessed; /** < The last time that the URL was accessed */
|
||||
};
|
||||
|
||||
#include "gtkmozembed_common.h"
|
||||
#endif // XPCOM_GLUE
|
||||
|
||||
#define GTK_TYPE_MOZ_EMBED (gtk_moz_embed_get_type())
|
||||
#define GTK_MOZ_EMBED(obj) GTK_CHECK_CAST((obj), GTK_TYPE_MOZ_EMBED, GtkMozEmbed)
|
||||
@ -110,16 +92,8 @@ typedef struct _GtkMozEmbedClass GtkMozEmbedClass;
|
||||
|
||||
struct _GtkMozEmbed
|
||||
{
|
||||
GtkBin bin;
|
||||
void *data;
|
||||
GtkObject *common;
|
||||
/* FIXME: This is a temporary solution for incorrect progress values
|
||||
* being passed up. Oleg has mentioned something about a bug in JS.
|
||||
*/
|
||||
gint current_number_of_requests;
|
||||
gint total_number_of_requests;
|
||||
gint number_of_frames_loaded;
|
||||
|
||||
GtkBin bin;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct _GtkMozEmbedClass
|
||||
@ -132,10 +106,10 @@ struct _GtkMozEmbedClass
|
||||
void (* title) (GtkMozEmbed *embed);
|
||||
void (* progress) (GtkMozEmbed *embed, gint curprogress,
|
||||
gint maxprogress);
|
||||
void (* progress_all) (GtkMozEmbed *embed, const gchar *aURI,
|
||||
void (* progress_all) (GtkMozEmbed *embed, const char *aURI,
|
||||
gint curprogress, gint maxprogress);
|
||||
void (* net_state) (GtkMozEmbed *embed, gint state, guint status);
|
||||
void (* net_state_all) (GtkMozEmbed *embed, const gchar *aURI,
|
||||
void (* net_state_all) (GtkMozEmbed *embed, const char *aURI,
|
||||
gint state, guint status);
|
||||
void (* net_start) (GtkMozEmbed *embed);
|
||||
void (* net_stop) (GtkMozEmbed *embed);
|
||||
@ -154,11 +128,6 @@ struct _GtkMozEmbedClass
|
||||
gint (* dom_mouse_dbl_click) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_mouse_over) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_mouse_out) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
/* gint (* dom_mouse_move) (GtkMozEmbed *embed, gpointer dom_event); */
|
||||
gint (* dom_mouse_scroll) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_mouse_long_press)(GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_focus) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_blur) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
void (* security_change) (GtkMozEmbed *embed, gpointer request,
|
||||
guint state);
|
||||
void (* status_change) (GtkMozEmbed *embed, gpointer request,
|
||||
@ -166,124 +135,49 @@ struct _GtkMozEmbedClass
|
||||
gint (* dom_activate) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_focus_in) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
gint (* dom_focus_out) (GtkMozEmbed *embed, gpointer dom_event);
|
||||
void (* alert) (GtkMozEmbed *embed, const char *title, const char *text);
|
||||
void (* alert_check) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
const char *check_msg, gboolean *check_val);
|
||||
gboolean (* confirm) (GtkMozEmbed *embed, const char *title, const char *text);
|
||||
gboolean (* confirm_check) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
const char *check_msg, gboolean *check_val);
|
||||
gint (* confirm_ex) (GtkMozEmbed *embed, const char *title, const char *text, guint bt_flags,
|
||||
const char *button1, const char *button2, const char *button3,
|
||||
const char *check_msg, gboolean *check_val);
|
||||
gboolean (* prompt) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
char **value, const char *check_msg, gboolean *check_val);
|
||||
gboolean (* prompt_auth) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
char **user, char **pass, const char *check_msg, gboolean *check_val);
|
||||
gboolean (* select) (GtkMozEmbed *embed, const char *title, const char *text,
|
||||
GList *list, gint *selected_item);
|
||||
void (* download_request)(GtkMozEmbed *, const char *, const char *, const char *, long, int, gpointer);
|
||||
gboolean (* upload_dialog) (GtkMozEmbed *, const char *, const char *, char **);
|
||||
void (* icon_changed) (GtkMozEmbed *, gpointer*);
|
||||
void (* mailto) (GtkMozEmbed *, gchar *);
|
||||
void (* network_error) (GtkMozEmbed *, gchar *, const gint, const gchar **);
|
||||
void (* rss_request) (GtkMozEmbed *, gchar *, gchar *);
|
||||
};
|
||||
|
||||
GTKMOZEMBED_API(GtkType, gtk_moz_embed_get_type, (void))
|
||||
GTKMOZEMBED_API(GtkWidget*, gtk_moz_embed_new, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_push_startup, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_pop_startup, (void))
|
||||
GTKMOZEMBED_API(GtkType, gtk_moz_embed_get_type, (void))
|
||||
GTKMOZEMBED_API(GtkWidget*, gtk_moz_embed_new, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_push_startup, (void))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_pop_startup, (void))
|
||||
|
||||
/* Tell gtkmozembed where the gtkmozembed libs live. If this is not specified,
|
||||
The MOZILLA_FIVE_HOME environment variable is checked. */
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_path, (const char *aPath))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_comp_path, (const char *aPath))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_profile_path, (const char *aDir, const char *aName))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_load_url, (GtkMozEmbed *embed, const char *url))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_stop_load, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_back, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_forward, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_go_back, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_go_forward, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_render_data, (GtkMozEmbed *embed, const char *data, guint32 len,
|
||||
const char *base_uri, const char *mime_type))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_open_stream, (GtkMozEmbed *embed,
|
||||
const char *base_uri, const char *mime_type))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_append_data, (GtkMozEmbed *embed,
|
||||
const char *data, guint32 len))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_close_stream, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gchar*, gtk_moz_embed_get_link_message, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gchar*, gtk_moz_embed_get_js_status, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gchar*, gtk_moz_embed_get_title, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gchar*, gtk_moz_embed_get_location, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_reload, (GtkMozEmbed *embed, gint32 flags))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_chrome_mask, (GtkMozEmbed *embed, guint32 flags))
|
||||
GTKMOZEMBED_API(guint32, gtk_moz_embed_get_chrome_mask, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_get_zoom_level, (GtkMozEmbed *embed, gint*, gpointer))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_set_zoom_level, (GtkMozEmbed *embed, gint, gpointer))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_find_text, (GtkMozEmbed *embed, const gchar*, gboolean, gboolean, gboolean, gboolean, gint))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_clipboard, (GtkMozEmbed *embed, guint, gint))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_notify_plugins, (GtkMozEmbed *embed, guint))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_check_logins, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_encoding, (GtkMozEmbed *embed, gint))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_encoding, (GtkMozEmbed *embed, const gchar *, gint))
|
||||
GTKMOZEMBED_API(guint, gtk_moz_embed_get_context_info, (GtkMozEmbed *embed, gpointer event, gpointer *node,
|
||||
gint *x, gint *y, gint *docindex,
|
||||
const gchar **url, const gchar **objurl, const gchar **docurl))
|
||||
GTKMOZEMBED_API(const gchar*, gtk_moz_embed_get_selection, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_get_doc_info, (GtkMozEmbed *embed, gpointer node, gint docindex, const gchar**title,
|
||||
const gchar**location, const gchar **file_type, guint *file_size,
|
||||
gint *width, gint *height))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_insert_text, (GtkMozEmbed *embed, const gchar*, gpointer node))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_save_target, (GtkMozEmbed *embed, gchar*, gchar*, gint))
|
||||
GTKMOZEMBED_API(gint, gtk_moz_embed_get_shistory_list, (GtkMozEmbed *embed, GtkMozHistoryItem **GtkHI, guint type))
|
||||
GTKMOZEMBED_API(gint, gtk_moz_embed_get_shistory_index, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_shistory_goto_index, (GtkMozEmbed *embed, gint index))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_get_server_cert, (GtkMozEmbed *embed, gpointer *aCert, gpointer))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_path, (const char *aPath))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_BACK_SHISTORY,
|
||||
GTK_MOZ_EMBED_FORWARD_SHISTORY
|
||||
} GtkMozEmbedSessionHistory;
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_comp_path, (const char *aPath))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_profile_path, (const char *aDir,
|
||||
const char *aName))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_load_url, (GtkMozEmbed *embed,
|
||||
const char *url))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_stop_load, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_back, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_forward, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_go_back, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_go_forward, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_render_data, (GtkMozEmbed *embed,
|
||||
const char *data,
|
||||
guint32 len,
|
||||
const char *base_uri,
|
||||
const char *mime_type))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_open_stream, (GtkMozEmbed *embed,
|
||||
const char *base_uri,
|
||||
const char *mime_type))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_append_data, (GtkMozEmbed *embed,
|
||||
const char *data,
|
||||
guint32 len))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_close_stream, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_link_message, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_js_status, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_title, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(char*, gtk_moz_embed_get_location, (GtkMozEmbed *embed))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_reload, (GtkMozEmbed *embed,
|
||||
gint32 flags))
|
||||
GTKMOZEMBED_API(void, gtk_moz_embed_set_chrome_mask, (GtkMozEmbed *embed,
|
||||
guint32 flags))
|
||||
GTKMOZEMBED_API(guint32, gtk_moz_embed_get_chrome_mask, (GtkMozEmbed *embed))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_SELECT_ALL,
|
||||
GTK_MOZ_EMBED_CAN_SELECT,
|
||||
GTK_MOZ_EMBED_CUT,
|
||||
GTK_MOZ_EMBED_COPY,
|
||||
GTK_MOZ_EMBED_PASTE,
|
||||
GTK_MOZ_EMBED_CAN_CUT,
|
||||
GTK_MOZ_EMBED_CAN_PASTE,
|
||||
GTK_MOZ_EMBED_CAN_COPY
|
||||
} GtkMozEmbedClipboard;
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_CTX_NONE = 0,
|
||||
GTK_MOZ_EMBED_CTX_XUL = 1 << 1,
|
||||
GTK_MOZ_EMBED_CTX_SIDEBAR = 1 << 2,
|
||||
GTK_MOZ_EMBED_CTX_DOCUMENT = 1 << 3,
|
||||
GTK_MOZ_EMBED_CTX_LINK = 1 << 4,
|
||||
GTK_MOZ_EMBED_CTX_IMAGE = 1 << 5,
|
||||
GTK_MOZ_EMBED_CTX_IFRAME = 1 << 6,
|
||||
GTK_MOZ_EMBED_CTX_INPUT = 1 << 7,
|
||||
GTK_MOZ_EMBED_CTX_IPASSWORD = 1 << 8,
|
||||
GTK_MOZ_EMBED_CTX_EMAIL = 1 << 9,
|
||||
GTK_MOZ_EMBED_CTX_RICHEDIT = 1 << 10,
|
||||
GTK_MOZ_EMBED_CTX_ROINPUT = 1 << 11
|
||||
} GtkMozEmbedContext;
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_OK,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_CANCEL,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_YES,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_NO,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_SAVE,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_DONT_SAVE,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_REVERT,
|
||||
GTK_MOZ_EMBED_DIALOG_BUTTON_STRING
|
||||
} GtkMozEmbedDialogButtons;
|
||||
/* These are straight out of nsIWebProgressListener.h */
|
||||
|
||||
typedef enum
|
||||
@ -293,7 +187,7 @@ typedef enum
|
||||
GTK_MOZ_EMBED_FLAG_TRANSFERRING = 4,
|
||||
GTK_MOZ_EMBED_FLAG_NEGOTIATING = 8,
|
||||
GTK_MOZ_EMBED_FLAG_STOP = 16,
|
||||
|
||||
|
||||
GTK_MOZ_EMBED_FLAG_IS_REQUEST = 65536,
|
||||
GTK_MOZ_EMBED_FLAG_IS_DOCUMENT = 131072,
|
||||
GTK_MOZ_EMBED_FLAG_IS_NETWORK = 262144,
|
||||
@ -313,16 +207,14 @@ typedef enum
|
||||
/* NS_ERROR_NET_TIMEOUT */
|
||||
GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT = 2152398862U,
|
||||
/* NS_BINDING_ABORTED */
|
||||
GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED = 2152398850U,
|
||||
/* NS_ERROR_PROXY_CONNECTION_REFUSED */
|
||||
GTK_MOZ_EMBED_STATUS_PROXY_FAILED = 2152398920U
|
||||
GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED = 2152398850U
|
||||
} GtkMozEmbedStatusFlags;
|
||||
|
||||
/* These used to be straight out of nsIWebNavigation.h until the API
|
||||
changed. Now there's a mapping table that maps these values to the
|
||||
internal values. */
|
||||
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
GTK_MOZ_EMBED_FLAG_RELOADNORMAL = 0,
|
||||
GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE = 1,
|
||||
@ -354,7 +246,7 @@ typedef enum
|
||||
GTK_MOZ_EMBED_FLAG_DEPENDENT = 268435456U,
|
||||
GTK_MOZ_EMBED_FLAG_MODAL = 536870912U,
|
||||
GTK_MOZ_EMBED_FLAG_OPENASDIALOG = 1073741824U,
|
||||
GTK_MOZ_EMBED_FLAG_OPENASCHROME = 2147483648U
|
||||
GTK_MOZ_EMBED_FLAG_OPENASCHROME = 2147483648U
|
||||
} GtkMozEmbedChromeFlags;
|
||||
|
||||
/* this is a singleton object that you can hook up to to get signals
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -42,42 +40,12 @@
|
||||
// XPCOMGlueStartup to glue the gtkmozembed functions.
|
||||
|
||||
#include "gtkmozembed.h"
|
||||
#include "gtkmozembed_internal.h"
|
||||
#include "gtkmozembed_common.h"
|
||||
#include "gtkmozembed_download.h"
|
||||
#include "nsXPCOMGlue.h"
|
||||
|
||||
#ifndef XPCOM_GLUE
|
||||
#error This file only makes sense when XPCOM_GLUE is defined.
|
||||
#endif
|
||||
|
||||
#define GTKMOZEMBED2_FUNCTIONS \
|
||||
GTKF(gtk_moz_embed_download_get_type) \
|
||||
GTKF(gtk_moz_embed_download_new) \
|
||||
GTKF(gtk_moz_embed_common_get_type) \
|
||||
GTKF(gtk_moz_embed_common_new) \
|
||||
GTKF(gtk_moz_embed_common_set_pref) \
|
||||
GTKF(gtk_moz_embed_common_get_pref) \
|
||||
GTKF(gtk_moz_embed_common_save_prefs) \
|
||||
GTKF(gtk_moz_embed_common_remove_passwords) \
|
||||
GTKF(gtk_moz_embed_common_get_history_list) \
|
||||
GTKF(gtk_moz_embed_get_zoom_level) \
|
||||
GTKF(gtk_moz_embed_set_zoom_level) \
|
||||
GTKF(gtk_moz_embed_find_text) \
|
||||
GTKF(gtk_moz_embed_clipboard) \
|
||||
GTKF(gtk_moz_embed_notify_plugins) \
|
||||
GTKF(gtk_moz_embed_get_context_info) \
|
||||
GTKF(gtk_moz_embed_get_selection) \
|
||||
GTKF(gtk_moz_embed_get_doc_info) \
|
||||
GTKF(gtk_moz_embed_insert_text) \
|
||||
GTKF(gtk_moz_embed_common_nsx509_to_raw) \
|
||||
GTKF(gtk_moz_embed_common_observe) \
|
||||
GTKF(gtk_moz_embed_get_shistory_list) \
|
||||
GTKF(gtk_moz_embed_get_shistory_index) \
|
||||
GTKF(gtk_moz_embed_shistory_goto_index) \
|
||||
GTKF(gtk_moz_embed_get_server_cert) \
|
||||
GTKF(gtk_moz_embed_get_nsIWebBrowser)
|
||||
|
||||
#define GTKMOZEMBED_FUNCTIONS \
|
||||
GTKF(gtk_moz_embed_get_type) \
|
||||
GTKF(gtk_moz_embed_new) \
|
||||
@ -104,9 +72,7 @@
|
||||
GTKF(gtk_moz_embed_set_chrome_mask) \
|
||||
GTKF(gtk_moz_embed_get_chrome_mask) \
|
||||
GTKF(gtk_moz_embed_single_get_type) \
|
||||
GTKF(gtk_moz_embed_single_get) \
|
||||
GTKF(gtk_moz_embed_set_directory_service_provider) \
|
||||
GTKMOZEMBED2_FUNCTIONS
|
||||
GTKF(gtk_moz_embed_single_get)
|
||||
|
||||
#define GTKF(fname) fname##Type fname;
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -40,9 +38,8 @@
|
||||
#ifndef gtkmozembed_internal_h
|
||||
#define gtkmozembed_internal_h
|
||||
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include <stdlib.h>
|
||||
#include <nsIWebBrowser.h>
|
||||
#include <nsXPCOM.h>
|
||||
|
||||
struct nsModuleComponentInfo;
|
||||
|
||||
@ -53,7 +50,6 @@ extern "C" {
|
||||
GTKMOZEMBED_API(void,
|
||||
gtk_moz_embed_get_nsIWebBrowser, (GtkMozEmbed *embed,
|
||||
nsIWebBrowser **retval))
|
||||
|
||||
GTKMOZEMBED_API(PRUnichar*,
|
||||
gtk_moz_embed_get_title_unichar, (GtkMozEmbed *embed))
|
||||
|
||||
@ -73,4 +69,6 @@ GTKMOZEMBED_API(void,
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* gtkmozembed_internal_h */
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -16,7 +14,7 @@
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christopher Blizzard.
|
||||
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
@ -78,70 +76,16 @@ enum {
|
||||
DOM_ACTIVATE,
|
||||
DOM_FOCUS_IN,
|
||||
DOM_FOCUS_OUT,
|
||||
ALERT,
|
||||
ALERT_CHECK,
|
||||
CONFIRM,
|
||||
CONFIRM_CHECK,
|
||||
CONFIRM_EX,
|
||||
PROMPT,
|
||||
PROMPT_AUTH,
|
||||
SELECT,
|
||||
DOWNLOAD_REQUEST,
|
||||
DOM_MOUSE_SCROLL,
|
||||
DOM_MOUSE_LONG_PRESS,
|
||||
DOM_FOCUS,
|
||||
DOM_BLUR,
|
||||
UPLOAD_DIALOG,
|
||||
ICON_CHANGED,
|
||||
MAILTO,
|
||||
NETWORK_ERROR,
|
||||
RSS_REQUEST,
|
||||
EMBED_LAST_SIGNAL
|
||||
};
|
||||
|
||||
// DOM_MOUSE_MOVE,
|
||||
extern guint moz_embed_signals[EMBED_LAST_SIGNAL];
|
||||
|
||||
#if 0
|
||||
enum {
|
||||
COMMON_CERT_DIALOG,
|
||||
COMMON_CERT_PASSWD_DIALOG,
|
||||
COMMON_CERT_DETAILS_DIALOG,
|
||||
COMMON_HISTORY_ADDED,
|
||||
COMMON_ON_SUBMIT_SIGNAL,
|
||||
COMMON_SELECT_MATCH_SIGNAL,
|
||||
COMMON_MODAL_DIALOG,
|
||||
COMMON_LAST_SIGNAL
|
||||
};
|
||||
#endif
|
||||
|
||||
enum {
|
||||
COMMON_CERT_ERROR,
|
||||
COMMON_SELECT_LOGIN,
|
||||
COMMON_REMEMBER_LOGIN,
|
||||
COMMON_ASK_COOKIE,
|
||||
COMMON_LAST_SIGNAL
|
||||
};
|
||||
|
||||
extern guint moz_embed_common_signals[COMMON_LAST_SIGNAL];
|
||||
|
||||
enum
|
||||
{
|
||||
DOWNLOAD_STARTED_SIGNAL,
|
||||
DOWNLOAD_STOPPED_SIGNAL,
|
||||
DOWNLOAD_COMPLETED_SIGNAL,
|
||||
DOWNLOAD_FAILED_SIGNAL,
|
||||
DOWNLOAD_DESTROYED_SIGNAL,
|
||||
DOWNLOAD_PROGRESS_SIGNAL,
|
||||
DOWNLOAD_LAST_SIGNAL
|
||||
};
|
||||
|
||||
extern guint moz_embed_download_signals[DOWNLOAD_LAST_SIGNAL];
|
||||
extern void gtk_moz_embed_single_create_window(GtkMozEmbed **aNewEmbed,
|
||||
guint aChromeFlags);
|
||||
guint aChromeFlags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* gtkmozembedprivate_h */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user