aboutsummaryrefslogtreecommitdiffstats
path: root/embed/webkit/webkit-embed.c
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@src.gnome.org>2009-03-05 07:59:35 +0800
committerGustavo Noronha Silva <gns@src.gnome.org>2009-03-05 07:59:35 +0800
commit42a654901e1cdc2abf20feff9eb1d7128246d6a1 (patch)
treefce1285f78c056de771bc4420ad040c8ec440720 /embed/webkit/webkit-embed.c
parent8f403c6207687e3ecdec6a40bbe16e02a6815bc1 (diff)
downloadgsoc2013-epiphany-42a654901e1cdc2abf20feff9eb1d7128246d6a1.tar
gsoc2013-epiphany-42a654901e1cdc2abf20feff9eb1d7128246d6a1.tar.gz
gsoc2013-epiphany-42a654901e1cdc2abf20feff9eb1d7128246d6a1.tar.bz2
gsoc2013-epiphany-42a654901e1cdc2abf20feff9eb1d7128246d6a1.tar.lz
gsoc2013-epiphany-42a654901e1cdc2abf20feff9eb1d7128246d6a1.tar.xz
gsoc2013-epiphany-42a654901e1cdc2abf20feff9eb1d7128246d6a1.tar.zst
gsoc2013-epiphany-42a654901e1cdc2abf20feff9eb1d7128246d6a1.zip
Basic download functionality for ephy/webkit. This update also removes
the EphyDownload wrapper, which should be no longer needed with the advent of WebKitDownload. http://bugzilla.gnome.org/show_bug.cgi?id=570735 svn path=/trunk/; revision=8848
Diffstat (limited to 'embed/webkit/webkit-embed.c')
-rw-r--r--embed/webkit/webkit-embed.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c
index 31d272cf2..2202ad3f3 100644
--- a/embed/webkit/webkit-embed.c
+++ b/embed/webkit/webkit-embed.c
@@ -22,14 +22,19 @@
#include "config.h"
+#include "downloader-view.h"
#include "ephy-command-manager.h"
#include "ephy-debug.h"
+#include "ephy-file-chooser.h"
#include "ephy-history.h"
+#include "ephy-embed-factory.h"
#include "ephy-embed-shell.h"
#include "ephy-embed-single.h"
+#include "ephy-embed-persist.h"
#include "ephy-string.h"
#include "ephy-embed-event.h"
#include "ephy-embed-utils.h"
+#include "ephy-prefs.h"
#include <webkit/webkit.h>
#include <string.h>
@@ -377,6 +382,57 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view,
return FALSE;
}
+
+static gboolean
+download_requested_cb (WebKitWebView *web_view,
+ WebKitDownload *download,
+ WebKitEmbed *embed)
+{
+ EphyFileChooser *dialog;
+
+ GtkWindow *window;
+
+ gint dialog_result;
+ gboolean handled = FALSE;
+
+ /* Try to get the toplevel window related to the WebView that caused the
+ * download, and use NULL otherwise; we don't want to pass the WebView
+ * or other widget as a parent window.
+ */
+ window = gtk_widget_get_toplevel (GTK_WIDGET(web_view));
+ if (!GTK_WIDGET_TOPLEVEL (window))
+ window = NULL;
+
+ dialog = ephy_file_chooser_new (_("Save"),
+ window ? GTK_WIDGET (window) : NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ CONF_STATE_SAVE_DIR,
+ EPHY_FILE_FILTER_ALL_SUPPORTED);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
+ webkit_download_get_suggested_filename (download));
+
+ dialog_result = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ if (dialog_result == GTK_RESPONSE_ACCEPT)
+ {
+ DownloaderView *dview;
+ char *uri;
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER(dialog));
+ webkit_download_set_destination_uri (download, uri);
+
+ dview = EPHY_DOWNLOADER_VIEW (ephy_embed_shell_get_downloader_view (embed_shell));
+ downloader_view_add_download (dview, download);
+
+ handled = TRUE;
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ return handled;
+}
static void
webkit_embed_init (WebKitEmbed *embed)
@@ -409,6 +465,7 @@ webkit_embed_init (WebKitEmbed *embed)
"signal::load-progress-changed", G_CALLBACK (load_progress_changed_cb), embed,
"signal::hovering-over-link", G_CALLBACK (hovering_over_link_cb), embed,
"signal::mime-type-policy-decision-requested", G_CALLBACK (mime_type_policy_decision_requested_cb), embed,
+ "signal::download-requested", G_CALLBACK (download_requested_cb), embed,
NULL);
g_signal_connect (web_view, "notify::zoom-level",