aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-07-04 18:24:19 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2013-02-18 17:36:24 +0800
commit5544d966f5bae2b479f59375d5b48c2a3e07a319 (patch)
tree26024fca94e3e6024583031f7628c06936445284
parent99dfb8567ee8a04b7c65e46b02a8417fd66e2fdd (diff)
downloadgsoc2013-epiphany-5544d966f5bae2b479f59375d5b48c2a3e07a319.tar
gsoc2013-epiphany-5544d966f5bae2b479f59375d5b48c2a3e07a319.tar.gz
gsoc2013-epiphany-5544d966f5bae2b479f59375d5b48c2a3e07a319.tar.bz2
gsoc2013-epiphany-5544d966f5bae2b479f59375d5b48c2a3e07a319.tar.lz
gsoc2013-epiphany-5544d966f5bae2b479f59375d5b48c2a3e07a319.tar.xz
gsoc2013-epiphany-5544d966f5bae2b479f59375d5b48c2a3e07a319.tar.zst
gsoc2013-epiphany-5544d966f5bae2b479f59375d5b48c2a3e07a319.zip
popup-commands: Postpone the creation of the download object until destination is known
In WebKit2 downloads automatically start when an uri is requested to be downloaded. Instead of creating a download that is cancelled if the destination dialog is cancelled, we can simply create the download when the destination dialog has been accepted. https://bugzilla.gnome.org/show_bug.cgi?id=685950
-rw-r--r--src/popup-commands.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 0380e86d4..1a1d973a5 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -214,20 +214,40 @@ popup_cmd_copy_link_address (GtkAction *action,
}
static void
+save_property_url_to_destination (EphyWindow *window,
+ const char *location,
+ const char *destination)
+{
+ EphyDownload *download;
+
+ download = ephy_download_new_for_uri (location, GTK_WINDOW (window));
+
+ if (destination)
+ ephy_download_set_destination_uri (download, destination);
+ else
+ ephy_download_set_auto_destination (download);
+
+ ephy_download_start (download);
+}
+
+static void
response_cb (GtkDialog *dialog,
int response_id,
- EphyDownload *download)
+ char *location)
{
if (response_id == GTK_RESPONSE_ACCEPT)
{
char *uri;
+ GtkWindow *window;
+
+ window = gtk_window_get_transient_for (GTK_WINDOW (dialog));
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- ephy_download_set_destination_uri (download, uri);
- ephy_download_start (download);
+ save_property_url_to_destination (EPHY_WINDOW (window), location, uri);
g_free (uri);
}
+ g_free (location);
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -241,7 +261,6 @@ save_property_url (GtkAction *action,
EphyEmbedEvent *event;
const char *location;
GValue value = { 0, };
- EphyDownload *download;
event = ephy_window_get_context_event (window);
g_return_if_fail (event != NULL);
@@ -249,8 +268,6 @@ save_property_url (GtkAction *action,
ephy_embed_event_get_property (event, property, &value);
location = g_value_get_string (&value);
- download = ephy_download_new_for_uri (location, GTK_WINDOW (window));
-
if (ask_dest)
{
EphyFileChooser *dialog;
@@ -266,18 +283,15 @@ save_property_url (GtkAction *action,
gtk_file_chooser_set_current_name
(GTK_FILE_CHOOSER (dialog), base);
g_signal_connect (dialog, "response",
- G_CALLBACK (response_cb), download);
+ G_CALLBACK (response_cb), g_strdup (location));
gtk_widget_show (GTK_WIDGET (dialog));
g_free (base);
}
else
{
- ephy_download_set_auto_destination (download);
- ephy_download_start (download);
+ save_property_url_to_destination (window, location, NULL);
}
-
- g_value_unset (&value);
}
void