aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@gnome.org>2009-09-09 03:08:26 +0800
committerGustavo Noronha Silva <gns@gnome.org>2009-09-09 08:08:10 +0800
commite9d80d39ad48993df7140269ace8ce0cf4ac4585 (patch)
treeebafe9427a7157189987404b39c0ac25b109390b /embed
parentafec9315ee9295ab6928ebde1c642e81f8a61290 (diff)
downloadgsoc2013-epiphany-e9d80d39ad48993df7140269ace8ce0cf4ac4585.tar.gz
gsoc2013-epiphany-e9d80d39ad48993df7140269ace8ce0cf4ac4585.tar.zst
gsoc2013-epiphany-e9d80d39ad48993df7140269ace8ce0cf4ac4585.zip
Delay obtaining suggested filename for dialogs
Most downloads will only have proper suggested filenames after the request has been sent, and a reply was received, so delay getting the suggested filename to when that has happened. Bug #577797
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 98c6d089c..dec2a3251 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -711,6 +711,34 @@ confirm_action_from_mime (WebKitWebView *web_view,
gtk_window_present (GTK_WINDOW (dialog));
}
+static void
+download_status_changed_cb (GObject *object,
+ GParamSpec *pspec,
+ WebKitWebView *web_view)
+{
+ WebKitDownload *download = WEBKIT_DOWNLOAD (object);
+
+ g_return_if_fail (webkit_download_get_status (download) == WEBKIT_DOWNLOAD_STATUS_STARTED);
+
+ g_signal_handlers_disconnect_by_func (download,
+ download_status_changed_cb,
+ web_view);
+
+ /* Is auto-download enabled? */
+ if (eel_gconf_get_boolean (CONF_AUTO_DOWNLOADS)) {
+ perform_auto_download (download);
+ return;
+ }
+
+ /* FIXME: when we are able to obtain the MIME information from
+ * WebKit, we will want to decide earlier whether we want to open or
+ * open the location to where the file was downloaded. See
+ * perform_auto_download, too.
+ */
+ g_object_ref (download); /* balanced in confirm_action_response_cb */
+ confirm_action_from_mime (web_view, download, DOWNLOAD_ACTION_DOWNLOAD);
+}
+
static gboolean
download_requested_cb (WebKitWebView *web_view,
WebKitDownload *download)
@@ -719,11 +747,11 @@ download_requested_cb (WebKitWebView *web_view,
if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK))
return FALSE;
- /* Is auto-download enabled? */
- if (eel_gconf_get_boolean (CONF_AUTO_DOWNLOADS)) {
- perform_auto_download (download);
- return TRUE;
- }
+ /* Wait for the request to be sent in all cases, so that we have a
+ * response which may contain a suggested filename */
+ g_signal_connect (download, "notify::status",
+ G_CALLBACK (download_status_changed_cb),
+ web_view);
/* If we are not performing an auto-download, we will ask the user
* where they want the file to go to; we will start downloading to a
@@ -732,14 +760,6 @@ download_requested_cb (WebKitWebView *web_view,
if (!define_destination_uri (download, TRUE))
return FALSE;
- /* FIXME: when we are able to obtain the MIME information from
- * WebKit, we will want to decide earlier whether we want to open or
- * open the location to where the file was downloaded. See
- * perform_auto_download, too.
- */
- g_object_ref (download); /* balanced in confirm_action_response_cb */
- confirm_action_from_mime (web_view, download, DOWNLOAD_ACTION_DOWNLOAD);
-
return TRUE;
}