[epiphany] popup-commands: Postpone the creation of the download object until destination is known
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] popup-commands: Postpone the creation of the download object until destination is known
- Date: Mon, 18 Feb 2013 09:37:11 +0000 (UTC)
commit 5544d966f5bae2b479f59375d5b48c2a3e07a319
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Wed Jul 4 12:24:19 2012 +0200
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
src/popup-commands.c | 36 +++++++++++++++++++++++++-----------
1 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 0380e86..1a1d973 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]