aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-11-14 05:38:40 +0800
committerChristian Persch <chpe@src.gnome.org>2004-11-14 05:38:40 +0800
commit24664b3b9a56643eb383e3db7aa24f7a18bd5979 (patch)
tree4030e0305d3868104eaafceb3d109a34ef8851a8 /embed/mozilla
parent14fb72aeb0cc6a75d7326298607887dbc7d9fdd7 (diff)
downloadgsoc2013-epiphany-24664b3b9a56643eb383e3db7aa24f7a18bd5979.tar
gsoc2013-epiphany-24664b3b9a56643eb383e3db7aa24f7a18bd5979.tar.gz
gsoc2013-epiphany-24664b3b9a56643eb383e3db7aa24f7a18bd5979.tar.bz2
gsoc2013-epiphany-24664b3b9a56643eb383e3db7aa24f7a18bd5979.tar.lz
gsoc2013-epiphany-24664b3b9a56643eb383e3db7aa24f7a18bd5979.tar.xz
gsoc2013-epiphany-24664b3b9a56643eb383e3db7aa24f7a18bd5979.tar.zst
gsoc2013-epiphany-24664b3b9a56643eb383e3db7aa24f7a18bd5979.zip
No need to make the content handler dialogue modal.
2004-11-13 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/ContentHandler.cpp: * embed/mozilla/ContentHandler.h: No need to make the content handler dialogue modal.
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/ContentHandler.cpp107
-rw-r--r--embed/mozilla/ContentHandler.h26
2 files changed, 67 insertions, 66 deletions
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index 59d05bb28..1de4579bd 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -39,6 +39,10 @@
#include <nsIInterfaceRequestorUtils.h>
#include <nsCExternalHandlerService.h>
+#ifdef ALLOW_PRIVATE_API
+#include <nsIServiceManager.h>
+#endif
+
#include "ephy-prefs.h"
#include "ephy-embed-single.h"
#include "ephy-embed-shell.h"
@@ -52,10 +56,6 @@
#include "MozDownload.h"
#include "EphyUtils.h"
-class GContentHandler;
-
-NS_IMPL_ISUPPORTS1(GContentHandler, nsIHelperAppLauncherDialog)
-
#ifdef MOZ_NSIMIMEINFO_NSACSTRING_
GContentHandler::GContentHandler()
{
@@ -73,13 +73,14 @@ GContentHandler::~GContentHandler()
LOG ("GContentHandler dtor (%p)", this)
#ifndef MOZ_NSIMIMEINFO_NSACSTRING_
- nsMemory::Free (mMimeType);
+ if (mMimeType)
+ {
+ nsMemory::Free (mMimeType);
+ }
#endif
}
-////////////////////////////////////////////////////////////////////////////////
-// begin nsIHelperAppLauncher impl
-////////////////////////////////////////////////////////////////////////////////
+NS_IMPL_ISUPPORTS1(GContentHandler, nsIHelperAppLauncherDialog)
/* void show (in nsIHelperAppLauncher aLauncher, in nsISupports aContext); */
NS_IMETHODIMP GContentHandler::Show(nsIHelperAppLauncher *aLauncher,
@@ -106,7 +107,7 @@ NS_IMETHODIMP GContentHandler::Show(nsIHelperAppLauncher *aLauncher,
if (!handled)
{
- MIMEDoAction ();
+ MIMEInitiateAction ();
}
else
{
@@ -146,6 +147,7 @@ NS_IMETHODIMP GContentHandler::PromptForSaveToFile(
EPHY_FILE_FILTER_ALL);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), defaultFile.get());
+ /* FIXME: modal -- mozilla sucks! */
do
{
g_free (filename);
@@ -177,7 +179,7 @@ NS_IMETHODIMP GContentHandler::PromptForSaveToFile(
}
}
-NS_METHOD GContentHandler::LaunchHelperApp (void)
+NS_METHOD GContentHandler::LaunchHelperApp ()
{
nsCOMPtr<nsIExternalHelperAppService> helperService;
@@ -202,31 +204,7 @@ NS_METHOD GContentHandler::LaunchHelperApp (void)
return NS_OK;
}
-NS_METHOD GContentHandler::CheckAppSupportScheme (void)
-{
- GList *l;
-
- mAppSupportScheme = PR_FALSE;
-
- if (!mHelperApp) return NS_OK;
-
- if (mHelperApp->expects_uris != GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS)
- return NS_OK;
-
- for (l = mHelperApp->supported_uri_schemes; l != NULL; l = l->next)
- {
- char *uri_scheme = (char *)l->data;
-
- if (strcmp (mScheme.get(), uri_scheme) == 0)
- {
- mAppSupportScheme = PR_TRUE;
- }
- }
-
- return NS_OK;
-}
-
-NS_METHOD GContentHandler::Init (void)
+NS_METHOD GContentHandler::Init ()
{
nsresult rv;
@@ -253,11 +231,36 @@ NS_METHOD GContentHandler::Init (void)
return NS_OK;
}
+static void
+response_cb (GtkWidget *dialog,
+ int response,
+ GContentHandler *self)
+{
+ gtk_widget_destroy (dialog);
+
+ if (response > 0)
+ {
+ self->mAction = (ContentAction) response;
+ }
+ else
+ {
+ self->mAction = CONTENT_ACTION_NONE;
+ }
+
+ self->MIMEDoAction ();
+}
+
+static void
+release_cb (GContentHandler *data)
+{
+ NS_RELEASE (data);
+}
+
NS_METHOD GContentHandler::MIMEConfirmAction ()
{
GtkWidget *dialog;
const char *action_label, *primary, *secondary;
- int response;
+ //int response;
nsCOMPtr<nsIDOMWindow> parentDOMWindow = do_GetInterface (mContext);
GtkWindow *parentWindow = GTK_WINDOW (EphyUtils::FindGtkParent(parentDOMWindow));
@@ -291,7 +294,7 @@ NS_METHOD GContentHandler::MIMEConfirmAction ()
dialog = gtk_message_dialog_new
(parentWindow,
- GTK_DIALOG_MODAL /* FIXME mozilla sucks */,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
primary);
@@ -310,23 +313,16 @@ NS_METHOD GContentHandler::MIMEConfirmAction ()
gtk_dialog_set_default_response (GTK_DIALOG (dialog), (guint) mAction);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- if (response == GTK_RESPONSE_DELETE_EVENT)
- {
- mAction = CONTENT_ACTION_NONE;
- }
- else
- {
- mAction = (ContentAction)response;
- }
-
- gtk_widget_destroy (dialog);
+ NS_ADDREF (this);
+ g_signal_connect_data (dialog, "response",
+ G_CALLBACK (response_cb), this,
+ (GClosureNotify) release_cb, (GConnectFlags) 0);
+ gtk_window_present (GTK_WINDOW (dialog));
return NS_OK;
}
-NS_METHOD GContentHandler::MIMEDoAction (void)
+NS_METHOD GContentHandler::MIMEInitiateAction (void)
{
gboolean auto_downloads;
@@ -342,8 +338,6 @@ NS_METHOD GContentHandler::MIMEDoAction (void)
mPermission = ephy_embed_shell_check_mime (embed_shell, mMimeType);
#endif
- CheckAppSupportScheme ();
-
if (auto_downloads)
{
mAction = CONTENT_ACTION_OPEN;
@@ -362,7 +356,16 @@ NS_METHOD GContentHandler::MIMEDoAction (void)
{
MIMEConfirmAction ();
}
+ else
+ {
+ MIMEDoAction ();
+ }
+
+ return NS_OK;
+}
+NS_METHOD GContentHandler::MIMEDoAction (void)
+{
nsCOMPtr<nsIMIMEInfo> mimeInfo;
mLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo));
NS_ENSURE_TRUE (mimeInfo, NS_ERROR_FAILURE);
diff --git a/embed/mozilla/ContentHandler.h b/embed/mozilla/ContentHandler.h
index 95ba1aa4d..92612653b 100644
--- a/embed/mozilla/ContentHandler.h
+++ b/embed/mozilla/ContentHandler.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2000-2003 Marco Pesenti Gritti, Xan Lopez
+ * Copyright (C) 2000-2003 Marco Pesenti Gritti,
+ * Copyright (C) 2003 Xan Lopez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,27 +19,25 @@
* $Id$
*/
-#ifndef __ContentHandler_h
-#define __ContentHandler_h
+#ifndef CONTENT_HANDLER_H
+#define CONTENT_HANDLER_H
#include "config.h"
-#include "ephy-embed-shell.h"
-
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#define MOZILLA_STRICT_API
+#include <nsEmbedString.h>
+#undef MOZILLA_STRICT_API
#include <nsCOMPtr.h>
#include <nsISupports.h>
#include <nsIURI.h>
#include <nsIFile.h>
-#define MOZILLA_STRICT_API
-#include <nsEmbedString.h>
-#undef MOZILLA_STRICT_API
#include <nsIHelperAppLauncherDialog.h>
typedef enum
{
- CONTENT_ACTION_OPEN,
+ CONTENT_ACTION_OPEN = 1,
CONTENT_ACTION_OPEN_TMP,
CONTENT_ACTION_DOWNLOAD,
CONTENT_ACTION_SAVEAS,
@@ -62,23 +61,22 @@ class GContentHandler : public nsIHelperAppLauncherDialog
GContentHandler();
virtual ~GContentHandler();
+ NS_METHOD MIMEDoAction ();
+ ContentAction mAction;
private:
NS_METHOD Init ();
NS_METHOD LaunchHelperApp ();
+ NS_METHOD MIMEInitiateAction ();
NS_METHOD MIMEConfirmAction ();
- NS_METHOD MIMEDoAction ();
- NS_METHOD CheckAppSupportScheme ();
nsCOMPtr<nsIHelperAppLauncher> mLauncher;
nsCOMPtr<nsIURI> mUri;
nsCOMPtr<nsIFile> mTempFile;
nsCOMPtr<nsISupports> mContext;
- PRBool mAppSupportScheme;
GnomeVFSMimeApplication *mHelperApp;
- ContentAction mAction;
EphyMimePermission mPermission;
nsEmbedCString mUrl;
@@ -90,4 +88,4 @@ class GContentHandler : public nsIHelperAppLauncherDialog
#endif
};
-#endif /* __ContentHandler_h */
+#endif /* CONTENT_HANDLER_H */