[epiphany] Delay obtaining suggested filename for dialogs
- From: Gustavo Noronha Silva <gns src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [epiphany] Delay obtaining suggested filename for dialogs
- Date: Wed, 9 Sep 2009 00:08:59 +0000 (UTC)
commit e9d80d39ad48993df7140269ace8ce0cf4ac4585
Author: Gustavo Noronha Silva <gns gnome org>
Date: Tue Sep 8 16:08:26 2009 -0300
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
embed/ephy-embed.c | 46 +++++++++++++++++++++++++++++++++-------------
1 files changed, 33 insertions(+), 13 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 98c6d08..dec2a32 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]