summaryrefslogtreecommitdiff
path: root/browser.c
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2014-06-19 11:46:21 +0200
committerPeter Hofmann <scm@uninformativ.de>2014-06-19 11:46:21 +0200
commit2fa578a22ff730663c00260d33d024302569ba89 (patch)
tree72c2bde62cf7f523f3c90a71f2226b80101e5c23 /browser.c
parent6c3efac43257173ec49e142c3e61d40e47dfd380 (diff)
downloadlariza-2fa578a22ff730663c00260d33d024302569ba89.tar.gz
Download manager: Show the real file name
Diffstat (limited to 'browser.c')
-rw-r--r--browser.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/browser.c b/browser.c
index 33bd32e..07b9240 100644
--- a/browser.c
+++ b/browser.c
@@ -475,12 +475,28 @@ downloadmanager_progress(GObject *obj, GParamSpec *pspec, gpointer data)
WebKitDownload *download = WEBKIT_DOWNLOAD(obj);
GtkToolItem *tb = GTK_TOOL_ITEM(data);
gdouble p;
- gchar *t;
+ const gchar *uri;
+ gchar *t, *filename, *base;
p = webkit_download_get_progress(download) * 100;
- t = g_strdup_printf("%s (%.0f%%)",
- webkit_download_get_suggested_filename(download),
- p);
+
+ uri = webkit_download_get_destination_uri(download);
+ filename = g_filename_from_uri(uri, NULL, NULL);
+ if (filename == NULL)
+ {
+ /* This really should not happen because WebKit uses that URI to
+ * write to a file... */
+ fprintf(stderr, __NAME__": Could not construct file name from URI!\n");
+ t = g_strdup_printf("%s (%.0f%%)",
+ webkit_download_get_suggested_filename(download), p);
+ }
+ else
+ {
+ base = g_path_get_basename(filename);
+ t = g_strdup_printf("%s (%.0f%%)", base, p);
+ g_free(filename);
+ g_free(base);
+ }
gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), t);
g_free(t);
}