20829N/A+# ***** BEGIN LICENSE BLOCK *****
20829N/A+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+# The contents of this file are subject to the Mozilla Public License Version
20829N/A+# 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+# the License. You may obtain a copy of the License at
20829N/A+# Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+# for the specific language governing rights and limitations under the
20829N/A+# The Original Code is the Mozilla browser.
20829N/A+# The Initial Developer of the Original Code is
20829N/A+# Portions created by the Initial Developer are Copyright (C) 1999
20829N/A+# the Initial Developer. All Rights Reserved.
20829N/A+# Christopher Blizzard <blizzard@mozilla.org>
20829N/A+# Alternatively, the contents of this file may be used under the terms of
20829N/A+# either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+# in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+# of those above. If you wish to allow use of your version of this file only
20829N/A+# under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+# use your version of this file under the terms of the MPL, indicate your
20829N/A+# decision by deleting the provisions above and replace them with the notice
20829N/A+# and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+# the provisions above, a recipient may use your version of this file under
20829N/A+# the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+# ***** END LICENSE BLOCK *****
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Terry Hayes <thayes@netscape.com>
20829N/A+ * Javier Delgadillo <javi@netscape.com>
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+EmbedCertificates::EmbedCertificates(void)
20829N/A+EmbedCertificates::~EmbedCertificates()
20829N/A+NS_IMPL_THREADSAFE_ADDREF(EmbedCertificates)
20829N/A+NS_IMPL_THREADSAFE_RELEASE(EmbedCertificates)
20829N/A+NS_INTERFACE_MAP_BEGIN(EmbedCertificates)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsITokenPasswordDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsICertificateDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsIClientAuthDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsICertPickDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsITokenDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsIGeneratingKeypairInfoDialogs)
20829N/A+NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMCryptoDialogs)
20829N/A+ nsCOMPtr<nsIStringBundleService> service =
20829N/A+ do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
20829N/A+ if (NS_FAILED(rv)) return NS_OK;
20829N/A+ rv = service->CreateBundle(PIPSTRING_BUNDLE_URL,
20829N/A+ getter_AddRefs(mPIPStringBundle));
20829N/A+EmbedCertificates::SetPassword(nsIInterfaceRequestor *ctx,
20829N/A+ const PRUnichar *tokenName, PRBool* _canceled)
20829N/A+EmbedCertificates::GetPassword(nsIInterfaceRequestor *ctx,
20829N/A+EmbedCertificates::CrlImportStatusDialog(nsIInterfaceRequestor *ctx, nsICRLInfo *crl)
20829N/A+EmbedCertificates::ConfirmDownloadCACert(nsIInterfaceRequestor *ctx,
20829N/A+ // If an implementation chooses not to implement UI for displaying
20829N/A+ // the cert and asking the user for confirmation,
20829N/A+ // then this function must return PR_FALSE.
20829N/A+ *_trust = nsIX509CertDB::UNTRUSTED;
20829N/A+EmbedCertificates::NotifyCACertExists(nsIInterfaceRequestor *ctx)
20829N/A+EmbedCertificates::ChooseCertificate(
20829N/A+ const PRUnichar *organization,
20829N/A+ const PRUnichar **certNickList,
20829N/A+ const PRUnichar **certDetailsList,
20829N/A+EmbedCertificates::PickCertificate(
20829N/A+ const PRUnichar **certNickList,
20829N/A+ const PRUnichar **certDetailsList,
20829N/A+EmbedCertificates::SetPKCS12FilePassword(
20829N/A+ /* The person who wrote this method implementation did
20829N/A+EmbedCertificates::GetPKCS12FilePassword(
20829N/A+ /* The person who wrote this method implementation did
20829N/A+/* void viewCert (in nsIX509Cert cert); */
20829N/A+EmbedCertificates::DisplayGeneratingKeypairInfo(nsIInterfaceRequestor *aCtx, nsIKeygenThread *runnable)
20829N/A+EmbedCertificates::ChooseToken(
20829N/A+EmbedCertificates::DisplayProtectedAuth(
20829N/A+ nsIProtectedAuthThread *runnable)
20829N/A+/* boolean ConfirmKeyEscrow (in nsIX509Cert escrowAuthority); */
20829N/A+EmbedCertificates::ConfirmKeyEscrow(nsIX509Cert *escrowAuthority, PRBool *_retval)
20829N/A+ // If an implementation chooses not to implement UI that asks the user for
20829N/A+ // confirmation to hand out the private key,
20829N/A+ // then this function must return PR_FALSE.
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Terry Hayes <thayes@netscape.com>
20829N/A+ * Javier Delgadillo <javi@netscape.com>
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+#define EMBED_CERTIFICATES_CID \
20829N/A+ { 0x518e071f, 0x1dd2, 0x11b2, \
20829N/A+ { 0x93, 0x7e, 0xc4, 0x5f, 0x14, 0xde, 0xf7, 0x78 }}
20829N/A+#define EMBED_CERTIFICATES_DESCRIPTION "Certificates Listener Impl"
20829N/A+: public nsITokenPasswordDialogs,
20829N/A+ public nsIGeneratingKeypairInfoDialogs
20829N/A+ NS_DECL_NSITOKENPASSWORDDIALOGS
20829N/A+ NS_DECL_NSIGENERATINGKEYPAIRINFODIALOGS
20829N/A+ nsCOMPtr<nsIStringBundle> mPIPStringBundle;
20829N/A+#endif /* __EmbedCertificates_h */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+EmbedContentListener::EmbedContentListener(void)
20829N/A+EmbedContentListener::~EmbedContentListener()
20829N/A+NS_IMPL_ISUPPORTS2(EmbedContentListener,
20829N/A+EmbedContentListener::Init(EmbedPrivate *aOwner)
20829N/A+EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
20829N/A+ rv = aURI->GetSpec(specString);
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[OPEN_URI], 0,
20829N/A+EmbedContentListener::DoContent(const char *aContentType,
20829N/A+ nsIStreamListener **aContentHandler,
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+EmbedContentListener::IsPreferred(const char *aContentType,
20829N/A+ return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
20829N/A+EmbedContentListener::CanHandleContent(const char *aContentType,
20829N/A+ *aDesiredContentType = nsnull;
20829N/A+ nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
20829N/A+ do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
20829N/A+ webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
20829N/A+ *_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
20829N/A+EmbedContentListener::GetLoadCookie(nsISupports **aLoadCookie)
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+EmbedContentListener::SetLoadCookie(nsISupports *aLoadCookie)
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+EmbedContentListener::GetParentContentListener(nsIURIContentListener **aParent)
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+EmbedContentListener::SetParentContentListener(nsIURIContentListener *aParent)
20829N/A+ return NS_ERROR_NOT_IMPLEMENTED;
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+#ifndef __EmbedContentListener_h
20829N/A+#define __EmbedContentListener_h
20829N/A+class EmbedContentListener : public nsIURIContentListener,
20829N/A+ public nsSupportsWeakReference
20829N/A+ virtual ~EmbedContentListener();
20829N/A+ nsresult Init (EmbedPrivate *aOwner);
20829N/A+#endif /* __EmbedContentListener_h */
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2006
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+#if defined(FIXED_BUG347731) || !defined(MOZ_ENABLE_LIBXUL)
20829N/A+//*****************************************************************************
20829N/A+//*****************************************************************************
20829N/A+EmbedContextMenuInfo::EmbedContextMenuInfo(EmbedPrivate *aOwner) : mCtxFrameNum(-1), mEmbedCtxType(0)
20829N/A+ mFormRect = nsIntRect(0,0,0,0);
20829N/A+EmbedContextMenuInfo::~EmbedContextMenuInfo(void)
20829N/A+NS_IMPL_ADDREF(EmbedContextMenuInfo)
20829N/A+NS_IMPL_RELEASE(EmbedContextMenuInfo)
20829N/A+NS_INTERFACE_MAP_BEGIN(EmbedContextMenuInfo)
20829N/A+NS_INTERFACE_MAP_ENTRY(nsISupports)
20829N/A+EmbedContextMenuInfo::SetFrameIndex()
20829N/A+ nsCOMPtr<nsIDOMWindowCollection> frames;
20829N/A+ mCtxDomWindow->GetFrames(getter_AddRefs(frames));
20829N/A+ nsCOMPtr<nsIDOMWindow> currentWindow;
20829N/A+ frames->GetLength(&frameCount);
20829N/A+ for (unsigned int i= 0; i < frameCount; i++) {
20829N/A+ frames->Item(i, getter_AddRefs(currentWindow));
20829N/A+ nsCOMPtr<nsIDOMDocument> currentDoc;
20829N/A+ currentWindow->GetDocument(getter_AddRefs(currentDoc));
20829N/A+ if (currentDoc == mCtxDocument) {
20829N/A+ mCtxDomWindow = currentWindow;
20829N/A+ nsCOMPtr<nsIDOMNSDocument> doc = do_QueryInterface(currentDoc);
20829N/A+EmbedContextMenuInfo::GetFormControlType(nsIDOMEvent* aEvent)
20829N/A+ nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
20829N/A+ nsCOMPtr<nsIDOMEventTarget> target;
20829N/A+ nsevent->GetOriginalTarget(getter_AddRefs(target));
20829N/A+ if (SetFormControlType(target)) {
20829N/A+ nsCOMPtr<nsIDOMNode> eventNode = do_QueryInterface(target);
20829N/A+ nsCOMPtr<nsIDOMDocument> domDoc;
20829N/A+ nsresult rv = eventNode->GetOwnerDocument(getter_AddRefs(domDoc));
20829N/A+ if (!NS_SUCCEEDED(rv) || !domDoc) {
20829N/A+ nsCOMPtr<nsIDocument> doc = do_QueryInterface(mCtxDocument);
20829N/A+ nsIPresShell *presShell = doc->GetShell();
20829N/A+ nsCOMPtr<nsIContent> tgContent = do_QueryInterface(mEventTarget);
20829N/A+#if defined(FIXED_BUG347731) || !defined(MOZ_ENABLE_LIBXUL)
20829N/A+ frame = tgContent->GetDocument() == presShell->GetDocument() ?
20829N/A+ tgContent->GetPrimaryFrame() : nsnull;
20829N/A+ mFormRect = frame->GetScreenRectExternal();
20829N/A+EmbedContextMenuInfo::SetFormControlType(nsIDOMEventTarget *originalTarget)
20829N/A+ nsresult rv = NS_ERROR_FAILURE;
20829N/A+ nsCOMPtr<nsIContent> targetContent = do_QueryInterface(originalTarget);
20829N/A+ if (targetContent && targetContent->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL)) {
20829N/A+ nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(targetContent));
20829N/A+ mCtxFormType = formControl->GetType();
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IPASSWORD;
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ if (mEmbedCtxType & GTK_MOZ_EMBED_CTX_INPUT) {
20829N/A+ if (mCtxFormType == NS_FORM_TEXTAREA) {
20829N/A+ nsCOMPtr<nsIDOMHTMLTextAreaElement> input;
20829N/A+ input = do_QueryInterface(mEventNode, &rv);
20829N/A+ rv = input->GetReadOnly(&rdonly);
20829N/A+ if (!NS_FAILED(rv) && rdonly) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_ROINPUT;
20829N/A+ nsCOMPtr<nsIDOMHTMLInputElement> input;
20829N/A+ input = do_QueryInterface(mEventNode, &rv);
20829N/A+ rv = input->GetReadOnly(&rdonly);
20829N/A+ if (!NS_FAILED(rv) && rdonly) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_ROINPUT;
20829N/A+EmbedContextMenuInfo::GetSelectedText()
20829N/A+ nsresult rv = NS_ERROR_FAILURE;
20829N/A+ if (mCtxFormType != 0 && mEventNode) {
20829N/A+ PRInt32 TextLength = 0, selStart = 0, selEnd = 0;
20829N/A+ if (mCtxFormType == NS_FORM_INPUT_TEXT || mCtxFormType == NS_FORM_INPUT_FILE) {
20829N/A+ nsCOMPtr<nsIDOMHTMLInputElement> nsinput = do_QueryInterface(mEventNode, &rv);
20829N/A+ if (NS_SUCCEEDED(rv) && nsinput)
20829N/A+ nsinput->GetTextLength(&TextLength);
20829N/A+ nsinput->GetSelectionEnd(&selEnd);
20829N/A+ nsinput->GetSelectionStart(&selStart);
20829N/A+ if (selStart < selEnd || mCtxFormType == NS_FORM_INPUT_FILE) {
20829N/A+ nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(mEventNode, &rv);
20829N/A+ rv = input->GetValue(cString);
20829N/A+ } else if (mCtxFormType == NS_FORM_TEXTAREA) {
20829N/A+ nsCOMPtr<nsIDOMNSHTMLTextAreaElement> nsinput = do_QueryInterface(mEventNode, &rv);
20829N/A+ if (NS_SUCCEEDED(rv) && nsinput)
20829N/A+ nsinput->GetTextLength(&TextLength);
20829N/A+ nsinput->GetSelectionStart(&selStart);
20829N/A+ nsinput->GetSelectionEnd(&selEnd);
20829N/A+ nsCOMPtr<nsIDOMHTMLTextAreaElement> input = do_QueryInterface(mEventNode, &rv);
20829N/A+ rv = input->GetValue(cString);
20829N/A+ nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mCtxDocument, &rv);
20829N/A+ if (NS_FAILED(rv) || !htmlDoc)
20829N/A+ rv = htmlDoc->GetSelection(cString);
20829N/A+ return NS_ConvertUTF16toUTF8(cString).get();
20829N/A+EmbedContextMenuInfo::CheckDomImageElement(nsIDOMNode *node, nsString& aHref,
20829N/A+ PRInt32 *aWidth, PRInt32 *aHeight)
20829N/A+ nsresult rv = NS_ERROR_FAILURE;
20829N/A+ nsCOMPtr<nsIDOMHTMLImageElement> image =
20829N/A+ rv = image->GetHeight(aHeight);
20829N/A+EmbedContextMenuInfo::GetImageRequest(imgIRequest **aRequest, nsIDOMNode *aDOMNode)
20829N/A+ NS_ENSURE_ARG_POINTER(aRequest);
20829N/A+ nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(aDOMNode));
20829N/A+ NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
20829N/A+ return content->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
20829N/A+EmbedContextMenuInfo::CheckDomHtmlNode(nsIDOMNode *aNode)
20829N/A+ nsresult rv = NS_ERROR_FAILURE;
20829N/A+ nsCOMPtr<nsIDOMHTMLElement> element = do_QueryInterface(node, &rv);
20829N/A+ element = do_QueryInterface(mOrigNode, &rv);
20829N/A+ element = do_QueryInterface(node, &rv);
20829N/A+ rv = node->GetNodeType(&dnode_type);
20829N/A+ if (!((nsIDOMNode::ELEMENT_NODE == dnode_type) && element)) {
20829N/A+ nsCOMPtr<nsIDOMNSHTMLElement> nodeElement = do_QueryInterface(node, &rv);
20829N/A+ if (NS_SUCCEEDED(rv) && nodeElement) {
20829N/A+ mNSHHTMLElement = nodeElement;
20829N/A+ rv = element->GetLocalName(uTag);
20829N/A+ nsCOMPtr<nsIDOMHTMLAnchorElement> anchor = do_QueryInterface(node);
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_LINK;
20829N/A+ nsCOMPtr<nsIDOMNode> childNode;
20829N/A+ node->GetFirstChild(getter_AddRefs(childNode));
20829N/A+ rv = CheckDomImageElement(node, mCtxImgHref, &width, &height);
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IMAGE;
20829N/A+ } else if (StringBeginsWith(mCtxHref, NS_LITERAL_STRING("mailto:"))) {
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_EMAIL;
20829N/A+ nsCOMPtr<nsIDOMHTMLAreaElement> area = do_QueryInterface(node, &rv);
20829N/A+ if (NS_SUCCEEDED(rv) && area) {
20829N/A+ rv = area->GetNoHref(&aNoHref);
20829N/A+ rv = area->GetTarget(mCtxHref);
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_LINK;
20829N/A+ rv = CheckDomImageElement(node, mCtxImgHref, &width, &height);
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IMAGE;
20829N/A+EmbedContextMenuInfo::UpdateContextData(void *aEvent)
20829N/A+ NS_ENSURE_ARG_POINTER(aEvent);
20829N/A+ nsCOMPtr<nsIDOMEvent> event = do_QueryInterface((nsISupports*)aEvent, &rv);
20829N/A+ return UpdateContextData(event);
20829N/A+EmbedContextMenuInfo::GetElementForScroll(nsIDOMEvent *aEvent)
20829N/A+ if (!aEvent) return NS_ERROR_UNEXPECTED;
20829N/A+ nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aEvent));
20829N/A+ nsCOMPtr<nsIDOMEventTarget> target;
20829N/A+ nsevent->GetOriginalTarget(getter_AddRefs(target));
20829N/A+ if (!target) return NS_ERROR_UNEXPECTED;
20829N/A+ nsCOMPtr<nsIDOMNode> targetDOMNode(do_QueryInterface(target));
20829N/A+ if (!targetDOMNode) return NS_ERROR_UNEXPECTED;
20829N/A+ nsCOMPtr<nsIDOMDocument> targetDOMDocument;
20829N/A+ targetDOMNode->GetOwnerDocument(getter_AddRefs(targetDOMDocument));
20829N/A+ if (!targetDOMDocument) return NS_ERROR_UNEXPECTED;
20829N/A+ return GetElementForScroll(targetDOMDocument);
20829N/A+EmbedContextMenuInfo::GetElementForScroll(nsIDOMDocument *targetDOMDocument)
20829N/A+ nsCOMPtr<nsIDOMElement> targetDOMElement;
20829N/A+ targetDOMDocument->GetDocumentElement(getter_AddRefs(targetDOMElement));
20829N/A+ if (!targetDOMElement) return NS_ERROR_UNEXPECTED;
20829N/A+ nsString bodyName(NS_LITERAL_STRING("body"));
20829N/A+ nsCOMPtr<nsIDOMNodeList> bodyList;
20829N/A+ targetDOMElement->GetElementsByTagName(bodyName, getter_AddRefs(bodyList));
20829N/A+ nsCOMPtr<nsIDOMNode> domBodyNode;
20829N/A+ bodyList->Item(0, getter_AddRefs(domBodyNode));
20829N/A+ if (!domBodyNode) return NS_ERROR_UNEXPECTED;
20829N/A+ mNSHHTMLElementSc = do_QueryInterface(domBodyNode);
20829N/A+ if (!mNSHHTMLElementSc) return NS_ERROR_UNEXPECTED;
20829N/A+EmbedContextMenuInfo::UpdateContextData(nsIDOMEvent *aDOMEvent)
20829N/A+ NS_ENSURE_ARG_POINTER(mCtxEvent);
20829N/A+ mCtxEvent->GetEventPhase(&eventphase);
20829N/A+ nsCOMPtr<nsIDOMEventTarget> originalTarget = nsnull;
20829N/A+ nsCOMPtr<nsIDOMNode> originalNode = nsnull;
20829N/A+ nsCOMPtr<nsIDOMNSEvent> aEvent = do_QueryInterface(mCtxEvent, &rv);
20829N/A+ nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(mCtxEvent, &rv));
20829N/A+ ((nsIDOMMouseEvent*)mouseEvent)->GetClientX(&mX);
20829N/A+ ((nsIDOMMouseEvent*)mouseEvent)->GetClientY(&mY);
20829N/A+ rv = aEvent->GetOriginalTarget(getter_AddRefs(originalTarget));
20829N/A+ originalNode = do_QueryInterface(originalTarget);
20829N/A+ if (NS_FAILED(rv) || !originalNode)
20829N/A+ // nsresult SelText = mOwner->ClipBoardAction(GTK_MOZ_EMBED_CAN_COPY);
20829N/A+ if (originalNode == mOrigNode)
20829N/A+ mEmbedCtxType = GTK_MOZ_EMBED_CTX_NONE;
20829N/A+ mOrigNode->GetNodeName(SOrigNode);
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_XUL;
20829N/A+ rv = mCtxEvent->GetTarget(getter_AddRefs(mEventTarget));
20829N/A+ if (NS_FAILED(rv) || !mEventTarget) {
20829N/A+ nsCOMPtr<nsIDOMNode> eventNode = do_QueryInterface(mEventTarget, &rv);
20829N/A+ nsCOMPtr<nsIDOMDocument> domDoc;
20829N/A+ rv = mEventNode->GetOwnerDocument(getter_AddRefs(domDoc));
20829N/A+ if (!NS_SUCCEEDED(rv) || !domDoc) {
20829N/A+ if (NS_SUCCEEDED(rv) && domDoc && mCtxDocument != domDoc) {
20829N/A+ mCtxDocument->GetDocumentURI(mCtxURI);
20829N/A+ NS_ENSURE_ARG_POINTER(mOwner);
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mOwner->mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ webBrowser->GetContentDOMWindow(getter_AddRefs(mCtxDomWindow));
20829N/A+ nsCOMPtr<nsIDOMDocument> mainDocument;
20829N/A+ mCtxDomWindow->GetDocument(getter_AddRefs(mainDocument));
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_IFRAME;
20829N/A+ nsCOMPtr<nsIDOMElement> targetDOMElement;
20829N/A+ mCtxDocument->GetDocumentElement(getter_AddRefs(targetDOMElement));
20829N/A+ if (!targetDOMElement) return NS_ERROR_UNEXPECTED;
20829N/A+ nsCOMPtr<nsIDOMNSHTMLDocument> htmlDoc = do_QueryInterface(mCtxDocument);
20829N/A+ htmlDoc->GetDesignMode(DMode);
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_RICHEDIT;
20829N/A+ nsCOMPtr<nsIDocument> doc = do_QueryInterface(mCtxDocument);
20829N/A+ nsIPresShell *presShell = doc->GetShell();
20829N/A+ nsCOMPtr<nsIContent> tgContent = do_QueryInterface(mEventTarget);
20829N/A+#if defined(FIXED_BUG347731) || !defined(MOZ_ENABLE_LIBXUL)
20829N/A+ if (mEmbedCtxType & GTK_MOZ_EMBED_CTX_RICHEDIT)
20829N/A+ frame = presShell->GetRootFrame();
20829N/A+ else if (tgContent->GetDocument() == presShell->GetDocument()) {
20829N/A+ frame = tgContent->GetPrimaryFrame();
20829N/A+ mFormRect = frame->GetScreenRectExternal();
20829N/A+ if (NS_SUCCEEDED(SetFormControlType(mEventTarget))) {
20829N/A+ nsCOMPtr<nsIDOMNode> node = mEventNode;
20829N/A+ nsCOMPtr<nsIDOMNode> parentNode;
20829N/A+ node->GetParentNode(getter_AddRefs(parentNode));
20829N/A+ if (NS_FAILED(CheckDomHtmlNode()))
20829N/A+ node->GetParentNode(getter_AddRefs(parentNode));
20829N/A+ mEmbedCtxType |= GTK_MOZ_EMBED_CTX_DOCUMENT;
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
20829N/A+ * ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Original Code is the Mozilla browser.
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2006
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+#ifndef EmbedContextMenuInfo_h__
20829N/A+#define EmbedContextMenuInfo_h__
20829N/A+//*****************************************************************************
20829N/A+//*****************************************************************************
20829N/A+class EmbedContextMenuInfo : public nsISupports
20829N/A+ EmbedContextMenuInfo(EmbedPrivate *aOwner);
20829N/A+ virtual ~EmbedContextMenuInfo(void);
20829N/A+ nsresult GetFormControlType(nsIDOMEvent *aDOMEvent);
20829N/A+ nsresult UpdateContextData(nsIDOMEvent *aDOMEvent);
20829N/A+ nsresult UpdateContextData(void *aEvent);
20829N/A+ const char* GetSelectedText();
20829N/A+ nsresult GetElementForScroll(nsIDOMDocument *targetDOMDocument);
20829N/A+ nsresult GetElementForScroll(nsIDOMEvent *aEvent);
20829N/A+ nsresult CheckDomImageElement(nsIDOMNode *node, nsString& aHref,
20829N/A+ PRInt32 *aWidth, PRInt32 *aHeight);
20829N/A+ nsresult GetImageRequest(imgIRequest **aRequest, nsIDOMNode *aDOMNode);
20829N/A+ nsString GetCtxDocTitle(void) { return mCtxDocTitle; }
20829N/A+ PRInt32 mX, mY, mObjWidth, mObjHeight, mCtxFrameNum;
20829N/A+ nsString mCtxURI, mCtxHref, mCtxImgHref;
20829N/A+ nsCOMPtr<nsIDOMNode> mEventNode;
20829N/A+ nsCOMPtr<nsIDOMEventTarget> mEventTarget;
20829N/A+ nsCOMPtr<nsIDOMDocument>mCtxDocument;
20829N/A+ nsCOMPtr<nsIDOMWindow> mCtxDomWindow;
20829N/A+ nsCOMPtr<nsIDOMEvent> mCtxEvent;
20829N/A+ nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElement;
20829N/A+ nsCOMPtr<nsIDOMNSHTMLElement> mNSHHTMLElementSc;
20829N/A+ nsresult SetFormControlType(nsIDOMEventTarget *originalTarget);
20829N/A+ nsresult CheckDomHtmlNode(nsIDOMNode *aNode = nsnull);
20829N/A+ nsCOMPtr<nsIDOMNode> mOrigNode;
20829N/A+}; // class EmbedContextMenuInfo
20829N/A+#endif // EmbedContextMenuInfo_h__
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+EmbedEventListener::EmbedEventListener(void)
20829N/A+EmbedEventListener::~EmbedEventListener()
20829N/A+NS_IMPL_ADDREF(EmbedEventListener)
20829N/A+NS_IMPL_RELEASE(EmbedEventListener)
20829N/A+NS_INTERFACE_MAP_BEGIN(EmbedEventListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMKeyListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMKeyListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIDOMUIListener)
20829N/A+EmbedEventListener::Init(EmbedPrivate *aOwner)
20829N/A+EmbedEventListener::HandleEvent(nsIDOMEvent* aDOMEvent)
20829N/A+EmbedEventListener::KeyDown(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMKeyEvent> keyEvent;
20829N/A+ keyEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return FALSE to this function to mark the event as not
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_KEY_DOWN], 0,
20829N/A+ (void *)keyEvent, &return_val);
20829N/A+EmbedEventListener::KeyUp(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMKeyEvent> keyEvent;
20829N/A+ keyEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // return FALSE to this function to mark this event as not
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_KEY_UP], 0,
20829N/A+ (void *)keyEvent, &return_val);
20829N/A+EmbedEventListener::KeyPress(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMKeyEvent> keyEvent;
20829N/A+ keyEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_KEY_PRESS], 0,
20829N/A+ (void *)keyEvent, &return_val);
20829N/A+EmbedEventListener::MouseDown(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_DOWN], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+EmbedEventListener::MouseUp(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_UP], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+EmbedEventListener::MouseClick(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_CLICK], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+EmbedEventListener::MouseDblClick(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_DBL_CLICK], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+EmbedEventListener::MouseOver(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_OVER], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+EmbedEventListener::MouseOut(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
20829N/A+ mouseEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_MOUSE_OUT], 0,
20829N/A+ (void *)mouseEvent, &return_val);
20829N/A+EmbedEventListener::Activate(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_ACTIVATE], 0,
20829N/A+ (void *)uiEvent, &return_val);
20829N/A+EmbedEventListener::FocusIn(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_FOCUS_IN], 0,
20829N/A+ (void *)uiEvent, &return_val);
20829N/A+EmbedEventListener::FocusOut(nsIDOMEvent* aDOMEvent)
20829N/A+ nsCOMPtr <nsIDOMUIEvent> uiEvent = do_QueryInterface(aDOMEvent);
20829N/A+ // Return TRUE from your signal handler to mark the event as consumed.
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DOM_FOCUS_OUT], 0,
20829N/A+ (void *)uiEvent, &return_val);
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+class EmbedEventListener : public nsIDOMKeyListener,
20829N/A+ virtual ~EmbedEventListener();
20829N/A+ nsresult Init(EmbedPrivate *aOwner);
20829N/A+ NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
20829N/A+ NS_IMETHOD KeyDown(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD KeyUp(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD KeyPress(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseDown(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseUp(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseClick(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseDblClick(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseOver(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD MouseOut(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD Activate(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD FocusIn(nsIDOMEvent* aDOMEvent);
20829N/A+ NS_IMETHOD FocusOut(nsIDOMEvent* aDOMEvent);
20829N/A+#endif /* __EmbedEventListener_h */
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=4 sts=2 tw=80 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2006
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+GtkWidget * GetGtkWidgetForDOMWindow(nsIDOMWindow* aDOMWindow)
20829N/A+ nsCOMPtr<nsIWebBrowserChrome> chrome;
20829N/A+ wwatch->GetChromeForWindow(aDOMWindow, getter_AddRefs(chrome));
20829N/A+ return GTK_WIDGET(EmbedCommon::GetAnyLiveWidget());
20829N/A+ nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow = nsnull;
20829N/A+ siteWindow = do_QueryInterface(chrome);
20829N/A+ return GTK_WIDGET(EmbedCommon::GetAnyLiveWidget());
20829N/A+ siteWindow->GetSiteWindow((void**)&parentWidget);
20829N/A+ if (GTK_IS_WIDGET(parentWidget))
20829N/A+GtkWindow * GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow)
20829N/A+ GtkWidget* parentWidget = GetGtkWidgetForDOMWindow(aDOMWindow);
20829N/A+ GtkWidget* gtkWin = gtk_widget_get_toplevel(parentWidget);
20829N/A+ if (GTK_WIDGET_TOPLEVEL(gtkWin))
20829N/A+nsresult GetContentViewer(nsIWebBrowser *webBrowser, nsIContentViewer **aViewer)
20829N/A+ g_return_val_if_fail(webBrowser, NS_ERROR_FAILURE);
20829N/A+ nsCOMPtr<nsIDocShell> docShell(do_GetInterface((nsISupports*)webBrowser));
20829N/A+ NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
20829N/A+ return docShell->GetContentViewer(aViewer);
20829N/A+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
20829N/A+/* vim:set ts=2 sw=2 sts=2 et cindent: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2006
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Oleg Romashin <romaxa@gmail.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+GetGtkWidgetForDOMWindow(nsIDOMWindow* aDOMWindow);
20829N/A+GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow);
20829N/A+GetContentViewer(nsIWebBrowser *webBrowser, nsIContentViewer **aViewer);
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+// for initializing our window watcher service
20829N/A+// all of the crap that we need for event listeners
20829N/A+// and when chrome windows finish loading
20829N/A+// For seting scrollbar visibilty
20829N/A+PRUint32 EmbedPrivate::sWidgetCount = 0;
20829N/A+char *EmbedPrivate::sPath = nsnull;
20829N/A+char *EmbedPrivate::sCompPath = nsnull;
20829N/A+nsTArray<EmbedPrivate*> *EmbedPrivate::sWindowList = nsnull;
20829N/A+nsILocalFile *EmbedPrivate::sProfileDir = nsnull;
20829N/A+nsISupports *EmbedPrivate::sProfileLock = nsnull;
20829N/A+GtkWidget *EmbedPrivate::sOffscreenWindow = 0;
20829N/A+GtkWidget *EmbedPrivate::sOffscreenFixed = 0;
20829N/A+nsIDirectoryServiceProvider *EmbedPrivate::sAppFileLocProvider = nsnull;
20829N/A+class GTKEmbedDirectoryProvider : public nsIDirectoryServiceProvider2
20829N/A+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER
20829N/A+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
20829N/A+static const GTKEmbedDirectoryProvider kDirectoryProvider;
20829N/A+NS_IMPL_QUERY_INTERFACE2(GTKEmbedDirectoryProvider,
20829N/A+GTKEmbedDirectoryProvider::AddRef()
20829N/A+GTKEmbedDirectoryProvider::Release()
20829N/A+GTKEmbedDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist,
20829N/A+ if (EmbedPrivate::sAppFileLocProvider) {
20829N/A+ nsresult rv = EmbedPrivate::sAppFileLocProvider->GetFile(aKey, aPersist,
20829N/A+ if (EmbedPrivate::sProfileDir && (!strcmp(aKey, NS_APP_USER_PROFILE_50_DIR)
20829N/A+ || !strcmp(aKey, NS_APP_PROFILE_DIR_STARTUP))) {
20829N/A+ return EmbedPrivate::sProfileDir->Clone(aResult);
20829N/A+GTKEmbedDirectoryProvider::GetFiles(const char *aKey,
20829N/A+ nsISimpleEnumerator* *aResult)
20829N/A+ nsCOMPtr<nsIDirectoryServiceProvider2>
20829N/A+ dp2(do_QueryInterface(EmbedPrivate::sAppFileLocProvider));
20829N/A+ return dp2->GetFiles(aKey, aResult);
20829N/A+ {0x95611356, 0xf583, 0x46f5, {0x81, 0xff, 0x4b, 0x3e, 0x01, 0x62, 0xc6, 0x19}}
20829N/A+NS_GENERIC_FACTORY_CONSTRUCTOR(GtkPromptService)
20829N/A+NS_DEFINE_NAMED_CID(NS_PROMPTSERVICE_CID);
20829N/A+static const mozilla::Module::CIDEntry kDefaultPromptCIDs[] = {
20829N/A+ { &kNS_PROMPTSERVICE_CID, false, NULL, GtkPromptServiceConstructor },
20829N/A+static const mozilla::Module::ContractIDEntry kDefaultPromptContracts[] = {
20829N/A+static const mozilla::Module kDefaultPromptModule = {
20829N/A+EmbedPrivate::EmbedPrivate(void)
20829N/A+ mChromeMask = nsIWebBrowserChrome::CHROME_ALL;
20829N/A+ mListenersAttached = PR_FALSE;
20829N/A+ sWindowList = new nsTArray<EmbedPrivate*>();
20829N/A+ sWindowList->AppendElement(this);
20829N/A+ sWindowList->RemoveElement(this);
20829N/A+EmbedPrivate::Init(GtkMozEmbed *aOwningWidget)
20829N/A+ // are we being re-initialized?
20829N/A+ // hang on with a reference to the owning widget
20829N/A+ mOwningWidget = aOwningWidget;
20829N/A+ // Create our embed window, and create an owning reference to it and
20829N/A+ // initialize it. It is assumed that this window will be destroyed
20829N/A+ mWindowGuard = static_cast<nsIWebBrowserChrome *>(mWindow);
20829N/A+ // Create our progress listener object, make an owning reference,
20829N/A+ // and initialize it. It is assumed that this progress listener
20829N/A+ // will be destroyed when we go out of scope.
20829N/A+ mProgress = new EmbedProgress();
20829N/A+ mProgressGuard = static_cast<nsIWebProgressListener *>
20829N/A+ // Create our content listener object, initialize it and attach it.
20829N/A+ // It is assumed that this will be destroyed when we go out of
20829N/A+ mContentListener = new EmbedContentListener();
20829N/A+ mContentListenerGuard = static_cast<nsISupports*>(static_cast<nsIURIContentListener*>(mContentListener));
20829N/A+ // Create our key listener object and initialize it. It is assumed
20829N/A+ // that this will be destroyed before we go out of scope.
20829N/A+ mEventListener = new EmbedEventListener();
20829N/A+ static_cast<nsISupports *>(static_cast<nsIDOMKeyListener *>(mEventListener));
20829N/A+ // has the window creator service been set up?
20829N/A+ static int initialized = PR_FALSE;
20829N/A+ // Set up our window creator ( only once )
20829N/A+ // We set this flag here instead of on success. If it failed we
20829N/A+ // don't want to keep trying and leaking window creator objects.
20829N/A+ EmbedWindowCreator *creator = new EmbedWindowCreator();
20829N/A+ nsCOMPtr<nsIWindowCreator> windowCreator;
20829N/A+ windowCreator = static_cast<nsIWindowCreator *>(creator);
20829N/A+ // Attach it via the watcher service
20829N/A+ nsCOMPtr<nsIWindowWatcher> watcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
20829N/A+ watcher->SetWindowCreator(windowCreator);
20829N/A+EmbedPrivate::Realize(PRBool *aAlreadyRealized)
20829N/A+ // create the offscreen window if we have to
20829N/A+ // Have we ever been initialized before? If so then just reparent
20829N/A+ gtk_widget_reparent(mMozWindowWidget, GTK_WIDGET(mOwningWidget));
20829N/A+ // Get the nsIWebBrowser object for our embedded window.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ // get a handle on the navigation object
20829N/A+ mNavigation = do_QueryInterface(webBrowser);
20829N/A+ // Create our session history object and tell the navigation object
20829N/A+ // to use it. We need to do this before we create the web browser
20829N/A+ mSessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID);
20829N/A+ mNavigation->SetSessionHistory(mSessionHistory);
20829N/A+ // bind the progress listener to the browser object
20829N/A+ nsCOMPtr<nsISupportsWeakReference> supportsWeak;
20829N/A+ supportsWeak = do_QueryInterface(mProgressGuard);
20829N/A+ nsCOMPtr<nsIWeakReference> weakRef;
20829N/A+ supportsWeak->GetWeakReference(getter_AddRefs(weakRef));
20829N/A+ webBrowser->AddWebBrowserListener(weakRef,
20829N/A+ NS_GET_IID(nsIWebProgressListener));
20829N/A+ // set ourselves as the parent uri content listener
20829N/A+ nsCOMPtr<nsIURIContentListener> uriListener;
20829N/A+ uriListener = do_QueryInterface(mContentListenerGuard);
20829N/A+ webBrowser->SetParentURIContentListener(uriListener);
20829N/A+ // save the window id of the newly created window
20829N/A+ nsCOMPtr<nsIWidget> mozWidget;
20829N/A+ mWindow->mBaseWindow->GetMainWidget(getter_AddRefs(mozWidget));
20829N/A+ // get the native drawing area
20829N/A+ mozWidget->GetNativeData(NS_NATIVE_WINDOW));
20829N/A+ // and, thanks to superwin we actually need the parent of that.
20829N/A+ tmp_window = gdk_window_get_parent(tmp_window);
20829N/A+ // save the widget ID - it should be the mozarea of the window.
20829N/A+ gdk_window_get_user_data(tmp_window, &data);
20829N/A+ mMozWindowWidget = static_cast<GtkWidget *>(data);
20829N/A+ // Apply the current chrome mask
20829N/A+ // reparent to our offscreen window
20829N/A+ gtk_widget_reparent(mMozWindowWidget, sOffscreenFixed);
20829N/A+ // Get the nsIWebBrowser object for our embedded window.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ // and set the visibility on the thing
20829N/A+ nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(webBrowser);
20829N/A+ baseWindow->SetVisibility(PR_TRUE);
20829N/A+ // Get the nsIWebBrowser object for our embedded window.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ // and set the visibility on the thing
20829N/A+ nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(webBrowser);
20829N/A+ baseWindow->SetVisibility(PR_FALSE);
20829N/A+EmbedPrivate::Resize(PRUint32 aWidth, PRUint32 aHeight)
20829N/A+ mWindow->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER,
20829N/A+ // This flag might have been set from
20829N/A+ // EmbedWindow::DestroyBrowserWindow() as well if someone used a
20829N/A+ // the window. No harm setting it again.
20829N/A+ // Get the nsIWebBrowser object for our embedded window.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ // Release our progress listener
20829N/A+ nsCOMPtr<nsISupportsWeakReference> supportsWeak;
20829N/A+ supportsWeak = do_QueryInterface(mProgressGuard);
20829N/A+ nsCOMPtr<nsIWeakReference> weakRef;
20829N/A+ supportsWeak->GetWeakReference(getter_AddRefs(weakRef));
20829N/A+ webBrowser->RemoveWebBrowserListener(weakRef,
20829N/A+ NS_GET_IID(nsIWebProgressListener));
20829N/A+ // Release our content listener
20829N/A+ webBrowser->SetParentURIContentListener(nsnull);
20829N/A+ mContentListenerGuard = nsnull;
20829N/A+ // Now that we have removed the listener, release our progress
20829N/A+ // detach our event listeners and release the event receiver
20829N/A+EmbedPrivate::SetURI(const char *aURI)
20829N/A+EmbedPrivate::LoadCurrentURI(void)
20829N/A+ nsCOMPtr<nsPIDOMWindow> piWin;
20829N/A+ GetPIDOMWindow(getter_AddRefs(piWin));
20829N/A+ nsAutoPopupStatePusher popupStatePusher(piWin, openAllowed);
20829N/A+ mNavigation->LoadURI(NS_ConvertUTF8toUTF16(mURI).get(), // URI string
20829N/A+ nsIWebNavigation::LOAD_FLAGS_NONE | // Load flags
20829N/A+EmbedPrivate::Reload(PRUint32 reloadFlags)
20829N/A+ /* Use the session history if it is available, this
20829N/A+ * allows framesets to reload correctly */
20829N/A+ nsCOMPtr<nsIWebNavigation> wn;
20829N/A+ wn = do_QueryInterface(mSessionHistory);
20829N/A+EmbedPrivate::ApplyChromeMask()
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ nsCOMPtr<nsIDOMWindow> domWindow;
20829N/A+ webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
20829N/A+ nsCOMPtr<nsIDOMBarProp> scrollbars;
20829N/A+ domWindow->GetScrollbars(getter_AddRefs(scrollbars));
20829N/A+ (mChromeMask & nsIWebBrowserChrome::CHROME_SCROLLBARS ?
20829N/A+EmbedPrivate::SetChromeMask(PRUint32 aChromeMask)
20829N/A+EmbedPrivate::PushStartup(void)
20829N/A+ // increment the number of widgets
20829N/A+ // if this is the first widget, fire up xpcom
20829N/A+ nsCOMPtr<nsILocalFile> binDir;
20829N/A+ rv = NS_NewNativeLocalFile(nsDependentCString(sCompPath), 1, getter_AddRefs(binDir));
20829N/A+ grePath = getenv("MOZILLA_FIVE_HOME");
20829N/A+ nsCOMPtr<nsILocalFile> greDir;
20829N/A+ rv = NS_NewNativeLocalFile(nsDependentCString(grePath), PR_TRUE,
20829N/A+ if (sProfileDir && !sProfileLock) {
20829N/A+ rv = XRE_LockProfileDirectory(sProfileDir,
20829N/A+ rv = XRE_InitEmbedding2(greDir, binDir,
20829N/A+ const_cast<GTKEmbedDirectoryProvider*>(&kDirectoryProvider));
20829N/A+ // destroy the offscreen window
20829N/A+ // we no longer need a reference to the DirectoryServiceProvider
20829N/A+ NS_RELEASE(sAppFileLocProvider);
20829N/A+void EmbedPrivate::SetPath(const char *aPath)
20829N/A+EmbedPrivate::SetCompPath(const char *aPath)
20829N/A+EmbedPrivate::SetProfilePath(const char *aDir, const char *aName)
20829N/A+ NS_ERROR("Cannot change profile directory during run.");
20829N/A+ NS_NewNativeLocalFile(nsDependentCString(aDir), PR_TRUE, &sProfileDir);
20829N/A+ if (NS_SUCCEEDED(rv) && aName)
20829N/A+ rv = sProfileDir->AppendNative(nsDependentCString(aName));
20829N/A+ rv = sProfileDir->Exists(&exists);
20829N/A+ rv = sProfileDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
20829N/A+ rv = XRE_LockProfileDirectory(sProfileDir, &sProfileLock);
20829N/A+ NS_WARNING("Failed to lock profile.");
20829N/A+EmbedPrivate::SetDirectoryServiceProvider(nsIDirectoryServiceProvider * appFileLocProvider)
20829N/A+ NS_RELEASE(sAppFileLocProvider);
20829N/A+ sAppFileLocProvider = appFileLocProvider;
20829N/A+ NS_ADDREF(sAppFileLocProvider);
20829N/A+EmbedPrivate::OpenStream(const char *aBaseURI, const char *aContentType)
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
20829N/A+ if (!wbStream) return NS_ERROR_FAILURE;
20829N/A+ nsresult rv = NS_NewURI(getter_AddRefs(uri), aBaseURI);
20829N/A+ rv = wbStream->OpenStream(uri, nsDependentCString(aContentType));
20829N/A+EmbedPrivate::AppendToStream(const PRUint8 *aData, PRUint32 aLen)
20829N/A+ // Attach listeners to this document since in some cases we don't
20829N/A+ // get updates for content added this way.
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
20829N/A+ if (!wbStream) return NS_ERROR_FAILURE;
20829N/A+ return wbStream->AppendToStream(aData, aLen);
20829N/A+EmbedPrivate::CloseStream(void)
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ nsCOMPtr<nsIWebBrowserStream> wbStream = do_QueryInterface(webBrowser);
20829N/A+ if (!wbStream) return NS_ERROR_FAILURE;
20829N/A+ return wbStream->CloseStream();
20829N/A+EmbedPrivate::FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser)
20829N/A+ // Get the number of browser windows.
20829N/A+ PRInt32 count = sWindowList->Length();
20829N/A+ // This function doesn't get called very often at all ( only when
20829N/A+ // creating a new window ) so it's OK to walk the list of open
20829N/A+ for (int i = 0; i < count; i++) {
20829N/A+ EmbedPrivate *tmpPrivate = sWindowList->ElementAt(i);
20829N/A+ // get the browser object for that window
20829N/A+ nsIWebBrowserChrome *chrome = static_cast<nsIWebBrowserChrome *>(
20829N/A+EmbedPrivate::ContentStateChange(void)
20829N/A+ // we don't attach listeners to chrome
20829N/A+ if (mListenersAttached && !mIsChrome)
20829N/A+EmbedPrivate::ContentFinishedLoading(void)
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ // get the content DOM window for that web browser
20829N/A+ nsCOMPtr<nsIDOMWindow> domWindow;
20829N/A+ webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
20829N/A+ NS_WARNING("no dom window in content finished loading\n");
20829N/A+ // and since we're done loading show the window, assuming that the
20829N/A+ // visibility flag has been set.
20829N/A+ mWindow->GetVisibility(&visibility);
20829N/A+ mWindow->SetVisibility(PR_TRUE);
20829N/A+EmbedPrivate::ChildFocusIn(void)
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ rv = mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ nsCOMPtr<nsIWebBrowserFocus> webBrowserFocus(do_QueryInterface(webBrowser));
20829N/A+EmbedPrivate::ChildFocusOut(void)
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ rv = mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ nsCOMPtr<nsIWebBrowserFocus> webBrowserFocus(do_QueryInterface(webBrowser));
20829N/A+ webBrowserFocus->Deactivate();
20829N/A+// Get the event listener for the chrome event handler.
20829N/A+EmbedPrivate::GetListener(void)
20829N/A+ nsCOMPtr<nsPIDOMWindow> piWin;
20829N/A+ GetPIDOMWindow(getter_AddRefs(piWin));
20829N/A+ mEventTarget = do_QueryInterface(piWin->GetChromeEventHandler());
20829N/A+// attach key and mouse event listeners
20829N/A+EmbedPrivate::AttachListeners(void)
20829N/A+ if (!mEventTarget || mListenersAttached)
20829N/A+ nsIDOMEventListener *eventListener =
20829N/A+ static_cast<nsIDOMEventListener *>(static_cast<nsIDOMKeyListener *>(mEventListener));
20829N/A+ rv = mEventTarget->AddEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMKeyListener));
20829N/A+ NS_WARNING("Failed to add key listener\n");
20829N/A+ rv = mEventTarget->AddEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMMouseListener));
20829N/A+ NS_WARNING("Failed to add mouse listener\n");
20829N/A+ rv = mEventTarget->AddEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMUIListener));
20829N/A+ NS_WARNING("Failed to add UI listener\n");
20829N/A+EmbedPrivate::DetachListeners(void)
20829N/A+ if (!mListenersAttached || !mEventTarget)
20829N/A+ nsIDOMEventListener *eventListener =
20829N/A+ static_cast<nsIDOMEventListener *>(static_cast<nsIDOMKeyListener *>(mEventListener));
20829N/A+ rv = mEventTarget->RemoveEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMKeyListener));
20829N/A+ NS_WARNING("Failed to remove key listener\n");
20829N/A+ mEventTarget->RemoveEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMMouseListener));
20829N/A+ NS_WARNING("Failed to remove mouse listener\n");
20829N/A+ rv = mEventTarget->RemoveEventListenerByIID(eventListener,
20829N/A+ NS_GET_IID(nsIDOMUIListener));
20829N/A+ NS_WARNING("Failed to remove UI listener\n");
20829N/A+ mListenersAttached = PR_FALSE;
20829N/A+EmbedPrivate::GetPIDOMWindow(nsPIDOMWindow **aPIWin)
20829N/A+ nsCOMPtr<nsIWebBrowser> webBrowser;
20829N/A+ mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
20829N/A+ // get the content DOM window for that web browser
20829N/A+ nsCOMPtr<nsIDOMWindow> domWindow;
20829N/A+ webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
20829N/A+ nsCOMPtr<nsPIDOMWindow> domWindowPrivate = do_QueryInterface(domWindow);
20829N/A+ // and the root window for that DOM window
20829N/A+ *aPIWin = domWindowPrivate->GetPrivateRoot();
20829N/A+EmbedPrivate::GetAtkObjectForCurrentDocument()
20829N/A+ nsCOMPtr<nsIAccessibilityService> accService =
20829N/A+ nsCOMPtr<nsIDOMDocument> domDoc;
20829N/A+ mNavigation->GetDocument(getter_AddRefs(domDoc));
20829N/A+ NS_ENSURE_TRUE(domDoc, nsnull);
20829N/A+ nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(domDoc));
20829N/A+ NS_ENSURE_TRUE(domNode, nsnull);
20829N/A+ accService->GetAccessibleFor(domNode, getter_AddRefs(acc));
20829N/A+ if (NS_SUCCEEDED(acc->GetNativeInterface(&atkObj)))
20829N/A+#endif /* MOZ_ACCESSIBILITY_ATK */
20829N/A+EmbedPrivate::RegisterAppComponents(void)
20829N/A+ XRE_AddStaticComponent(&kDefaultPromptModule);
20829N/A+EmbedPrivate::EnsureOffscreenWindow(void)
20829N/A+ sOffscreenWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20829N/A+ gtk_widget_realize(sOffscreenWindow);
20829N/A+ sOffscreenFixed = gtk_fixed_new();
20829N/A+ gtk_container_add(GTK_CONTAINER(sOffscreenWindow), sOffscreenFixed);
20829N/A+ gtk_widget_realize(sOffscreenFixed);
20829N/A+EmbedPrivate::DestroyOffscreenWindow(void)
20829N/A+ gtk_widget_destroy(sOffscreenWindow);
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+// for our one function that gets the EmbedPrivate via the chrome
20829N/A+class nsIDirectoryServiceProvider;
20829N/A+ nsresult Init (GtkMozEmbed *aOwningWidget);
20829N/A+ nsresult Realize (PRBool *aAlreadRealized);
20829N/A+ void Resize (PRUint32 aWidth, PRUint32 aHeight);
20829N/A+ void SetURI (const char *aURI);
20829N/A+ void Reload (PRUint32 reloadFlags);
20829N/A+ void SetChromeMask (PRUint32 chromeMask);
20829N/A+ static void PushStartup (void);
20829N/A+ static void PopStartup (void);
20829N/A+ static void SetPath (const char *aPath);
20829N/A+ static void SetCompPath (const char *aPath);
20829N/A+ static void SetProfilePath (const char *aDir, const char *aName);
20829N/A+ static void SetDirectoryServiceProvider (nsIDirectoryServiceProvider * appFileLocProvider);
20829N/A+ nsresult OpenStream (const char *aBaseURI, const char *aContentType);
20829N/A+ nsresult AppendToStream (const PRUint8 *aData, PRUint32 aLen);
20829N/A+ // This function will find the specific EmbedPrivate object for a
20829N/A+ static EmbedPrivate *FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser);
20829N/A+ // This is an upcall that will come from the progress listener
20829N/A+ // whenever there is a content state change. We need this so we can
20829N/A+ void ContentStateChange (void);
20829N/A+ // This is an upcall from the progress listener when content is
20829N/A+ // finished loading. We have this so that if it's chrome content
20829N/A+ // that we can size to content properly and show ourselves if
20829N/A+ void ContentFinishedLoading(void);
20829N/A+ // these are when the widget itself gets focus in and focus out
20829N/A+ void *GetAtkObjectForCurrentDocument();
20829N/A+ // all of the objects that we own
20829N/A+ nsCOMPtr<nsISupports> mWindowGuard;
20829N/A+ nsCOMPtr<nsISupports> mProgressGuard;
20829N/A+ EmbedContentListener *mContentListener;
20829N/A+ nsCOMPtr<nsISupports> mContentListenerGuard;
20829N/A+ EmbedEventListener *mEventListener;
20829N/A+ nsCOMPtr<nsISupports> mEventListenerGuard;
20829N/A+ nsCOMPtr<nsIWebNavigation> mNavigation;
20829N/A+ nsCOMPtr<nsISHistory> mSessionHistory;
20829N/A+ nsCOMPtr<nsPIDOMEventTarget> mEventTarget;
20829N/A+ // the number of widgets that have been created
20829N/A+ // the appshell we have created
20829N/A+ static nsIAppShell *sAppShell;
20829N/A+ // the list of all open windows
20829N/A+ static nsTArray<EmbedPrivate*> *sWindowList;
20829N/A+ static nsILocalFile *sProfileDir;
20829N/A+ static nsISupports *sProfileLock;
20829N/A+ static nsIDirectoryServiceProvider * sAppFileLocProvider;
20829N/A+ // has the chrome finished loading?
20829N/A+ // saved window ID for reparenting later
20829N/A+ // has someone called Destroy() on us?
20829N/A+ // is the chrome listener attached yet?
20829N/A+ // this will get the PIDOMWindow for this widget
20829N/A+ nsresult GetPIDOMWindow (nsPIDOMWindow **aPIWin);
20829N/A+ static void RegisterAppComponents();
20829N/A+ // offscreen window methods and the offscreen widget
20829N/A+ static void EnsureOffscreenWindow(void);
20829N/A+ static void DestroyOffscreenWindow(void);
20829N/A+ static GtkWidget *sOffscreenWindow;
20829N/A+ static GtkWidget *sOffscreenFixed;
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+EmbedProgress::EmbedProgress(void)
20829N/A+EmbedProgress::~EmbedProgress()
20829N/A+NS_IMPL_ISUPPORTS2(EmbedProgress,
20829N/A+EmbedProgress::Init(EmbedPrivate *aOwner)
20829N/A+EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
20829N/A+ // give the widget a chance to attach any listeners
20829N/A+ // if we've got the start flag, emit the signal
20829N/A+ if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
20829N/A+ (aStateFlags & GTK_MOZ_EMBED_FLAG_START))
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[NET_START], 0);
20829N/A+ // get the uri for this request
20829N/A+ RequestToURIString(aRequest, uriString);
20829N/A+ // is it the same as the current URI?
20829N/A+ // for people who know what they are doing
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[NET_STATE], 0,
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[NET_STATE_ALL], 0,
20829N/A+ (gint)aStateFlags, (gint)aStatus);
20829N/A+ if ((aStateFlags & GTK_MOZ_EMBED_FLAG_IS_NETWORK) &&
20829N/A+ (aStateFlags & GTK_MOZ_EMBED_FLAG_STOP))
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[NET_STOP], 0);
20829N/A+ // let our owner know that the load finished
20829N/A+ mOwner->ContentFinishedLoading();
20829N/A+EmbedProgress::OnProgressChange(nsIWebProgress *aWebProgress,
20829N/A+ RequestToURIString(aRequest, uriString);
20829N/A+ // is it the same as the current uri?
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[PROGRESS], 0,
20829N/A+ aCurTotalProgress, aMaxTotalProgress);
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[PROGRESS_ALL], 0,
20829N/A+ aCurTotalProgress, aMaxTotalProgress);
20829N/A+EmbedProgress::OnLocationChange(nsIWebProgress *aWebProgress,
20829N/A+ NS_ENSURE_ARG_POINTER(aLocation);
20829N/A+ // Make sure that this is the primary frame change and not
20829N/A+ PRBool isSubFrameLoad = PR_FALSE;
20829N/A+ nsCOMPtr<nsIDOMWindow> domWindow;
20829N/A+ nsCOMPtr<nsIDOMWindow> topDomWindow;
20829N/A+ aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
20829N/A+ domWindow->GetTop(getter_AddRefs(topDomWindow));
20829N/A+ if (domWindow != topDomWindow)
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[LOCATION], 0);
20829N/A+EmbedProgress::OnStatusChange(nsIWebProgress *aWebProgress,
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[STATUS_CHANGE], 0,
20829N/A+ static_cast<void *>(aRequest),
20829N/A+ static_cast<const void *>(aMessage));
20829N/A+EmbedProgress::OnSecurityChange(nsIWebProgress *aWebProgress,
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[SECURITY_CHANGE], 0,
20829N/A+ static_cast<void *>(aRequest),
20829N/A+EmbedProgress::RequestToURIString(nsIRequest *aRequest, nsACString &aString)
20829N/A+ channel = do_QueryInterface(aRequest);
20829N/A+ channel->GetURI(getter_AddRefs(uri));
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+class EmbedProgress : public nsIWebProgressListener,
20829N/A+ public nsSupportsWeakReference
20829N/A+ nsresult Init(EmbedPrivate *aOwner);
20829N/A+ NS_DECL_NSIWEBPROGRESSLISTENER
20829N/A+ static void RequestToURIString (nsIRequest *aRequest, nsACString &aString);
20829N/A+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
20829N/A+/* vim:expandtab:shiftwidth=4:tabstop=4: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2003
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Brian Ryner <bryner@brianryner.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+// This table contains the optional widgets and icons associated with
20829N/A+static const DialogDescription DialogTable[] = {
20829N/A+ { 0, GTK_STOCK_DIALOG_WARNING }, // ALERT
20829N/A+ { INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_WARNING }, // ALERT_CHECK
20829N/A+ { INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM
20829N/A+ INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // CONFIRM_CHECK
20829N/A+ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT
20829N/A+ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_USER_PASS
20829N/A+ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION }, // PROMPT_PASS
20829N/A+ { INCLUDE_CANCEL, GTK_STOCK_DIALOG_QUESTION }, // SELECT
20829N/A+ INCLUDE_CHECKBOX, GTK_STOCK_DIALOG_QUESTION } // UNIVERSAL
20829N/A+EmbedPrompter::EmbedPrompter(void)
20829N/A+EmbedPrompter::~EmbedPrompter(void)
20829N/A+EmbedPrompter::Create(PromptType aType, GtkWindow* aParentWindow)
20829N/A+ // only add the dialog to the window group if the parent already has a window group,
20829N/A+ // so as not to break app's expectations about modal dialogs.
20829N/A+ if (aParentWindow && aParentWindow->group) {
20829N/A+ gtk_window_group_add_window (aParentWindow->group, GTK_WINDOW (mWindow));
20829N/A+ // gtk will resize this for us as necessary
20829N/A+ gtk_window_set_default_size(GTK_WINDOW(mWindow), 100, 50);
20829N/A+ // this HBox will contain the icon, and a vbox which contains the
20829N/A+ // dialog text and other widgets.
20829N/A+ GtkWidget* dialogHBox = gtk_hbox_new(FALSE, 12);
20829N/A+ // Set up dialog properties according to the GNOME HIG
20829N/A+ gtk_container_set_border_width(GTK_CONTAINER(mWindow), 6);
20829N/A+ gtk_dialog_set_has_separator(GTK_DIALOG(mWindow), FALSE);
20829N/A+ gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(mWindow)->vbox), 12);
20829N/A+ gtk_container_set_border_width(GTK_CONTAINER(dialogHBox), 6);
20829N/A+ // This is the VBox which will contain the label and other controls.
20829N/A+ GtkWidget* contentsVBox = gtk_vbox_new(FALSE, 12);
20829N/A+ // get the stock icon for this dialog and put it in the box
20829N/A+ const gchar* iconDesc = DialogTable[aType].icon;
20829N/A+ GtkWidget* icon = gtk_image_new_from_stock(iconDesc, GTK_ICON_SIZE_DIALOG);
20829N/A+ gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
20829N/A+ gtk_box_pack_start(GTK_BOX(dialogHBox), icon, FALSE, FALSE, 0);
20829N/A+ // now pack the label into the vbox
20829N/A+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
20829N/A+ gtk_label_set_selectable(GTK_LABEL(label), TRUE);
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), label, FALSE, FALSE, 0);
20829N/A+ int widgetFlags = DialogTable[aType].flags;
20829N/A+ if (widgetFlags & (INCLUDE_USERNAME | INCLUDE_PASSWORD)) {
20829N/A+ // If we're creating a username
and/or password field, make an hbox
20829N/A+ // which will contain two vboxes, one for the labels and one for the
20829N/A+ // text fields. This will let us line up the textfields.
20829N/A+ GtkWidget* userPassHBox = gtk_hbox_new(FALSE, 12);
20829N/A+ GtkWidget* userPassLabels = gtk_vbox_new(TRUE, 6);
20829N/A+ GtkWidget* userPassFields = gtk_vbox_new(TRUE, 6);
20829N/A+ if (widgetFlags & INCLUDE_USERNAME) {
20829N/A+ GtkWidget* userLabel = gtk_label_new("User Name:");
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassLabels), userLabel, FALSE,
20829N/A+ gtk_entry_set_activates_default(GTK_ENTRY(mUserField), TRUE);
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassFields), mUserField, FALSE,
20829N/A+ if (widgetFlags & INCLUDE_PASSWORD) {
20829N/A+ GtkWidget* passLabel = gtk_label_new("Password:");
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassLabels), passLabel, FALSE,
20829N/A+ gtk_entry_set_visibility(GTK_ENTRY(mPassField), FALSE);
20829N/A+ gtk_entry_set_activates_default(GTK_ENTRY(mPassField), TRUE);
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassFields), mPassField, FALSE,
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassHBox), userPassLabels, FALSE,
20829N/A+ gtk_box_pack_start(GTK_BOX(userPassHBox), userPassFields, FALSE,
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), userPassHBox, FALSE, FALSE, 0);
20829N/A+ gtk_entry_set_activates_default(GTK_ENTRY(mTextField), TRUE);
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), mTextField, FALSE, FALSE, 0);
20829N/A+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mCheckBox),
20829N/A+ gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(mCheckBox))),
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), mCheckBox, FALSE, FALSE, 0);
20829N/A+ // Build up a GtkComboBox containing the items
20829N/A+ GtkWidget* mComboBox = gtk_combo_box_new_text();
20829N/A+ for (PRUint32 i = 0; i < mItemCount; ++i) {
20829N/A+ gtk_combo_box_append_text(GTK_COMBO_BOX(mComboBox), mItemList[i].get());
20829N/A+ gtk_box_pack_start(GTK_BOX(contentsVBox), mComboBox, FALSE, FALSE, 0);
20829N/A+ if (aType == TYPE_UNIVERSAL) {
20829N/A+ // Create buttons based on the flags passed in.
20829N/A+ for (PRUint32 i = EMBED_MAX_BUTTONS; i-- > 0; ) {
20829N/A+ if (!mButtonLabels[i].IsEmpty())
20829N/A+ gtk_dialog_add_button(GTK_DIALOG(mWindow),
20829N/A+ gtk_dialog_set_default_response(GTK_DIALOG(mWindow), 0);
20829N/A+ // Create standard ok and cancel buttons
20829N/A+ if (widgetFlags & INCLUDE_CANCEL)
20829N/A+ gtk_dialog_add_button(GTK_DIALOG(mWindow), GTK_STOCK_CANCEL,
20829N/A+ GtkWidget* okButton = gtk_dialog_add_button(GTK_DIALOG(mWindow),
20829N/A+ gtk_widget_grab_default(okButton);
20829N/A+ // Pack the contentsVBox into the dialogHBox and the dialog.
20829N/A+ gtk_box_pack_start(GTK_BOX(dialogHBox), contentsVBox, FALSE, FALSE, 0);
20829N/A+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mWindow)->vbox), dialogHBox, FALSE,
20829N/A+EmbedPrompter::SetTitle(const PRUnichar *aTitle)
20829N/A+EmbedPrompter::SetTextValue(const PRUnichar *aTextValue)
20829N/A+EmbedPrompter::SetCheckMessage(const PRUnichar *aMessage)
20829N/A+EmbedPrompter::SetMessageText(const PRUnichar *aMessageText)
20829N/A+EmbedPrompter::SetUser(const PRUnichar *aUser)
20829N/A+EmbedPrompter::SetPassword(const PRUnichar *aPass)
20829N/A+EmbedPrompter::SetCheckValue(const PRBool aValue)
20829N/A+EmbedPrompter::SetItems(const PRUnichar** aItemArray, PRUint32 aCount)
20829N/A+ mItemList = new nsCString[aCount];
20829N/A+ for (PRUint32 i = 0; i < aCount; ++i)
20829N/A+ mItemList[i].Assign(NS_ConvertUTF16toUTF8(aItemArray[i]));
20829N/A+EmbedPrompter::SetButtons(const PRUnichar* aButton0Label,
20829N/A+ const PRUnichar* aButton1Label,
20829N/A+ const PRUnichar* aButton2Label)
20829N/A+ mButtonLabels[0].Assign(NS_ConvertUTF16toUTF8(aButton0Label));
20829N/A+ mButtonLabels[1].Assign(NS_ConvertUTF16toUTF8(aButton1Label));
20829N/A+ mButtonLabels[2].Assign(NS_ConvertUTF16toUTF8(aButton2Label));
20829N/A+EmbedPrompter::GetCheckValue(PRBool *aValue)
20829N/A+EmbedPrompter::GetConfirmValue(PRBool *aConfirmValue)
20829N/A+ *aConfirmValue = mConfirmResult;
20829N/A+EmbedPrompter::GetTextValue(PRUnichar **aTextValue)
20829N/A+ *aTextValue = ToNewUnicode(NS_ConvertUTF8toUTF16(mTextValue));
20829N/A+EmbedPrompter::GetUser(PRUnichar **aUser)
20829N/A+ *aUser = ToNewUnicode(NS_ConvertUTF8toUTF16(mUser));
20829N/A+EmbedPrompter::GetPassword(PRUnichar **aPass)
20829N/A+ *aPass = ToNewUnicode(NS_ConvertUTF8toUTF16(mPass));
20829N/A+EmbedPrompter::GetSelectedItem(PRInt32 *aIndex)
20829N/A+EmbedPrompter::GetButtonPressed(PRInt32 *aButton)
20829N/A+ gint response = gtk_dialog_run(GTK_DIALOG(mWindow));
20829N/A+ case GTK_RESPONSE_DELETE_EVENT:
20829N/A+EmbedPrompter::SaveDialogValues()
20829N/A+ mCheckValue = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mCheckBox));
20829N/A+ gchar *str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(mComboBox));
20829N/A+ for (PRUint32 i = 0; i < mItemCount; ++i) {
20829N/A+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
20829N/A+/* vim:expandtab:shiftwidth=4:tabstop=4: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Brian Ryner <bryner@brianryner.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+ nsresult Create(PromptType aType, GtkWindow* aParentWindow);
20829N/A+ void SetTitle(const PRUnichar *aTitle);
20829N/A+ void SetTextValue (const PRUnichar *aTextValue);
20829N/A+ void SetCheckMessage(const PRUnichar *aCheckMessage);
20829N/A+ void SetCheckValue(const PRBool aValue);
20829N/A+ void SetMessageText(const PRUnichar *aMessageText);
20829N/A+ void SetUser(const PRUnichar *aUser);
20829N/A+ void SetPassword(const PRUnichar *aPass);
20829N/A+ void SetButtons(const PRUnichar* aButton0Label,
20829N/A+ const PRUnichar* aButton1Label,
20829N/A+ const PRUnichar* aButton2Label);
20829N/A+ void SetItems(const PRUnichar **aItemArray, PRUint32 aCount);
20829N/A+ void GetCheckValue(PRBool *aValue);
20829N/A+ void GetConfirmValue(PRBool *aConfirmValue);
20829N/A+ void GetTextValue(PRUnichar **aTextValue);
20829N/A+ void GetUser(PRUnichar **aUser);
20829N/A+ void GetPassword(PRUnichar **aPass);
20829N/A+ void GetButtonPressed(PRInt32 *aButton);
20829N/A+ void GetSelectedItem(PRInt32 *aIndex);
20829N/A+ nsCString mButtonLabels[EMBED_MAX_BUTTONS];
20829N/A+ * ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+GtkWidget *EmbedWindow::sTipWindow = nsnull;
20829N/A+EmbedWindow::~EmbedWindow(void)
20829N/A+EmbedWindow::Init(EmbedPrivate *aOwner)
20829N/A+ // create our nsIWebBrowser object and set up some basic defaults.
20829N/A+ mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
20829N/A+ mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome *>(this));
20829N/A+ nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(mWebBrowser);
20829N/A+ item->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
20829N/A+EmbedWindow::CreateWindow(void)
20829N/A+ GtkWidget *ownerAsWidget = GTK_WIDGET(mOwner->mOwningWidget);
20829N/A+ // Get the base window interface for the web browser object and
20829N/A+ mBaseWindow = do_QueryInterface(mWebBrowser);
20829N/A+ rv = mBaseWindow->InitWindow(GTK_WIDGET(mOwner->mOwningWidget),
20829N/A+EmbedWindow::ReleaseChildren(void)
20829N/A+NS_INTERFACE_MAP_BEGIN(EmbedWindow)
20829N/A+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
20829N/A+ NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
20829N/A+EmbedWindow::SetStatus(PRUint32 aStatusType, const PRUnichar *aStatus)
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[JS_STATUS], 0);
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[LINK_MESSAGE], 0);
20829N/A+EmbedWindow::GetWebBrowser(nsIWebBrowser **aWebBrowser)
20829N/A+EmbedWindow::SetWebBrowser(nsIWebBrowser *aWebBrowser)
20829N/A+EmbedWindow::GetChromeFlags(PRUint32 *aChromeFlags)
20829N/A+ *aChromeFlags = mOwner->mChromeMask;
20829N/A+EmbedWindow::SetChromeFlags(PRUint32 aChromeFlags)
20829N/A+ mOwner->SetChromeMask(aChromeFlags);
20829N/A+EmbedWindow::DestroyBrowserWindow(void)
20829N/A+ // mark the owner as destroyed so it won't emit events anymore.
20829N/A+ mOwner->mIsDestroyed = PR_TRUE;
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[DESTROY_BROWSER], 0);
20829N/A+EmbedWindow::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[SIZE_TO], 0, aCX, aCY);
20829N/A+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+EmbedWindow::IsWindowModal(PRBool *_retval)
20829N/A+EmbedWindow::ExitModalEventLoop(nsresult aStatus)
20829N/A+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+EmbedWindow::FocusNextElement()
20829N/A+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ if (!GTK_WIDGET_TOPLEVEL(toplevel))
20829N/A+ g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
20829N/A+EmbedWindow::FocusPrevElement()
20829N/A+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ if (!GTK_WIDGET_TOPLEVEL(toplevel))
20829N/A+ g_signal_emit_by_name(G_OBJECT(toplevel), "move_focus",
20829N/A+EmbedWindow::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY,
20829N/A+ if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
20829N/A+ (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
20829N/A+ return mBaseWindow->SetPositionAndSize(aX, aY, aCX, aCY, PR_TRUE);
20829N/A+ else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
20829N/A+ return mBaseWindow->SetPosition(aX, aY);
20829N/A+ else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
20829N/A+ return mBaseWindow->SetSize(aCX, aCY, PR_TRUE);
20829N/A+EmbedWindow::GetDimensions(PRUint32 aFlags, PRInt32 *aX,
20829N/A+ PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
20829N/A+ if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
20829N/A+ (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
20829N/A+ return mBaseWindow->GetPositionAndSize(aX, aY, aCX, aCY);
20829N/A+ else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) {
20829N/A+ return mBaseWindow->GetPosition(aX, aY);
20829N/A+ else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
20829N/A+ nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
20829N/A+ return mBaseWindow->GetSize(aCX, aCY);
20829N/A+ // XXX might have to do more here.
20829N/A+ return mBaseWindow->SetFocus();
20829N/A+EmbedWindow::GetTitle(PRUnichar **aTitle)
20829N/A+ *aTitle = ToNewUnicode(mTitle);
20829N/A+EmbedWindow::SetTitle(const PRUnichar *aTitle)
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+EmbedWindow::GetSiteWindow(void **aSiteWindow)
20829N/A+ GtkWidget *ownerAsWidget (GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ *aSiteWindow = static_cast<void *>(ownerAsWidget);
20829N/A+EmbedWindow::GetVisibility(PRBool *aVisibility)
20829N/A+ // Work around the problem that sometimes the window
20829N/A+ // is already visible even though mVisibility isn't true
20829N/A+ GTK_WIDGET_MAPPED(mOwner->mOwningWidget));
20829N/A+EmbedWindow::SetVisibility(PRBool aVisibility)
20829N/A+ // We always set the visibility so that if it's chrome and we finish
20829N/A+ // the load we know that we have to show the window.
20829N/A+ // if this is a chrome window and the chrome hasn't finished loading
20829N/A+ // yet then don't show the window yet.
20829N/A+ if (mOwner->mIsChrome && !mOwner->mChromeLoaded)
20829N/A+ g_signal_emit(G_OBJECT(mOwner->mOwningWidget),
20829N/A+ moz_embed_signals[VISIBILITY], 0,
20829N/A+tooltips_paint_window(GtkWidget *window)
20829N/A+ // draw tooltip style border around the text
20829N/A+ gtk_paint_flat_box(window->style, window->window,
20829N/A+ GTK_STATE_NORMAL, GTK_SHADOW_OUT,
20829N/A+EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
20829N/A+ nsAutoString tipText ( aTipText );
20829N/A+ const char* tipString = ToNewUTF8String(tipText);
20829N/A+ gtk_widget_destroy(sTipWindow);
20829N/A+ // get the root origin for this content window
20829N/A+ nsCOMPtr<nsIWidget> mainWidget;
20829N/A+ mBaseWindow->GetMainWidget(getter_AddRefs(mainWidget));
20829N/A+ window = static_cast<GdkWindow *>(mainWidget->GetNativeData(NS_NATIVE_WINDOW));
20829N/A+ gdk_window_get_origin(window, &root_x, &root_y);
20829N/A+ // XXX work around until I can get pink to figure out why
20829N/A+ // tooltips vanish if they show up right at the origin of the
20829N/A+ sTipWindow = gtk_window_new(GTK_WINDOW_POPUP);
20829N/A+ gtk_widget_set_app_paintable(sTipWindow, TRUE);
20829N/A+ gtk_window_set_resizable(GTK_WINDOW(sTipWindow), TRUE);
20829N/A+ // needed to get colors + fonts etc correctly
20829N/A+ gtk_widget_set_name(sTipWindow, "gtk-tooltips");
20829N/A+ gtk_window_set_type_hint(GTK_WINDOW(sTipWindow), GDK_WINDOW_TYPE_HINT_TOOLTIP);
20829N/A+ // set up the popup window as a transient of the widget.
20829N/A+ toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
20829N/A+ if (!GTK_WINDOW(toplevel_window)) {
20829N/A+ NS_ERROR("no gtk window in hierarchy!");
20829N/A+ gtk_window_set_transient_for(GTK_WINDOW(sTipWindow),
20829N/A+ gtk_widget_realize(sTipWindow);
20829N/A+ g_signal_connect(G_OBJECT(sTipWindow), "expose_event",
20829N/A+ G_CALLBACK(tooltips_paint_window), NULL);
20829N/A+ // set up the label for the tooltip
20829N/A+ GtkWidget *label = gtk_label_new(tipString);
20829N/A+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
20829N/A+ gtk_container_add(GTK_CONTAINER(sTipWindow), label);
20829N/A+ gtk_container_set_border_width(GTK_CONTAINER(sTipWindow), 4);
20829N/A+ // set the coords for the widget
20829N/A+ gtk_widget_set_uposition(sTipWindow, aXCoords + root_x,
20829N/A+ gtk_widget_show_all(sTipWindow);
20829N/A+EmbedWindow::OnHideTooltip(void)
20829N/A+ gtk_widget_destroy(sTipWindow);
20829N/A+EmbedWindow::GetInterface(const nsIID &aIID, void** aInstancePtr)
20829N/A+ rv = QueryInterface(aIID, aInstancePtr);
20829N/A+ // pass it up to the web browser object
20829N/A+ if (NS_FAILED(rv) || !*aInstancePtr) {
20829N/A+ nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(mWebBrowser);
20829N/A+ return ir->GetInterface(aIID, aInstancePtr);
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+class EmbedWindow : public nsIWebBrowserChrome,
20829N/A+ public nsIWebBrowserChromeFocus,
20829N/A+ public nsIEmbeddingSiteWindow,
20829N/A+ nsresult Init (EmbedPrivate *aOwner);
20829N/A+ NS_DECL_NSIWEBBROWSERCHROMEFOCUS
20829N/A+ NS_DECL_NSIEMBEDDINGSITEWINDOW
20829N/A+ nsCOMPtr<nsIBaseWindow> mBaseWindow; // [OWNER]
20829N/A+ nsCOMPtr<nsIWebBrowser> mWebBrowser; // [OWNER]
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+// in order to create orphaned windows
20829N/A+EmbedWindowCreator::EmbedWindowCreator(void)
20829N/A+EmbedWindowCreator::~EmbedWindowCreator()
20829N/A+NS_IMPL_ISUPPORTS1(EmbedWindowCreator, nsIWindowCreator)
20829N/A+EmbedWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
20829N/A+ nsIWebBrowserChrome **_retval)
20829N/A+ NS_ENSURE_ARG_POINTER(_retval);
20829N/A+ GtkMozEmbed *newEmbed = nsnull;
20829N/A+ // No parent? Ask via the singleton object instead.
20829N/A+ gtk_moz_embed_single_create_window(&newEmbed,
20829N/A+ // Find the EmbedPrivate object for this web browser chrome object.
20829N/A+ EmbedPrivate *embedPrivate = EmbedPrivate::FindPrivateForBrowser(aParent);
20829N/A+ g_signal_emit(G_OBJECT(embedPrivate->mOwningWidget),
20829N/A+ moz_embed_signals[NEW_WINDOW], 0,
20829N/A+ &newEmbed, (guint)aChromeFlags);
20829N/A+ // check to make sure that we made a new window
20829N/A+ // The window _must_ be realized before we pass it back to the
20829N/A+ // function that created it. Functions that create new windows
20829N/A+ // will do things like GetDocShell() and the widget has to be
20829N/A+ // realized before that can happen.
20829N/A+ gtk_widget_realize(GTK_WIDGET(newEmbed));
20829N/A+ EmbedPrivate *newEmbedPrivate = static_cast<EmbedPrivate *>(newEmbed->data);
20829N/A+ // set the chrome flag on the new window if it's a chrome open
20829N/A+ if (aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)
20829N/A+ newEmbedPrivate->mIsChrome = PR_TRUE;
20829N/A+ *_retval = static_cast<nsIWebBrowserChrome *>(newEmbedPrivate->mWindow);
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+class EmbedWindowCreator : public nsIWindowCreator
20829N/A+ virtual ~EmbedWindowCreator();
20829N/A+#endif /* __EmbedWindowCreator_h */
20829N/A+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
20829N/A+/* vim:expandtab:shiftwidth=4:tabstop=4: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2003
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Brian Ryner <bryner@brianryner.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+GtkPromptService::GtkPromptService()
20829N/A+GtkPromptService::~GtkPromptService()
20829N/A+NS_IMPL_ISUPPORTS1(GtkPromptService, nsIPromptService)
20829N/A+GtkPromptService::Alert(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::AlertCheck(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aCheckMsg, PRBool* aCheckValue)
20829N/A+ NS_ENSURE_ARG_POINTER(aCheckValue);
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::Confirm(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText, PRBool* aConfirm)
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::ConfirmCheck(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ PRBool* aCheckValue, PRBool* aConfirm)
20829N/A+ NS_ENSURE_ARG_POINTER(aCheckValue);
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::ConfirmEx(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aButton0Title,
20829N/A+ const PRUnichar* aButton1Title,
20829N/A+ const PRUnichar* aButton2Title,
20829N/A+ const PRUnichar* aCheckMsg, PRBool* aCheckValue,
20829N/A+ nsAutoString button0Label, button1Label, button2Label;
20829N/A+ GetButtonLabel(aButtonFlags, BUTTON_POS_0, aButton0Title, button0Label);
20829N/A+ GetButtonLabel(aButtonFlags, BUTTON_POS_1, aButton1Title, button1Label);
20829N/A+ GetButtonLabel(aButtonFlags, BUTTON_POS_2, aButton2Title, button2Label);
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::Prompt(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText, PRUnichar** aValue,
20829N/A+ const PRUnichar* aCheckMsg, PRBool* aCheckValue,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::PromptUsernameAndPassword(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::PromptPassword(nsIDOMWindow* aParent,
20829N/A+ const PRUnichar* aDialogTitle,
20829N/A+ PRBool* aCheckValue, PRBool* aConfirm)
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::Select(nsIDOMWindow* aParent, const PRUnichar* aDialogTitle,
20829N/A+ const PRUnichar* aDialogText, PRUint32 aCount,
20829N/A+ const PRUnichar** aSelectList, PRInt32* outSelection,
20829N/A+ GetGtkWindowForDOMWindow(aParent));
20829N/A+GtkPromptService::GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow)
20829N/A+ nsCOMPtr<nsIWebBrowserChrome> chrome;
20829N/A+ wwatch->GetChromeForWindow(aDOMWindow, getter_AddRefs(chrome));
20829N/A+ nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow = do_QueryInterface(chrome);
20829N/A+ siteWindow->GetSiteWindow((void**)&parentWidget);
20829N/A+ GtkWidget* gtkWin = gtk_widget_get_toplevel(parentWidget);
20829N/A+ if (GTK_WIDGET_TOPLEVEL(gtkWin))
20829N/A+GtkPromptService::GetButtonLabel(PRUint32 aFlags, PRUint32 aPos,
20829N/A+ const PRUnichar* aStringValue,
20829N/A+ PRUint32 posFlag = (aFlags & (255 * aPos)) / aPos;
20829N/A+ NS_WARNING("Unexpected button flags");
20829N/A+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
20829N/A+/* vim:expandtab:shiftwidth=4:tabstop=4: */
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Netscape Communications Corporation.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2003
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Brian Ryner <bryner@brianryner.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+class GtkPromptService : public nsIPromptService
20829N/A+ GtkWindow* GetGtkWindowForDOMWindow(nsIDOMWindow* aDOMWindow);
20829N/A+ void GetButtonLabel(PRUint32 aFlags, PRUint32 aPos,
20829N/A+ const PRUnichar* aStringValue, nsAString &aLabel);
20829N/A+# ***** BEGIN LICENSE BLOCK *****
20829N/A+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+# The contents of this file are subject to the Mozilla Public License Version
20829N/A+# 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+# the License. You may obtain a copy of the License at
20829N/A+# Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+# for the specific language governing rights and limitations under the
20829N/A+# The Original Code is the Mozilla browser.
20829N/A+# The Initial Developer of the Original Code is
20829N/A+# Portions created by the Initial Developer are Copyright (C) 1999
20829N/A+# the Initial Developer. All Rights Reserved.
20829N/A+# Christopher Blizzard <blizzard@mozilla.org>
20829N/A+# Alternatively, the contents of this file may be used under the terms of
20829N/A+# either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+# in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+# of those above. If you wish to allow use of your version of this file only
20829N/A+# under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+# use your version of this file under the terms of the MPL, indicate your
20829N/A+# decision by deleting the provisions above and replace them with the notice
20829N/A+# and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+# the provisions above, a recipient may use your version of this file under
20829N/A+# the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+# ***** END LICENSE BLOCK *****
20829N/A+# When using Sun's WorkShop compiler, including
20829N/A+# causes most of these compiles to fail with:
20829N/A+# line 29: Error: Multiple declaration for std::tm.
20829N/A+# So, this gets around the problem.
20829N/A+CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
20829N/A+CFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)
20829N/A+MARSHAL_FILE = gtkmozembedmarshal
20829N/A+$(MARSHAL_FILE).h: $(MARSHAL_FILE).list
20829N/A+ glib-genmarshal --prefix=$(MARSHAL_PREFIX) $(srcdir)/$(MARSHAL_FILE).list --skip-source --header > $@
20829N/A+$(MARSHAL_FILE).c: $(MARSHAL_FILE).list $(MARSHAL_FILE).h
20829N/A+ glib-genmarshal --prefix=$(MARSHAL_PREFIX) $(srcdir)/$(MARSHAL_FILE).list --skip-source --body > $@
20829N/A+gtkmozembed2.$(OBJ_SUFFIX): $(MARSHAL_FILE).h
20829N/A+GARBAGE += $(MARSHAL_FILE).h $(MARSHAL_FILE).c
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Ramiro Estrugo <ramiro@eazel.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+/* Because this header may be included from files which not part of the mozilla
20829N/A+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
20829N/A+#define NS_HIDDEN __attribute__((visibility("hidden")))
20829N/A+#define GTKMOZEMBED_API(type, name, params) \
20829N/A+ typedef type (NS_FROZENCALL * name##Type) params; \
20829N/A+ extern name##Type name NS_HIDDEN;
20829N/A+#define GTKMOZEMBED_API(type, name, params) NS_EXPORT_(type) name params;
20829N/A+#define GTKMOZEMBED_API(type,name, params) NS_IMPORT_(type) name params;
20829N/A+#define GTK_TYPE_MOZ_EMBED (gtk_moz_embed_get_type())
20829N/A+#define GTK_MOZ_EMBED(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_MOZ_EMBED, GtkMozEmbed)
20829N/A+#define GTK_MOZ_EMBED_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_MOZ_EMBED, GtkMozEmbedClass)
20829N/A+#define GTK_IS_MOZ_EMBED(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_MOZ_EMBED)
20829N/A+#define GTK_IS_MOZ_EMBED_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_MOZ_EMBED)
20829N/A+typedef struct _GtkMozEmbed GtkMozEmbed;
20829N/A+typedef struct _GtkMozEmbedClass GtkMozEmbedClass;
20829N/A+ void (* link_message) (GtkMozEmbed *embed);
20829N/A+ void (* js_status) (GtkMozEmbed *embed);
20829N/A+ void (* location) (GtkMozEmbed *embed);
20829N/A+ void (* title) (GtkMozEmbed *embed);
20829N/A+ void (* progress) (GtkMozEmbed *embed, gint curprogress,
20829N/A+ void (* progress_all) (GtkMozEmbed *embed, const char *aURI,
20829N/A+ gint curprogress, gint maxprogress);
20829N/A+ void (* net_state) (GtkMozEmbed *embed, gint state, guint status);
20829N/A+ void (* net_state_all) (GtkMozEmbed *embed, const char *aURI,
20829N/A+ void (* net_start) (GtkMozEmbed *embed);
20829N/A+ void (* net_stop) (GtkMozEmbed *embed);
20829N/A+ void (* new_window) (GtkMozEmbed *embed, GtkMozEmbed **newEmbed,
20829N/A+ void (* visibility) (GtkMozEmbed *embed, gboolean visibility);
20829N/A+ void (* destroy_brsr) (GtkMozEmbed *embed);
20829N/A+ gint (* open_uri) (GtkMozEmbed *embed, const char *aURI);
20829N/A+ void (* size_to) (GtkMozEmbed *embed, gint width, gint height);
20829N/A+ gint (* dom_key_down) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_key_press) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_key_up) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_down) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_up) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_click) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_dbl_click) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_over) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_mouse_out) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ void (* security_change) (GtkMozEmbed *embed, gpointer request,
20829N/A+ void (* status_change) (GtkMozEmbed *embed, gpointer request,
20829N/A+ gint status, gpointer message);
20829N/A+ gint (* dom_activate) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_focus_in) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+ gint (* dom_focus_out) (GtkMozEmbed *embed, gpointer dom_event);
20829N/A+GTKMOZEMBED_API(GType, gtk_moz_embed_get_type, (void))
20829N/A+GTKMOZEMBED_API(GtkWidget*, gtk_moz_embed_new, (void))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_push_startup, (void))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_pop_startup, (void))
20829N/A+/* Tell gtkmozembed where the gtkmozembed libs live. If this is not specified,
20829N/A+ The MOZILLA_FIVE_HOME environment variable is checked. */
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_set_path, (const char *aPath))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_set_comp_path, (const char *aPath))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_set_profile_path, (const char *aDir,
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_load_url, (GtkMozEmbed *embed,
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_stop_load, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_back, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(gboolean, gtk_moz_embed_can_go_forward, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_go_back, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_go_forward, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_render_data, (GtkMozEmbed *embed,
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_open_stream, (GtkMozEmbed *embed,
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_append_data, (GtkMozEmbed *embed,
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_close_stream, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(char*, gtk_moz_embed_get_link_message, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(char*, gtk_moz_embed_get_js_status, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(char*, gtk_moz_embed_get_title, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(char*, gtk_moz_embed_get_location, (GtkMozEmbed *embed))
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_reload, (GtkMozEmbed *embed,
20829N/A+GTKMOZEMBED_API(void, gtk_moz_embed_set_chrome_mask, (GtkMozEmbed *embed,
20829N/A+GTKMOZEMBED_API(guint32, gtk_moz_embed_get_chrome_mask, (GtkMozEmbed *embed))
20829N/A+ GTK_MOZ_EMBED_FLAG_REDIRECTING = 2,
20829N/A+ GTK_MOZ_EMBED_FLAG_TRANSFERRING = 4,
20829N/A+ GTK_MOZ_EMBED_FLAG_NEGOTIATING = 8,
20829N/A+ GTK_MOZ_EMBED_FLAG_IS_REQUEST = 65536,
20829N/A+ GTK_MOZ_EMBED_FLAG_IS_DOCUMENT = 131072,
20829N/A+ GTK_MOZ_EMBED_FLAG_IS_NETWORK = 262144,
20829N/A+ GTK_MOZ_EMBED_FLAG_IS_WINDOW = 524288,
20829N/A+ GTK_MOZ_EMBED_FLAG_RESTORING = 16777216
20829N/A+/* These are from various networking headers */
20829N/A+ GTK_MOZ_EMBED_STATUS_FAILED_DNS = 2152398878U,
20829N/A+ /* NS_ERROR_CONNECTION_REFUSED */
20829N/A+ GTK_MOZ_EMBED_STATUS_FAILED_CONNECT = 2152398861U,
20829N/A+ GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT = 2152398862U,
20829N/A+ GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED = 2152398850U
20829N/A+ changed. Now there's a mapping table that maps these values to the
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADNORMAL = 0,
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE = 1,
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXY = 2,
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE = 3,
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE = 4
20829N/A+ GTK_MOZ_EMBED_FLAG_DEFAULTCHROME = 1U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWBORDERSON = 2U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWCLOSEON = 4U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWRESIZEON = 8U,
20829N/A+ GTK_MOZ_EMBED_FLAG_MENUBARON = 16U,
20829N/A+ GTK_MOZ_EMBED_FLAG_TOOLBARON = 32U,
20829N/A+ GTK_MOZ_EMBED_FLAG_LOCATIONBARON = 64U,
20829N/A+ GTK_MOZ_EMBED_FLAG_STATUSBARON = 128U,
20829N/A+ GTK_MOZ_EMBED_FLAG_PERSONALTOOLBARON = 256U,
20829N/A+ GTK_MOZ_EMBED_FLAG_SCROLLBARSON = 512U,
20829N/A+ GTK_MOZ_EMBED_FLAG_TITLEBARON = 1024U,
20829N/A+ GTK_MOZ_EMBED_FLAG_EXTRACHROMEON = 2048U,
20829N/A+ GTK_MOZ_EMBED_FLAG_ALLCHROME = 4094U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWRAISED = 33554432U,
20829N/A+ GTK_MOZ_EMBED_FLAG_WINDOWLOWERED = 67108864U,
20829N/A+ GTK_MOZ_EMBED_FLAG_CENTERSCREEN = 134217728U,
20829N/A+ GTK_MOZ_EMBED_FLAG_DEPENDENT = 268435456U,
20829N/A+ GTK_MOZ_EMBED_FLAG_MODAL = 536870912U,
20829N/A+ GTK_MOZ_EMBED_FLAG_OPENASDIALOG = 1073741824U,
20829N/A+ GTK_MOZ_EMBED_FLAG_OPENASCHROME = 2147483648U
20829N/A+/* this is a singleton object that you can hook up to to get signals
20829N/A+ that are not handed out on a per widget basis. */
20829N/A+#define GTK_TYPE_MOZ_EMBED_SINGLE (gtk_moz_embed_single_get_type())
20829N/A+#define GTK_MOZ_EMBED_SINGLE(obj) GTK_CHECK_CAST((obj), GTK_TYPE_MOZ_EMBED_SINGLE, GtkMozEmbedSingle)
20829N/A+#define GTK_MOZ_EMBED_SINGLE_CLASS(klass) GTK_CHEK_CLASS_CAST((klass), GTK_TYPE_MOZ_EMBED_SINGLE, GtkMozEmbedSingleClass)
20829N/A+#define GTK_IS_MOZ_EMBED_SINGLE(obj) GTK_CHECK_TYPE((obj), GTK_TYPE_MOZ_EMBED_SINGLE)
20829N/A+#define GTK_IS_MOZ_EMBED_SINGLE_CLASS(klass) GTK_CHECK_CLASS_TYPE((klass), GTK_TYPE_MOZ_EMBED)
20829N/A+#define GTK_MOZ_EMBED_SINGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MOZ_EMBED_SINGLE, GtkMozEmbedSingleClass))
20829N/A+typedef struct _GtkMozEmbedSingle GtkMozEmbedSingle;
20829N/A+typedef struct _GtkMozEmbedSingleClass GtkMozEmbedSingleClass;
20829N/A+ void (* new_window_orphan) (GtkMozEmbedSingle *embed,
20829N/A+GTKMOZEMBED_API(GType, gtk_moz_embed_single_get_type, (void))
20829N/A+GTKMOZEMBED_API(GtkMozEmbedSingle *, gtk_moz_embed_single_get, (void))
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Ramiro Estrugo <ramiro@eazel.com>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+// so we can do our get_nsIWebBrowser later...
20829N/A+#define NEW_TOOLKIT_STRING(x) g_strdup(NS_ConvertUTF16toUTF8(x).get())
20829N/A+#define GET_OBJECT_CLASS_TYPE(x) G_OBJECT_CLASS_TYPE(x)
20829N/A+class nsIDirectoryServiceProvider;
20829N/A+// class and instance initialization
20829N/A+gtk_moz_embed_class_init(GtkMozEmbedClass *klass);
20829N/A+gtk_moz_embed_init(GtkMozEmbed *embed);
20829N/A+gtk_moz_embed_destroy(GtkObject *object);
20829N/A+gtk_moz_embed_realize(GtkWidget *widget);
20829N/A+gtk_moz_embed_unrealize(GtkWidget *widget);
20829N/A+gtk_moz_embed_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
20829N/A+gtk_moz_embed_map(GtkWidget *widget);
20829N/A+gtk_moz_embed_unmap(GtkWidget *widget);
20829N/A+static AtkObject* gtk_moz_embed_get_accessible (GtkWidget *widget);
20829N/A+handle_child_focus_in(GtkWidget *aWidget,
20829N/A+ GdkEventFocus *aGdkFocusEvent,
20829N/A+handle_child_focus_out(GtkWidget *aWidget,
20829N/A+ GdkEventFocus *aGdkFocusEvent,
20829N/A+// globals for this type of widget
20829N/A+static GtkBinClass *embed_parent_class;
20829N/A+guint moz_embed_signals[EMBED_LAST_SIGNAL] = { 0 };
20829N/A+// GtkObject + class-related functions
20829N/A+ static GType moz_embed_type = 0;
20829N/A+ (GClassInitFunc)gtk_moz_embed_class_init,
20829N/A+ (GInstanceInitFunc)gtk_moz_embed_init,
20829N/A+ moz_embed_type = g_type_register_static(GTK_TYPE_BIN,
20829N/A+gtk_moz_embed_class_init(GtkMozEmbedClass *klass)
20829N/A+ GtkContainerClass *container_class;
20829N/A+ container_class = GTK_CONTAINER_CLASS(klass);
20829N/A+ widget_class = GTK_WIDGET_CLASS(klass);
20829N/A+ object_class = GTK_OBJECT_CLASS(klass);
20829N/A+ embed_parent_class = (GtkBinClass *)g_type_class_peek(gtk_bin_get_type());
20829N/A+ widget_class->realize = gtk_moz_embed_realize;
20829N/A+ widget_class->unrealize = gtk_moz_embed_unrealize;
20829N/A+ widget_class->size_allocate = gtk_moz_embed_size_allocate;
20829N/A+ widget_class->map = gtk_moz_embed_map;
20829N/A+ widget_class->unmap = gtk_moz_embed_unmap;
20829N/A+ widget_class->get_accessible = gtk_moz_embed_get_accessible;
20829N/A+ object_class->destroy = gtk_moz_embed_destroy;
20829N/A+ moz_embed_signals[LINK_MESSAGE] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, link_message),
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ moz_embed_signals[JS_STATUS] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, js_status),
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, location),
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, title),
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, progress),
20829N/A+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
20829N/A+ moz_embed_signals[PROGRESS_ALL] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, progress_all),
20829N/A+ gtkmozembed_VOID__STRING_INT_INT,
20829N/A+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
20829N/A+ moz_embed_signals[NET_STATE] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, net_state),
20829N/A+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_UINT);
20829N/A+ moz_embed_signals[NET_STATE_ALL] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, net_state_all),
20829N/A+ gtkmozembed_VOID__STRING_INT_UINT,
20829N/A+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
20829N/A+ moz_embed_signals[NET_START] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, net_start),
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, net_stop),
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ moz_embed_signals[NEW_WINDOW] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, new_window),
20829N/A+ gtkmozembed_VOID__POINTER_UINT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
20829N/A+ moz_embed_signals[VISIBILITY] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, visibility),
20829N/A+ g_cclosure_marshal_VOID__BOOLEAN,
20829N/A+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
20829N/A+ moz_embed_signals[DESTROY_BROWSER] =
20829N/A+ g_signal_new("destroy_browser",
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, destroy_brsr),
20829N/A+ g_cclosure_marshal_VOID__VOID,
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, open_uri),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_STRING |
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, size_to),
20829N/A+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
20829N/A+ moz_embed_signals[DOM_KEY_DOWN] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_key_down),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_KEY_PRESS] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_key_press),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_KEY_UP] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_key_up),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_DOWN] =
20829N/A+ g_signal_new("dom_mouse_down",
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_down),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_UP] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_up),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_CLICK] =
20829N/A+ g_signal_new("dom_mouse_click",
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_click),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_DBL_CLICK] =
20829N/A+ g_signal_new("dom_mouse_dbl_click",
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_dbl_click),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_OVER] =
20829N/A+ g_signal_new("dom_mouse_over",
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_over),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_MOUSE_OUT] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_mouse_out),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[SECURITY_CHANGE] =
20829N/A+ g_signal_new("security_change",
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, security_change),
20829N/A+ gtkmozembed_VOID__POINTER_UINT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
20829N/A+ moz_embed_signals[STATUS_CHANGE] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, status_change),
20829N/A+ gtkmozembed_VOID__POINTER_INT_POINTER,
20829N/A+ G_TYPE_POINTER, G_TYPE_INT, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_ACTIVATE] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_activate),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_FOCUS_IN] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_focus_in),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+ moz_embed_signals[DOM_FOCUS_OUT] =
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedClass, dom_focus_out),
20829N/A+ G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
20829N/A+gtk_moz_embed_init(GtkMozEmbed *embed)
20829N/A+ EmbedPrivate *priv = new EmbedPrivate();
20829N/A+ gtk_widget_set_name(GTK_WIDGET(embed), "gtkmozembed");
20829N/A+ GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(embed), GTK_NO_WINDOW);
20829N/A+ return GTK_WIDGET(g_object_new(GTK_TYPE_MOZ_EMBED, NULL));
20829N/A+gtk_moz_embed_destroy(GtkObject *object)
20829N/A+ g_return_if_fail(object != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(object));
20829N/A+ embed = GTK_MOZ_EMBED(object);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ // Destroy the widget only if it's been Init()ed.
20829N/A+ if(embedPrivate->mMozWindowWidget != 0) {
20829N/A+gtk_moz_embed_realize(GtkWidget *widget)
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
20829N/A+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
20829N/A+ widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
20829N/A+ &attributes, attributes_mask);
20829N/A+ gdk_window_set_user_data (widget->window, embed);
20829N/A+ widget->style = gtk_style_attach (widget->style, widget->window);
20829N/A+ gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
20829N/A+ rv = embedPrivate->Init(embed);
20829N/A+ g_return_if_fail(NS_SUCCEEDED(rv));
20829N/A+ PRBool alreadyRealized = PR_FALSE;
20829N/A+ rv = embedPrivate->Realize(&alreadyRealized);
20829N/A+ g_return_if_fail(NS_SUCCEEDED(rv));
20829N/A+ // if we're already realized we don't need to hook up to anything below
20829N/A+ embedPrivate->LoadCurrentURI();
20829N/A+ // connect to the focus out event for the child
20829N/A+ GtkWidget *child_widget = GTK_BIN(widget)->child;
20829N/A+ g_signal_connect_object(G_OBJECT(child_widget),
20829N/A+ G_CALLBACK(handle_child_focus_out),
20829N/A+ g_signal_connect_object(G_OBJECT(child_widget),
20829N/A+ G_CALLBACK(handle_child_focus_in),
20829N/A+gtk_moz_embed_unrealize(GtkWidget *widget)
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ if (GTK_WIDGET_CLASS(embed_parent_class)->unrealize)
20829N/A+ (* GTK_WIDGET_CLASS(embed_parent_class)->unrealize)(widget);
20829N/A+gtk_moz_embed_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ widget->allocation = *allocation;
20829N/A+ if (GTK_WIDGET_REALIZED(widget))
20829N/A+ gdk_window_move_resize(widget->window,
20829N/A+ allocation->width, allocation->height);
20829N/A+ embedPrivate->Resize(allocation->width, allocation->height);
20829N/A+gtk_moz_embed_map(GtkWidget *widget)
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED);
20829N/A+ gdk_window_show(widget->window);
20829N/A+gtk_moz_embed_unmap(GtkWidget *widget)
20829N/A+ g_return_if_fail(widget != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(widget));
20829N/A+ embed = GTK_MOZ_EMBED(widget);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ GTK_WIDGET_UNSET_FLAGS(widget, GTK_MAPPED);
20829N/A+ gdk_window_hide(widget->window);
20829N/A+gtk_moz_embed_get_accessible (GtkWidget *widget)
20829N/A+ g_return_val_if_fail(widget != NULL, NULL);
20829N/A+ g_return_val_if_fail(GTK_IS_MOZ_EMBED(widget), NULL);
20829N/A+ GtkMozEmbed *embed = GTK_MOZ_EMBED(widget);;
20829N/A+ EmbedPrivate *embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ return static_cast<AtkObject *>(
20829N/A+ embedPrivate->GetAtkObjectForCurrentDocument());
20829N/A+#endif /* MOZ_ACCESSIBILITY_ATK */
20829N/A+handle_child_focus_in(GtkWidget *aWidget,
20829N/A+ GdkEventFocus *aGdkFocusEvent,
20829N/A+ embedPrivate = (EmbedPrivate *)aEmbed->data;
20829N/A+handle_child_focus_out(GtkWidget *aWidget,
20829N/A+ GdkEventFocus *aGdkFocusEvent,
20829N/A+ embedPrivate = (EmbedPrivate *)aEmbed->data;
20829N/A+ embedPrivate->ChildFocusOut();
20829N/A+gtk_moz_embed_push_startup(void)
20829N/A+gtk_moz_embed_pop_startup(void)
20829N/A+gtk_moz_embed_set_path(const char *aPath)
20829N/A+gtk_moz_embed_set_comp_path(const char *aPath)
20829N/A+ EmbedPrivate::SetCompPath(aPath);
20829N/A+gtk_moz_embed_set_profile_path(const char *aDir, const char *aName)
20829N/A+ EmbedPrivate::SetProfilePath(aDir, aName);
20829N/A+gtk_moz_embed_set_directory_service_provider(nsIDirectoryServiceProvider *appFileLocProvider) {
20829N/A+ EmbedPrivate::SetDirectoryServiceProvider(appFileLocProvider);
20829N/A+gtk_moz_embed_load_url(GtkMozEmbed *embed, const char *url)
20829N/A+ g_return_if_fail(embed != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(embed));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ // If the widget is realized, load the URI. If it isn't then we
20829N/A+ if (GTK_WIDGET_REALIZED(embed))
20829N/A+ embedPrivate->LoadCurrentURI();
20829N/A+gtk_moz_embed_stop_load(GtkMozEmbed *embed)
20829N/A+ g_return_if_fail(embed != NULL);
20829N/A+ g_return_if_fail(GTK_IS_MOZ_EMBED(embed));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->Stop(nsIWebNavigation::STOP_ALL);
20829N/A+gtk_moz_embed_can_go_back(GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), FALSE);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), FALSE);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->GetCanGoBack(&retval);
20829N/A+gtk_moz_embed_can_go_forward(GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), FALSE);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), FALSE);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->GetCanGoForward(&retval);
20829N/A+gtk_moz_embed_go_back(GtkMozEmbed *embed)
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->GoBack();
20829N/A+gtk_moz_embed_go_forward(GtkMozEmbed *embed)
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ if (embedPrivate->mNavigation)
20829N/A+ embedPrivate->mNavigation->GoForward();
20829N/A+gtk_moz_embed_render_data(GtkMozEmbed *embed, const char *data,
20829N/A+ guint32 len, const char *base_uri,
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ embedPrivate->OpenStream(base_uri, mime_type);
20829N/A+ embedPrivate->AppendToStream((const PRUint8*)data, len);
20829N/A+gtk_moz_embed_open_stream(GtkMozEmbed *embed, const char *base_uri,
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ g_return_if_fail (GTK_WIDGET_REALIZED(GTK_WIDGET(embed)));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ embedPrivate->OpenStream(base_uri, mime_type);
20829N/A+void gtk_moz_embed_append_data(GtkMozEmbed *embed, const char *data,
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ g_return_if_fail (GTK_WIDGET_REALIZED(GTK_WIDGET(embed)));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ embedPrivate->AppendToStream((const PRUint8*)data, len);
20829N/A+gtk_moz_embed_close_stream(GtkMozEmbed *embed)
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ g_return_if_fail (GTK_WIDGET_REALIZED(GTK_WIDGET(embed)));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+gtk_moz_embed_get_link_message(GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), (char *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (char *)NULL);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ retval = NEW_TOOLKIT_STRING(embedPrivate->mWindow->mLinkMessage);
20829N/A+gtk_moz_embed_get_js_status(GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), (char *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (char *)NULL);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ retval = NEW_TOOLKIT_STRING(embedPrivate->mWindow->mJSStatus);
20829N/A+gtk_moz_embed_get_title(GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), (char *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (char *)NULL);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ retval = NEW_TOOLKIT_STRING(embedPrivate->mWindow->mTitle);
20829N/A+gtk_moz_embed_get_location(GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), (char *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (char *)NULL);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+gtk_moz_embed_reload(GtkMozEmbed *embed, gint32 flags)
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ // map the external API to the internal web navigation API.
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADNORMAL:
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE:
20829N/A+ reloadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE;
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXY:
20829N/A+ reloadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE:
20829N/A+ reloadFlags = (nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY |
20829N/A+ nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE);
20829N/A+ case GTK_MOZ_EMBED_FLAG_RELOADCHARSETCHANGE:
20829N/A+ reloadFlags = nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE;
20829N/A+ embedPrivate->Reload(reloadFlags);
20829N/A+gtk_moz_embed_set_chrome_mask(GtkMozEmbed *embed, guint32 flags)
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ embedPrivate->SetChromeMask(flags);
20829N/A+gtk_moz_embed_get_chrome_mask(GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), 0);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), 0);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ return embedPrivate->mChromeMask;
20829N/A+gtk_moz_embed_get_nsIWebBrowser (GtkMozEmbed *embed, nsIWebBrowser **retval)
20829N/A+ g_return_if_fail (embed != NULL);
20829N/A+ g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ embedPrivate->mWindow->GetWebBrowser(retval);
20829N/A+gtk_moz_embed_get_title_unichar (GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), (PRUnichar *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (PRUnichar *)NULL);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ retval = ToNewUnicode(embedPrivate->mWindow->mTitle);
20829N/A+gtk_moz_embed_get_js_status_unichar (GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), (PRUnichar *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (PRUnichar *)NULL);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ retval = ToNewUnicode(embedPrivate->mWindow->mJSStatus);
20829N/A+gtk_moz_embed_get_link_message_unichar (GtkMozEmbed *embed)
20829N/A+ g_return_val_if_fail ((embed != NULL), (PRUnichar *)NULL);
20829N/A+ g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), (PRUnichar *)NULL);
20829N/A+ embedPrivate = (EmbedPrivate *)embed->data;
20829N/A+ retval = ToNewUnicode(embedPrivate->mWindow->mLinkMessage);
20829N/A+// class and instance initialization
20829N/A+gtk_moz_embed_single_class_init(GtkMozEmbedSingleClass *klass);
20829N/A+gtk_moz_embed_single_init(GtkMozEmbedSingle *embed);
20829N/A+gtk_moz_embed_single_new(void);
20829N/A+guint moz_embed_single_signals[SINGLE_LAST_SIGNAL] = { 0 };
20829N/A+// GtkObject + class-related functions
20829N/A+gtk_moz_embed_single_get_type(void)
20829N/A+ static GType moz_embed_single_type = 0;
20829N/A+ if (moz_embed_single_type == 0)
20829N/A+ (GClassInitFunc)gtk_moz_embed_single_class_init,
20829N/A+ (GInstanceInitFunc)gtk_moz_embed_single_init,
20829N/A+ moz_embed_single_type = g_type_register_static(GTK_TYPE_OBJECT,
20829N/A+gtk_moz_embed_single_class_init(GtkMozEmbedSingleClass *klass)
20829N/A+ object_class = GTK_OBJECT_CLASS(klass);
20829N/A+ moz_embed_single_signals[NEW_WINDOW_ORPHAN] =
20829N/A+ g_signal_new("new_window_orphan",
20829N/A+ G_STRUCT_OFFSET(GtkMozEmbedSingleClass, new_window_orphan),
20829N/A+ gtkmozembed_VOID__POINTER_UINT,
20829N/A+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
20829N/A+gtk_moz_embed_single_init(GtkMozEmbedSingle *embed)
20829N/A+ // this is a placeholder for later in case we need to stash data at
20829N/A+ // a later data and maintain backwards compatibility.
20829N/A+ return (GtkMozEmbedSingle *)g_object_new(GTK_TYPE_MOZ_EMBED_SINGLE, NULL);
20829N/A+ static GtkMozEmbedSingle *singleton_object = nsnull;
20829N/A+ singleton_object = gtk_moz_embed_single_new();
20829N/A+// our callback from the window creator service
20829N/A+gtk_moz_embed_single_create_window(GtkMozEmbed **aNewEmbed,
20829N/A+ GtkMozEmbedSingle *single = gtk_moz_embed_single_get();
20829N/A+ g_signal_emit(G_OBJECT(single),
20829N/A+ moz_embed_single_signals[NEW_WINDOW_ORPHAN], 0,
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Original Code is Mozilla embedding.
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Benjamin Smedberg <benjamin@smedbergs.us>.
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2005
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+// This file is an implementation file, meant to be #included in a
20829N/A+// single C++ file of an embedding application. It is called after
20829N/A+// XPCOMGlueStartup to glue the gtkmozembed functions.
20829N/A+#error This file only makes sense when XPCOM_GLUE is defined.
20829N/A+#define GTKMOZEMBED_FUNCTIONS \
20829N/A+ GTKF(gtk_moz_embed_get_type) \
20829N/A+ GTKF(gtk_moz_embed_push_startup) \
20829N/A+ GTKF(gtk_moz_embed_pop_startup) \
20829N/A+ GTKF(gtk_moz_embed_set_path) \
20829N/A+ GTKF(gtk_moz_embed_set_comp_path) \
20829N/A+ GTKF(gtk_moz_embed_set_profile_path) \
20829N/A+ GTKF(gtk_moz_embed_load_url) \
20829N/A+ GTKF(gtk_moz_embed_stop_load) \
20829N/A+ GTKF(gtk_moz_embed_can_go_back) \
20829N/A+ GTKF(gtk_moz_embed_can_go_forward) \
20829N/A+ GTKF(gtk_moz_embed_go_forward) \
20829N/A+ GTKF(gtk_moz_embed_render_data) \
20829N/A+ GTKF(gtk_moz_embed_open_stream) \
20829N/A+ GTKF(gtk_moz_embed_append_data) \
20829N/A+ GTKF(gtk_moz_embed_close_stream) \
20829N/A+ GTKF(gtk_moz_embed_get_link_message) \
20829N/A+ GTKF(gtk_moz_embed_get_js_status) \
20829N/A+ GTKF(gtk_moz_embed_get_title) \
20829N/A+ GTKF(gtk_moz_embed_get_location) \
20829N/A+ GTKF(gtk_moz_embed_set_chrome_mask) \
20829N/A+ GTKF(gtk_moz_embed_get_chrome_mask) \
20829N/A+ GTKF(gtk_moz_embed_single_get_type) \
20829N/A+ GTKF(gtk_moz_embed_single_get)
20829N/A+#define GTKMOZEMBED_FUNCTIONS_INTERNAL \
20829N/A+ GTKF(gtk_moz_embed_get_nsIWebBrowser) \
20829N/A+ GTKF(gtk_moz_embed_get_title_unichar) \
20829N/A+ GTKF(gtk_moz_embed_get_js_status_unichar) \
20829N/A+ GTKF(gtk_moz_embed_get_link_message_unichar) \
20829N/A+ GTKF(gtk_moz_embed_set_directory_service_provider)
20829N/A+#define GTKF(fname) fname##Type fname;
20829N/A+#define GTKF(fname) { #fname, (NSFuncPtr*) &fname },
20829N/A+static const nsDynamicFunctionLoad GtkSymbols[] = {
20829N/A+static const nsDynamicFunctionLoad GtkSymbolsInternal[] = {
20829N/A+ return XPCOMGlueLoadXULFunctions(GtkSymbols);
20829N/A+ return XPCOMGlueLoadXULFunctions(GtkSymbolsInternal);
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+ gtk_moz_embed_get_nsIWebBrowser, (GtkMozEmbed *embed,
20829N/A+ gtk_moz_embed_get_title_unichar, (GtkMozEmbed *embed))
20829N/A+ gtk_moz_embed_get_js_status_unichar, (GtkMozEmbed *embed))
20829N/A+ gtk_moz_embed_get_link_message_unichar, (GtkMozEmbed *embed))
20829N/A+ gtk_moz_embed_set_directory_service_provider, (nsIDirectoryServiceProvider *appFileLocProvider))
20829N/A+#endif /* gtkmozembed_internal_h */
20829N/A+BOOL:STRING,STRING,POINTER,POINTER,STRING,POINTER
20829N/A+BOOL:STRING,STRING,POINTER,STRING,POINTER
20829N/A+BOOL:STRING,STRING,STRING,POINTER
20829N/A+INT:STRING,STRING,INT,INT,INT,INT
20829N/A+INT:STRING,STRING,UINT,STRING,STRING,STRING,STRING,POINTER
20829N/A+VOID:POINTER,INT,STRING,STRING,STRING,STRING,STRING,BOOLEAN,INT
20829N/A+VOID:STRING,STRING,STRING,ULONG,INT
20829N/A+VOID:STRING,STRING,STRING,POINTER
20829N/A+VOID:UINT,INT,INT,STRING,STRING,STRING,STRING
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+extern guint moz_embed_signals[EMBED_LAST_SIGNAL];
20829N/A+extern void gtk_moz_embed_single_create_window(GtkMozEmbed **aNewEmbed,
20829N/A+#endif /* gtkmozembedprivate_h */
20829N/A+# ***** BEGIN LICENSE BLOCK *****
20829N/A+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+# The contents of this file are subject to the Mozilla Public License Version
20829N/A+# 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+# the License. You may obtain a copy of the License at
20829N/A+# Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+# for the specific language governing rights and limitations under the
20829N/A+# The Original Code is the Mozilla browser.
20829N/A+# The Initial Developer of the Original Code is
20829N/A+# Portions created by the Initial Developer are Copyright (C) 1999
20829N/A+# the Initial Developer. All Rights Reserved.
20829N/A+# Christopher Blizzard <blizzard@mozilla.org>
20829N/A+# Alternatively, the contents of this file may be used under the terms of
20829N/A+# either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+# in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+# of those above. If you wish to allow use of your version of this file only
20829N/A+# under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+# use your version of this file under the terms of the MPL, indicate your
20829N/A+# decision by deleting the provisions above and replace them with the notice
20829N/A+# and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+# the provisions above, a recipient may use your version of this file under
20829N/A+# the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+# ***** END LICENSE BLOCK *****
20829N/A+SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=)
20829N/A+LIBS += $(XPCOM_STANDALONE_GLUE_LDOPTS)
20829N/A+CXXFLAGS += `gnome-config --cflags gnomeui`
20829N/A+EXTRA_LIBS += `gnome-config --libs gnomeui`
20829N/A+# When using Sun's WorkShop compiler, including
20829N/A+# causes most of these compiles to fail with:
20829N/A+# line 29: Error: Multiple declaration for std::tm.
20829N/A+# So, this gets around the problem.
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+typedef struct _TestGtkBrowser {
20829N/A+ GtkWidget *fileOpenNewBrowser;
20829N/A+// the list of browser windows currently open
20829N/A+GList *browser_list = g_list_alloc();
20829N/A+static TestGtkBrowser *new_gtk_browser (guint32 chromeMask);
20829N/A+static void set_browser_visibility (TestGtkBrowser *browser,
20829N/A+static void back_clicked_cb (GtkButton *button,
20829N/A+static void stop_clicked_cb (GtkButton *button,
20829N/A+static void forward_clicked_cb (GtkButton *button,
20829N/A+static void reload_clicked_cb (GtkButton *button,
20829N/A+static void url_activate_cb (GtkEditable *widget,
20829N/A+static void menu_open_new_cb (GtkMenuItem *menuitem,
20829N/A+static void menu_stream_cb (GtkMenuItem *menuitem,
20829N/A+static void menu_memory_cb (GtkMenuItem *menuitem,
20829N/A+static void menu_close_cb (GtkMenuItem *menuitem,
20829N/A+static void menu_quit_cb (GtkMenuItem *menuitem,
20829N/A+static gboolean delete_cb (GtkWidget *widget, GdkEventAny *event,
20829N/A+static void destroy_cb (GtkWidget *widget,
20829N/A+static void location_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void title_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void load_started_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void load_finished_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void net_state_change_cb (GtkMozEmbed *embed, gint flags,
20829N/A+ guint status, TestGtkBrowser *browser);
20829N/A+static void net_state_change_all_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+static void progress_change_cb (GtkMozEmbed *embed, gint cur, gint max,
20829N/A+static void progress_change_all_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+static void link_message_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void js_status_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static void new_window_cb (GtkMozEmbed *embed,
20829N/A+ GtkMozEmbed **retval, guint chromemask,
20829N/A+static void visibility_cb (GtkMozEmbed *embed,
20829N/A+static void destroy_brsr_cb (GtkMozEmbed *embed, TestGtkBrowser *browser);
20829N/A+static gint open_uri_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+static void size_to_cb (GtkMozEmbed *embed, gint width,
20829N/A+ gint height, TestGtkBrowser *browser);
20829N/A+static gint dom_key_down_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+static gint dom_key_press_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+static gint dom_key_up_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+static gint dom_mouse_down_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+static gint dom_mouse_up_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+static gint dom_mouse_click_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+static gint dom_mouse_dbl_click_cb (GtkMozEmbed *embed,
20829N/A+static gint dom_mouse_over_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+static gint dom_mouse_out_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+static gint dom_activate_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+static gint dom_focus_in_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+static gint dom_focus_out_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+// callbacks from the singleton object
20829N/A+static void new_window_orphan_cb (GtkMozEmbedSingle *embed,
20829N/A+ GtkMozEmbed **retval, guint chromemask,
20829N/A+static void update_status_bar_text (TestGtkBrowser *browser);
20829N/A+static void update_temp_message (TestGtkBrowser *browser,
20829N/A+static void update_nav_buttons (TestGtkBrowser *browser);
20829N/A+ static const GREVersionRange greVersion = {
20829N/A+ nsresult rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
20829N/A+ xpcomPath, sizeof(xpcomPath));
20829N/A+ fprintf(stderr, "Couldn't find a compatible GRE.\n");
20829N/A+ rv = XPCOMGlueStartup(xpcomPath);
20829N/A+ fprintf(stderr, "Couldn't start XPCOM.");
20829N/A+ fprintf(stderr, "Couldn't find GTKMozEmbed symbols.");
20829N/A+ char *lastSlash = strrchr(xpcomPath, '/');
20829N/A+ gtk_moz_embed_set_path(xpcomPath);
20829N/A+ fprintf(stderr, "Failed to get HOME\n");
20829N/A+ full_path = g_strdup_printf("%s/%s", home_path, ".TestGtkEmbed");
20829N/A+ gtk_moz_embed_set_profile_path(full_path, "TestGtkEmbed");
20829N/A+ TestGtkBrowser *browser = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
20829N/A+ gtk_widget_set_size_request(browser->mozEmbed, 400, 400);
20829N/A+ set_browser_visibility(browser, TRUE);
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), argv[1]);
20829N/A+ // get the singleton object and hook up to its new window callback
20829N/A+ // so we can create orphaned windows.
20829N/A+ single = gtk_moz_embed_single_get();
20829N/A+ fprintf(stderr, "Failed to get singleton embed object!\n");
20829N/A+ g_signal_connect(GTK_OBJECT(single), "new_window_orphan",
20829N/A+ G_CALLBACK(new_window_orphan_cb), NULL);
20829N/A+new_gtk_browser(guint32 chromeMask)
20829N/A+ guint32 actualChromeMask = chromeMask;
20829N/A+ browser = g_new0(TestGtkBrowser, 1);
20829N/A+ browser_list = g_list_prepend(browser_list, browser);
20829N/A+ browser->locationBarOn = FALSE;
20829N/A+ if (chromeMask == GTK_MOZ_EMBED_FLAG_DEFAULTCHROME)
20829N/A+ actualChromeMask = GTK_MOZ_EMBED_FLAG_ALLCHROME;
20829N/A+ if (actualChromeMask & GTK_MOZ_EMBED_FLAG_MENUBARON)
20829N/A+ if (actualChromeMask & GTK_MOZ_EMBED_FLAG_TOOLBARON)
20829N/A+ if (actualChromeMask & GTK_MOZ_EMBED_FLAG_LOCATIONBARON)
20829N/A+ browser->locationBarOn = TRUE;
20829N/A+ if (actualChromeMask & GTK_MOZ_EMBED_FLAG_STATUSBARON)
20829N/A+ // create our new toplevel window
20829N/A+ browser->topLevelWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20829N/A+ browser->topLevelVBox = gtk_vbox_new(FALSE, 0);
20829N/A+ // add it to the toplevel window
20829N/A+ gtk_container_add(GTK_CONTAINER(browser->topLevelWindow),
20829N/A+ browser->menuBar = gtk_menu_bar_new();
20829N/A+ browser->fileMenuItem = gtk_menu_item_new_with_label("File");
20829N/A+ browser->fileMenu = gtk_menu_new();
20829N/A+ gtk_menu_item_set_submenu (GTK_MENU_ITEM(browser->fileMenuItem),
20829N/A+ gtk_menu_item_new_with_label("Open New Browser");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ gtk_menu_item_new_with_label("Test Stream");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ gtk_menu_item_new_with_label("Release Memory");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ gtk_menu_item_new_with_label("Close");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ gtk_menu_item_new_with_label("Quit");
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(browser->fileMenu),
20829N/A+ gtk_menu_shell_append((GtkMenuShell *)GTK_MENU_BAR(browser->menuBar),
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->topLevelVBox),
20829N/A+ // create the hbox that will contain the toolbar and the url text entry bar
20829N/A+ browser->toolbarHBox = gtk_hbox_new(FALSE, 0);
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->topLevelVBox),
20829N/A+ // new horiz toolbar with buttons + icons
20829N/A+ browser->toolbar = gtk_toolbar_new();
20829N/A+ gtk_toolbar_set_orientation(GTK_TOOLBAR(browser->toolbar),
20829N/A+ gtk_toolbar_set_style(GTK_TOOLBAR(browser->toolbar),
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->toolbarHBox), browser->toolbar,
20829N/A+ gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar),
20829N/A+ gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar),
20829N/A+ gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar),
20829N/A+ G_CALLBACK(forward_clicked_cb),
20829N/A+ gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar),
20829N/A+ G_CALLBACK(reload_clicked_cb),
20829N/A+ browser->urlEntry = gtk_entry_new();
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->toolbarHBox), browser->urlEntry,
20829N/A+ // create our new gtk moz embed widget
20829N/A+ browser->mozEmbed = gtk_moz_embed_new();
20829N/A+ // add it to the toplevel vbox
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->mozEmbed,
20829N/A+ // create the new hbox for the progress area
20829N/A+ browser->progressAreaHBox = gtk_hbox_new(FALSE, 0);
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->progressAreaHBox,
20829N/A+ // create our new progress bar
20829N/A+ browser->progressBar = gtk_progress_bar_new();
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->progressAreaHBox), browser->progressBar,
20829N/A+ // create our status area and the alignment object that will keep it
20829N/A+ browser->statusAlign = gtk_alignment_new(0, 0, 1, 1);
20829N/A+ gtk_widget_set_size_request(browser->statusAlign, 1, -1);
20829N/A+ browser->statusBar = gtk_statusbar_new();
20829N/A+ gtk_container_add(GTK_CONTAINER(browser->statusAlign), browser->statusBar);
20829N/A+ gtk_box_pack_start(GTK_BOX(browser->progressAreaHBox), browser->statusAlign,
20829N/A+ // by default none of the buttons are marked as sensitive.
20829N/A+ gtk_widget_set_sensitive(browser->backButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->stopButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->forwardButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->reloadButton, FALSE);
20829N/A+ // catch the destruction of the toplevel window
20829N/A+ g_signal_connect(GTK_OBJECT(browser->topLevelWindow), "delete_event",
20829N/A+ G_CALLBACK(delete_cb), browser);
20829N/A+ // hook up the activate signal to the right callback
20829N/A+ g_signal_connect(GTK_OBJECT(browser->urlEntry), "activate",
20829N/A+ G_CALLBACK(url_activate_cb), browser);
20829N/A+ // hook up to the open new browser activation
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileOpenNewBrowser), "activate",
20829N/A+ G_CALLBACK(menu_open_new_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileStream), "activate",
20829N/A+ G_CALLBACK(menu_stream_cb), browser);
20829N/A+ // hook up the memory pressure release function
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileMemory), "activate",
20829N/A+ G_CALLBACK(menu_memory_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileClose), "activate",
20829N/A+ G_CALLBACK(menu_close_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->fileQuit), "activate",
20829N/A+ G_CALLBACK(menu_quit_cb), browser);
20829N/A+ // hook up the location change to update the urlEntry
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "location",
20829N/A+ G_CALLBACK(location_changed_cb), browser);
20829N/A+ // hook up the title change to update the window title
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "title",
20829N/A+ G_CALLBACK(title_changed_cb), browser);
20829N/A+ // hook up the start and stop signals
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_start",
20829N/A+ G_CALLBACK(load_started_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_stop",
20829N/A+ G_CALLBACK(load_finished_cb), browser);
20829N/A+ // hook up to the change in network status
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_state",
20829N/A+ G_CALLBACK(net_state_change_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_state_all",
20829N/A+ G_CALLBACK(net_state_change_all_cb), browser);
20829N/A+ // hookup to changes in progress
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "progress",
20829N/A+ G_CALLBACK(progress_change_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "progress_all",
20829N/A+ G_CALLBACK(progress_change_all_cb), browser);
20829N/A+ // hookup to changes in over-link message
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "link_message",
20829N/A+ G_CALLBACK(link_message_cb), browser);
20829N/A+ // hookup to changes in js status message
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "js_status",
20829N/A+ G_CALLBACK(js_status_cb), browser);
20829N/A+ // hookup to see whenever a new window is requested
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "new_window",
20829N/A+ G_CALLBACK(new_window_cb), browser);
20829N/A+ // hookup to any requested visibility changes
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "visibility",
20829N/A+ G_CALLBACK(visibility_cb), browser);
20829N/A+ // hookup to the signal that says that the browser requested to be
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "destroy_browser",
20829N/A+ G_CALLBACK(destroy_brsr_cb), browser);
20829N/A+ // hookup to the signal that is called when someone clicks on a link
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "open_uri",
20829N/A+ G_CALLBACK(open_uri_cb), browser);
20829N/A+ // this signal is emitted when there's a request to change the
20829N/A+ // containing browser window to a certain height, like with width
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "size_to",
20829N/A+ G_CALLBACK(size_to_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_down",
20829N/A+ G_CALLBACK(dom_key_down_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_press",
20829N/A+ G_CALLBACK(dom_key_press_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_up",
20829N/A+ G_CALLBACK(dom_key_up_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_down",
20829N/A+ G_CALLBACK(dom_mouse_down_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_up",
20829N/A+ G_CALLBACK(dom_mouse_up_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_click",
20829N/A+ G_CALLBACK(dom_mouse_click_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_dbl_click",
20829N/A+ G_CALLBACK(dom_mouse_dbl_click_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_over",
20829N/A+ G_CALLBACK(dom_mouse_over_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_out",
20829N/A+ G_CALLBACK(dom_mouse_out_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_activate",
20829N/A+ G_CALLBACK(dom_activate_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_focus_in",
20829N/A+ G_CALLBACK(dom_focus_in_cb), browser);
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_focus_out",
20829N/A+ G_CALLBACK(dom_focus_out_cb), browser);
20829N/A+ // hookup to when the window is destroyed
20829N/A+ g_signal_connect(GTK_OBJECT(browser->mozEmbed), "destroy",
20829N/A+ G_CALLBACK(destroy_cb), browser);
20829N/A+ // set the chrome type so it's stored in the object
20829N/A+ gtk_moz_embed_set_chrome_mask(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+set_browser_visibility (TestGtkBrowser *browser, gboolean visibility)
20829N/A+ gtk_widget_hide(browser->topLevelWindow);
20829N/A+ gtk_widget_show_all(browser->menuBar);
20829N/A+ gtk_widget_hide_all(browser->menuBar);
20829N/A+ // since they are on the same line here...
20829N/A+ if (browser->toolBarOn || browser->locationBarOn)
20829N/A+ gtk_widget_show_all(browser->toolbarHBox);
20829N/A+ gtk_widget_hide_all(browser->toolbarHBox);
20829N/A+ gtk_widget_show_all(browser->progressAreaHBox);
20829N/A+ gtk_widget_hide_all(browser->progressAreaHBox);
20829N/A+ gtk_widget_show(browser->mozEmbed);
20829N/A+ gtk_widget_show(browser->topLevelVBox);
20829N/A+ gtk_widget_show(browser->topLevelWindow);
20829N/A+back_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+ gtk_moz_embed_go_back(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+stop_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+ gtk_moz_embed_stop_load(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+forward_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+ g_print("forward_clicked_cb\n");
20829N/A+ gtk_moz_embed_go_forward(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+reload_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+ g_print("reload_clicked_cb\n");
20829N/A+ GdkModifierType state = (GdkModifierType)0;
20829N/A+ gdk_window_get_pointer(NULL, &x, &y, &state);
20829N/A+ gtk_moz_embed_reload(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE :
20829N/A+ GTK_MOZ_EMBED_FLAG_RELOADNORMAL);
20829N/A+stream_clicked_cb (GtkButton *button, TestGtkBrowser *browser)
20829N/A+ g_print("stream_clicked_cb\n");
20829N/A+ gtk_moz_embed_open_stream(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ gtk_moz_embed_close_stream(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+url_activate_cb (GtkEditable *widget, TestGtkBrowser *browser)
20829N/A+ gchar *text = gtk_editable_get_chars(widget, 0, -1);
20829N/A+ g_print("loading url %s\n", text);
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), text);
20829N/A+menu_open_new_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+ g_print("opening new browser.\n");
20829N/A+ new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
20829N/A+ gtk_widget_set_size_request(newBrowser->mozEmbed, 400, 400);
20829N/A+ set_browser_visibility(newBrowser, TRUE);
20829N/A+menu_stream_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+ g_print("stream_clicked_cb\n");
20829N/A+ gtk_moz_embed_open_stream(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),
20829N/A+ gtk_moz_embed_close_stream(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+menu_memory_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+ // Compact like you mean it. We do this three times to give the
20829N/A+ // cycle collector a chance to try and reclaim as much as we can.
20829N/A+ os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
20829N/A+ os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
20829N/A+ os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("heap-minimize").get());
20829N/A+menu_close_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+ gtk_widget_destroy(browser->topLevelWindow);
20829N/A+menu_quit_cb (GtkMenuItem *menuitem, TestGtkBrowser *browser)
20829N/A+ GList *tmp_list = browser_list;
20829N/A+ tmpBrowser = (TestGtkBrowser *)tmp_list->data;
20829N/A+ gtk_widget_destroy(tmpBrowser->topLevelWindow);
20829N/A+ tmpBrowser = (TestGtkBrowser *)tmp_list->data;
20829N/A+delete_cb(GtkWidget *widget, GdkEventAny *event, TestGtkBrowser *browser)
20829N/A+destroy_cb (GtkWidget *widget, TestGtkBrowser *browser)
20829N/A+ tmp_list = g_list_find(browser_list, browser);
20829N/A+ browser_list = g_list_remove_link(browser_list, tmp_list);
20829N/A+location_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+ g_print("location_changed_cb\n");
20829N/A+ newLocation = gtk_moz_embed_get_location(embed);
20829N/A+ gtk_editable_delete_text(GTK_EDITABLE(browser->urlEntry), 0, -1);
20829N/A+ gtk_editable_insert_text(GTK_EDITABLE(browser->urlEntry),
20829N/A+ newLocation, strlen(newLocation), &newPosition);
20829N/A+ g_print("failed to get location!\n");
20829N/A+ // always make sure to clear the tempMessage. it might have been
20829N/A+ // set from the link before a click and we wouldn't have gotten the
20829N/A+ update_temp_message(browser, 0);
20829N/A+ // update the nav buttons on a location change
20829N/A+title_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+ g_print("title_changed_cb\n");
20829N/A+ newTitle = gtk_moz_embed_get_title(embed);
20829N/A+ gtk_window_set_title(GTK_WINDOW(browser->topLevelWindow), newTitle);
20829N/A+load_started_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+ gtk_widget_set_sensitive(browser->stopButton, TRUE);
20829N/A+ gtk_widget_set_sensitive(browser->reloadButton, FALSE);
20829N/A+ update_status_bar_text(browser);
20829N/A+load_finished_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+ g_print("load_finished_cb\n");
20829N/A+ gtk_widget_set_sensitive(browser->stopButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->reloadButton, TRUE);
20829N/A+ update_status_bar_text(browser);
20829N/A+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(browser->progressBar), 0);
20829N/A+net_state_change_cb (GtkMozEmbed *embed, gint flags, guint status,
20829N/A+ g_print("net_state_change_cb %d\n", flags);
20829N/A+ if (flags & GTK_MOZ_EMBED_FLAG_IS_REQUEST) {
20829N/A+ if (flags & GTK_MOZ_EMBED_FLAG_REDIRECTING)
20829N/A+ browser->statusMessage = "Redirecting to site...";
20829N/A+ else if (flags & GTK_MOZ_EMBED_FLAG_TRANSFERRING)
20829N/A+ browser->statusMessage = "Transferring data from site...";
20829N/A+ else if (flags & GTK_MOZ_EMBED_FLAG_NEGOTIATING)
20829N/A+ browser->statusMessage = "Waiting for authorization...";
20829N/A+ if (status == GTK_MOZ_EMBED_STATUS_FAILED_DNS)
20829N/A+ browser->statusMessage = "Site not found.";
20829N/A+ else if (status == GTK_MOZ_EMBED_STATUS_FAILED_CONNECT)
20829N/A+ browser->statusMessage = "Failed to connect to site.";
20829N/A+ else if (status == GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT)
20829N/A+ browser->statusMessage = "Failed due to connection timeout.";
20829N/A+ else if (status == GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED)
20829N/A+ browser->statusMessage = "User canceled connecting to site.";
20829N/A+ if (flags & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT) {
20829N/A+ if (flags & GTK_MOZ_EMBED_FLAG_START)
20829N/A+ browser->statusMessage = "Loading site...";
20829N/A+ else if (flags & GTK_MOZ_EMBED_FLAG_STOP)
20829N/A+ browser->statusMessage = "Done.";
20829N/A+ update_status_bar_text(browser);
20829N/A+void net_state_change_all_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+ // g_print("net_state_change_all_cb %s %d %d\n", uri, flags, status);
20829N/A+void progress_change_cb (GtkMozEmbed *embed, gint cur, gint max,
20829N/A+ g_print("progress_change_cb cur %d max %d\n", cur, max);
20829N/A+ // avoid those pesky divide by zero errors
20829N/A+ update_status_bar_text(browser);
20829N/A+ browser->maxBytesLoaded = max;
20829N/A+ browser->loadPercent = (cur * 100) / max;
20829N/A+ update_status_bar_text(browser);
20829N/A+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(browser->progressBar),
20829N/A+ browser->loadPercent / 100.0);
20829N/A+void progress_change_all_cb (GtkMozEmbed *embed, const char *uri,
20829N/A+ //g_print("progress_change_all_cb %s cur %d max %d\n", uri, cur, max);
20829N/A+link_message_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+ message = gtk_moz_embed_get_link_message(embed);
20829N/A+ update_temp_message(browser, 0);
20829N/A+ update_temp_message(browser, message);
20829N/A+js_status_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+ message = gtk_moz_embed_get_js_status(embed);
20829N/A+ update_temp_message(browser, 0);
20829N/A+ update_temp_message(browser, message);
20829N/A+new_window_cb (GtkMozEmbed *embed, GtkMozEmbed **newEmbed, guint chromemask, TestGtkBrowser *browser)
20829N/A+ g_print("embed is %p chromemask is %d\n", (void *)embed, chromemask);
20829N/A+ TestGtkBrowser *newBrowser = new_gtk_browser(chromemask);
20829N/A+ gtk_widget_set_size_request(newBrowser->mozEmbed, 400, 400);
20829N/A+ *newEmbed = GTK_MOZ_EMBED(newBrowser->mozEmbed);
20829N/A+ g_print("new browser is %p\n", (void *)*newEmbed);
20829N/A+visibility_cb (GtkMozEmbed *embed, gboolean visibility, TestGtkBrowser *browser)
20829N/A+ g_print("visibility_cb %d\n", visibility);
20829N/A+ set_browser_visibility(browser, visibility);
20829N/A+destroy_brsr_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
20829N/A+ gtk_widget_destroy(browser->topLevelWindow);
20829N/A+open_uri_cb (GtkMozEmbed *embed, const char *uri, TestGtkBrowser *browser)
20829N/A+ g_print("open_uri_cb %s\n", uri);
20829N/A+size_to_cb (GtkMozEmbed *embed, gint width, gint height,
20829N/A+ g_print("*** size_to_cb %d %d\n", width, height);
20829N/A+ gtk_widget_set_size_request(browser->mozEmbed, width, height);
20829N/A+gint dom_key_down_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ // g_print("dom_key_down_cb\n");
20829N/A+ // g_print("key code is %d\n", keyCode);
20829N/A+gint dom_key_press_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ // g_print("dom_key_press_cb\n");
20829N/A+ // g_print("char code is %d\n", keyCode);
20829N/A+gint dom_key_up_cb (GtkMozEmbed *embed, nsIDOMKeyEvent *event,
20829N/A+ // g_print("dom_key_up_cb\n");
20829N/A+ // g_print("key code is %d\n", keyCode);
20829N/A+gint dom_mouse_down_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ // g_print("dom_mouse_down_cb\n");
20829N/A+gint dom_mouse_up_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ // g_print("dom_mouse_up_cb\n");
20829N/A+gint dom_mouse_click_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ // g_print("dom_mouse_click_cb\n");
20829N/A+ printf("button was %d\n", button);
20829N/A+gint dom_mouse_dbl_click_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ // g_print("dom_mouse_dbl_click_cb\n");
20829N/A+gint dom_mouse_over_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ //g_print("dom_mouse_over_cb\n");
20829N/A+gint dom_mouse_out_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event,
20829N/A+ //g_print("dom_mouse_out_cb\n");
20829N/A+gint dom_activate_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ //g_print("dom_activate_cb\n");
20829N/A+gint dom_focus_in_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ //g_print("dom_focus_in_cb\n");
20829N/A+gint dom_focus_out_cb (GtkMozEmbed *embed, nsIDOMUIEvent *event,
20829N/A+ //g_print("dom_focus_out_cb\n");
20829N/A+void new_window_orphan_cb (GtkMozEmbedSingle *embed,
20829N/A+ GtkMozEmbed **retval, guint chromemask,
20829N/A+ g_print("new_window_orphan_cb\n");
20829N/A+ g_print("chromemask is %d\n", chromemask);
20829N/A+ TestGtkBrowser *newBrowser = new_gtk_browser(chromemask);
20829N/A+ *retval = GTK_MOZ_EMBED(newBrowser->mozEmbed);
20829N/A+ g_print("new browser is %p\n", (void *)*retval);
20829N/A+update_status_bar_text(TestGtkBrowser *browser)
20829N/A+ gtk_statusbar_pop(GTK_STATUSBAR(browser->statusBar), 1);
20829N/A+ gtk_statusbar_push(GTK_STATUSBAR(browser->statusBar), 1, browser->tempMessage);
20829N/A+ g_snprintf(message, 255, "%s (%d%% complete, %d bytes of %d loaded)", browser->statusMessage, browser->loadPercent, browser->bytesLoaded, browser->maxBytesLoaded);
20829N/A+ else if (browser->bytesLoaded)
20829N/A+ g_snprintf(message, 255, "%s (%d bytes loaded)", browser->statusMessage, browser->bytesLoaded);
20829N/A+ else if (browser->statusMessage == NULL)
20829N/A+ g_snprintf(message, 255, " ");
20829N/A+ g_snprintf(message, 255, "%s", browser->statusMessage);
20829N/A+ gtk_statusbar_push(GTK_STATUSBAR(browser->statusBar), 1, message);
20829N/A+update_temp_message(TestGtkBrowser *browser, const char *message)
20829N/A+ browser->tempMessage = g_strdup(message);
20829N/A+ // now that we've updated the temp message, redraw the status bar
20829N/A+ update_status_bar_text(browser);
20829N/A+update_nav_buttons (TestGtkBrowser *browser)
20829N/A+ can_go_back = gtk_moz_embed_can_go_back(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+ can_go_forward = gtk_moz_embed_can_go_forward(GTK_MOZ_EMBED(browser->mozEmbed));
20829N/A+ gtk_widget_set_sensitive(browser->backButton, TRUE);
20829N/A+ gtk_widget_set_sensitive(browser->backButton, FALSE);
20829N/A+ gtk_widget_set_sensitive(browser->forwardButton, TRUE);
20829N/A+ gtk_widget_set_sensitive(browser->forwardButton, FALSE);
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+int (*old_handler) (Display *, XErrorEvent *);
20829N/A+int error_handler (Display *d, XErrorEvent *e)
20829N/A+ if ((e->error_code == BadWindow) || (e->error_code == BadDrawable))
20829N/A+ XID resourceid = e->resourceid;
20829N/A+ GdkWindow *window = gdk_window_lookup (resourceid);
20829N/A+ if (!g_dataset_get_data (window, "bonobo-error"))
20829N/A+ g_dataset_set_data_full (window, "bonobo-error",
20829N/A+ g_warning ("Error accessing window %ld", resourceid);
20829N/A+ static const GREVersionRange greVersion = {
20829N/A+ nsresult rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
20829N/A+ xpcomPath, sizeof(xpcomPath));
20829N/A+ fprintf(stderr, "Couldn't find a compatible GRE.\n");
20829N/A+ rv = XPCOMGlueStartup(xpcomPath);
20829N/A+ fprintf(stderr, "Couldn't start XPCOM.");
20829N/A+ fprintf(stderr, "Couldn't find GTKMozEmbed symbols.");
20829N/A+ char *lastSlash = strrchr(xpcomPath, '/');
20829N/A+ gtk_moz_embed_set_path(xpcomPath);
20829N/A+ old_handler = XSetErrorHandler (error_handler);
20829N/A+ fprintf(stderr, "Usage: TestGtkEmbedChild WINDOW_ID\n");
20829N/A+ xid = strtol (argv[1], (char **)NULL, 0);
20829N/A+ fprintf(stderr, "Invalid window id '%s'\n", argv[1]);
20829N/A+ g_signal_connect(GTK_OBJECT(window), "destroy",
20829N/A+ G_CALLBACK(gtk_main_quit), NULL);
20829N/A+ gtk_container_set_border_width(GTK_CONTAINER(window), 0);
20829N/A+ vbox = gtk_vbox_new (FALSE, 0);
20829N/A+ gtk_container_add(GTK_CONTAINER(window), vbox);
20829N/A+ hbox = gtk_hbox_new (FALSE, 0);
20829N/A+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
20829N/A+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
20829N/A+ button = gtk_button_new_with_label("Load");
20829N/A+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
20829N/A+ g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(load_page), NULL);
20829N/A+ gtk_box_pack_start(GTK_BOX(vbox), embed, TRUE, TRUE, 0);
20829N/A+ gtk_widget_set_size_request(embed, 200, 200);
20829N/A+ fprintf(stderr, "exiting.\n");
20829N/A+ gchar *text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
20829N/A+ g_print("load url %s\n", text);
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(embed), text);
20829N/A+ * Modified by Kevin Gibbs (kgibbs@stanford.edu) to provide sample of
20829N/A+ * To get a fatal crash, simply run the program, click on the "Mozilla"
20829N/A+ * tab to display the MozEmbed widget, and then try to drag that MDI tab
20829N/A+ * Although this test might seem elaborate, it is really only a convenient
20829N/A+ * to create a situation where the widget is realized, unrealized, and
20829N/A+ * realized again at some point. (Dragging the MDI tab off to a new window
20829N/A+ * causes all widgets to be unrealized in the old window, and then realized
20829N/A+// Define this flag to have the test program use the gtkmozembed widget.
20829N/A+// Without this flag, mozilla is never loaded in the program, and a simple
20829N/A+// widget is used in place of the mozembed widget.
20829N/A+// Define this flag to have a simpler test than the usual one. The normal
20829N/A+// test builds a notebook inside of each MDI view, with one page being a label
20829N/A+// and the other page being a browser widget. The simpler test does not
20829N/A+// build a notebook and simply puts the browser widget in the MDI view itself.
20829N/A+// Currently, this test is not very interesting, since for some reason all
20829N/A+// the webshells just create and destroy themselves. (???)
20829N/A+// Define this flag to use a GnomePixmap instead of a GtkLabel as the
20829N/A+// replacement for the gtkmozembed widget when USE_MOZILLA_TEST is
20829N/A+// undefined. This is to stress test the program a bit more by providing a
20829N/A+// replacement widget slightly more complex than GtkLabel.
20829N/A+// (Has no effect when USE_MOZILLA_TEST is defined.)
20829N/A+gint eventDelete(GtkWidget *widget,
20829N/A+ GdkEvent *event,gpointer data);
20829N/A+gint eventDestroy(GtkWidget *widget,
20829N/A+ GdkEvent *event,gpointer data);
20829N/A+static void addChild(GtkObject *mdi,gchar *name);
20829N/A+static GtkWidget *setLabel(GnomeMDIChild *child,
20829N/A+ GtkWidget *currentLabel,gpointer data);
20829N/A+static GtkWidget *createView(GnomeMDIChild *child,
20829N/A+int main(int argc,char *argv[])
20829N/A+ gnome_init("simplemdi","1.0",argc,argv);
20829N/A+ mdi = gnome_mdi_new("simplemdi","Simple MDI");
20829N/A+ gtk_signal_connect(mdi,"destroy",
20829N/A+ GTK_SIGNAL_FUNC(eventDestroy),NULL);
20829N/A+ gnome_mdi_set_mode(GNOME_MDI(mdi),GNOME_MDI_NOTEBOOK);
20829N/A+ //gnome_mdi_open_toplevel(GNOME_MDI(mdi));
20829N/A+static void addChild(GtkObject *mdi,gchar *name)
20829N/A+ child = gnome_mdi_generic_child_new(name);
20829N/A+ gnome_mdi_add_child(GNOME_MDI(mdi),
20829N/A+ gnome_mdi_generic_child_set_view_creator(child,
20829N/A+ gnome_mdi_generic_child_set_label_func(child,setLabel,
20829N/A+ gnome_mdi_add_view(GNOME_MDI(mdi),
20829N/A+static GtkWidget *createView(GnomeMDIChild *child,
20829N/A+ GtkWidget *browser = gtk_moz_embed_new();
20829N/A+ GtkWidget *browser = gtk_label_new("lynx 0.01a");
20829N/A+ GtkWidget *notebook = gtk_notebook_new();
20829N/A+ sprintf(str,"View of the\n%s widget",(gchar *)data);
20829N/A+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), gtk_label_new(str),
20829N/A+ gtk_notebook_append_page(GTK_NOTEBOOK(notebook), browser,
20829N/A+ gtk_widget_show_all(notebook);
20829N/A+static GtkWidget *setLabel(GnomeMDIChild *child,
20829N/A+ GtkWidget *currentLabel,gpointer data)
20829N/A+ return(gtk_label_new(child->name));
20829N/A+ gtk_label_set_text(GTK_LABEL(currentLabel),
20829N/A+gint eventDestroy(GtkWidget *widget,
20829N/A+ GdkEvent *event,gpointer data) {
20829N/A+int main(int argc, char *argv[])
20829N/A+ static const GREVersionRange greVersion = {
20829N/A+ GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
20829N/A+ xpcomPath, sizeof(xpcomPath));
20829N/A+ fprintf(stderr, "Couldn't find a compatible GRE.\n");
20829N/A+ rv = XPCOMGlueStartup(xpcomPath);
20829N/A+ fprintf(stderr, "Couldn't start XPCOM.");
20829N/A+ fprintf(stderr, "Couldn't find GTKMozEmbed symbols.");
20829N/A+ char *lastSlash = strrchr(xpcomPath, '/');
20829N/A+ gtk_moz_embed_set_path(xpcomPath);
20829N/A+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20829N/A+ container = gtk_notebook_new();
20829N/A+ mozembed = gtk_moz_embed_new();
20829N/A+ label = gtk_label_new("Can you see this message?\n"
20829N/A+ "Once you switch to mozembed page "
20829N/A+ "you never see this message.");
20829N/A+ g_signal_connect(GTK_OBJECT(mozembed), "destroy",
20829N/A+ gtk_container_add(GTK_CONTAINER(window), container);
20829N/A+ gtk_notebook_append_page(GTK_NOTEBOOK(container),
20829N/A+ gtk_notebook_append_page(GTK_NOTEBOOK(container),
20829N/A+ gtk_widget_set_size_request(window, 400, 300);
20829N/A+ url = (argc > 1) ? argv[1] : (char *)"localhost";
20829N/A+ gtk_moz_embed_load_url(GTK_MOZ_EMBED(mozembed), url);
20829N/A+/* ***** BEGIN LICENSE BLOCK *****
20829N/A+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
20829N/A+ * The contents of this file are subject to the Mozilla Public License Version
20829N/A+ * 1.1 (the "License"); you may not use this file except in compliance with
20829N/A+ * the License. You may obtain a copy of the License at
20829N/A+ * Software distributed under the License is distributed on an "AS IS" basis,
20829N/A+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
20829N/A+ * for the specific language governing rights and limitations under the
20829N/A+ * The Initial Developer of the Original Code is
20829N/A+ * Portions created by the Initial Developer are Copyright (C) 2001
20829N/A+ * the Initial Developer. All Rights Reserved.
20829N/A+ * Christopher Blizzard <blizzard@mozilla.org>
20829N/A+ * Alternatively, the contents of this file may be used under the terms of
20829N/A+ * either the GNU General Public License Version 2 or later (the "GPL"), or
20829N/A+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20829N/A+ * in which case the provisions of the GPL or the LGPL are applicable instead
20829N/A+ * of those above. If you wish to allow use of your version of this file only
20829N/A+ * under the terms of either the GPL or the LGPL, and not to allow others to
20829N/A+ * use your version of this file under the terms of the MPL, indicate your
20829N/A+ * decision by deleting the provisions above and replace them with the notice
20829N/A+ * and other provisions required by the GPL or the LGPL. If you do not delete
20829N/A+ * the provisions above, a recipient may use your version of this file under
20829N/A+ * the terms of any one of the MPL, the GPL or the LGPL.
20829N/A+ * ***** END LICENSE BLOCK ***** */
20829N/A+GtkWidget *toplevel_window = 0;
20829N/A+ toplevel_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
20829N/A+ g_signal_connect(GTK_OBJECT(toplevel_window), "destroy",
20829N/A+ vbox = gtk_vbox_new(FALSE, 0);
20829N/A+ gtk_container_add(GTK_CONTAINER(toplevel_window), vbox);
20829N/A+ button = gtk_button_new_with_label("Insert Mozilla");
20829N/A+ gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
20829N/A+ g_signal_connect(GTK_OBJECT(button), "clicked",
20829N/A+ G_CALLBACK(insert_mozilla), NULL);
20829N/A+ gtk_widget_show(toplevel_window);
20829N/A+ gtk_socket = gtk_socket_new();
20829N/A+ gtk_box_pack_start(GTK_BOX(vbox), gtk_socket, TRUE, TRUE, 0);
20829N/A+ sprintf(buffer, "%#lx", GDK_WINDOW_XWINDOW(gtk_socket->window));
20829N/A+ if ((pid = fork()) == 0) { /* child */
20829N/A+ execl("./TestGtkEmbedChild", "./TestGtkEmbedChild", buffer, NULL);
20829N/A+ fprintf(stderr, "can't exec child\n");
20829N/A+ else if (pid > 0) { /* parent */
20829N/A+ fprintf(stderr, "Can't fork.\n");
20829N/A@@ -547,16 +547,19 @@ MAKEFILES_embedding="
20829N/A tier_platform_dirs += startupcache