summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-02-23 08:19:10 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-02-23 08:19:10 +0000
commitec1b92cf2436e15afc8180d40dfdebd39c47b9e3 (patch)
tree9e5d26759587e61964e58e43c3f8527a50dd90ff
parent6878eba2953bc2374425d5931b4c87d27aea213b (diff)
downloadnetsurf-ec1b92cf2436e15afc8180d40dfdebd39c47b9e3.tar.gz
netsurf-ec1b92cf2436e15afc8180d40dfdebd39c47b9e3.tar.bz2
Obtain download filename from the core
svn path=/trunk/netsurf/; revision=11768
-rw-r--r--gtk/download.c27
-rw-r--r--gtk/download.h1
2 files changed, 7 insertions, 21 deletions
diff --git a/gtk/download.c b/gtk/download.c
index 990176a24..d9a3c83ab 100644
--- a/gtk/download.c
+++ b/gtk/download.c
@@ -76,8 +76,8 @@ static void nsgtk_download_change_sensitivity(
static void nsgtk_download_change_status (
struct gui_download_window *dl, nsgtk_download_status status);
-static gchar* nsgtk_download_dialog_show (gchar *filename, gchar *domain,
- const gchar *size);
+static gchar* nsgtk_download_dialog_show (const gchar *filename,
+ const gchar *domain, const gchar *size);
static gchar* nsgtk_download_info_to_string (struct gui_download_window *dl);
static gchar* nsgtk_download_time_to_string (gint seconds);
static gboolean nsgtk_download_handle_error (GError *error);
@@ -203,7 +203,6 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
const char *url = download_context_get_url(ctx);
unsigned long total_size = download_context_get_total_length(ctx);
gchar *domain;
- gchar *filename;
gchar *destination;
gboolean unknown_size = total_size == 0;
const char *size = (total_size == 0 ?
@@ -217,27 +216,18 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
if (download == NULL)
return NULL;
- if (url_nice(url, &filename, false) != URL_FUNC_OK) {
- filename = g_strdup(messages_get("gtkUnknownFile"));
- if (filename == NULL) {
- free(download);
- return NULL;
- }
- }
-
if (url_host(url, &domain) != URL_FUNC_OK) {
domain = g_strdup(messages_get("gtkUnknownHost"));
if (domain == NULL) {
- g_free(filename);
free(download);
return NULL;
}
}
- destination = nsgtk_download_dialog_show(filename, domain, size);
+ destination = nsgtk_download_dialog_show(
+ download_context_get_filename(ctx), domain, size);
if (destination == NULL) {
g_free(domain);
- g_free(filename);
free(download);
return NULL;
}
@@ -252,7 +242,7 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
&nsgtk_download_iter));
download->ctx = ctx;
- download->name = g_string_new(filename);
+ download->name = g_string_new(download_context_get_filename(ctx));
download->time_left = g_string_new("");
download->size_total = total_size;
download->size_downloaded = 0;
@@ -260,7 +250,6 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
download->start_time = g_timer_elapsed(nsgtk_downloads_timer, NULL);
download->time_remaining = -1;
download->status = NSGTK_DOWNLOAD_NONE;
- download->filename = destination;
download->progress = 0;
download->error = NULL;
download->write =
@@ -269,7 +258,6 @@ struct gui_download_window *gui_download_window_create(download_context *ctx,
if (nsgtk_download_handle_error(download->error)) {
g_string_free(download->name, TRUE);
g_string_free(download->time_left, TRUE);
- g_free(download->filename);
free(download);
return NULL;
}
@@ -562,7 +550,6 @@ void nsgtk_download_store_clear_item (struct gui_download_window *dl)
download_context_destroy(dl->ctx);
g_string_free(dl->name, TRUE);
g_string_free(dl->time_left, TRUE);
- g_free(dl->filename);
g_free(dl);
nsgtk_download_sensitivity_evaluate(nsgtk_download_selection);
@@ -582,7 +569,7 @@ void nsgtk_download_store_cancel_item (struct gui_download_window *dl)
download_context_abort(dl->ctx);
- g_unlink(dl->filename);
+ g_unlink(download_context_get_filename(dl->ctx));
nsgtk_download_update(TRUE);
}
@@ -658,7 +645,7 @@ void nsgtk_download_change_status (
}
}
-gchar* nsgtk_download_dialog_show (gchar *filename, gchar *domain,
+gchar* nsgtk_download_dialog_show (const gchar *filename, const gchar *domain,
const gchar *size)
{
enum { GTK_RESPONSE_DOWNLOAD, GTK_RESPONSE_SAVE_AS };
diff --git a/gtk/download.h b/gtk/download.h
index 7e8226ce9..01451b77d 100644
--- a/gtk/download.h
+++ b/gtk/download.h
@@ -63,7 +63,6 @@ struct gui_download_window {
gfloat time_remaining;
gfloat start_time;
gfloat speed;
- gchar *filename;
GtkTreeRowReference *row;
GIOChannel *write;