summaryrefslogtreecommitdiff
path: root/browser.c
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2015-12-06 09:53:37 +0100
committerPeter Hofmann <scm@uninformativ.de>2015-12-06 09:53:37 +0100
commit0f0c693a6be637d3f8c4d602a3e690afd4aebf2a (patch)
tree01b8f7abd0ffc5210bdc2c223edfffc52c453b60 /browser.c
parent3fb92e08feee3112d54f7ffb48f75eab64cf6dcd (diff)
downloadlariza-0f0c693a6be637d3f8c4d602a3e690afd4aebf2a.tar.gz
Strip G_DIR_SEPARATOR from local file names
Closes #15.
Diffstat (limited to 'browser.c')
-rw-r--r--browser.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/browser.c b/browser.c
index 4274249..a88e78b 100644
--- a/browser.c
+++ b/browser.c
@@ -394,11 +394,17 @@ download_handle_start(WebKitWebView *web_view, WebKitDownload *download,
gboolean
download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer data)
{
- gchar *path, *path2 = NULL, *uri;
+ gchar *sug_clean, *path, *path2 = NULL, *uri;
GtkToolItem *tb;
int suffix = 1;
+ size_t i;
- path = g_build_filename(download_dir, suggested_filename, NULL);
+ sug_clean = g_strdup(suggested_filename);
+ for (i = 0; i < strlen(sug_clean); i++)
+ if (sug_clean[i] == G_DIR_SEPARATOR)
+ sug_clean[i] = '_';
+
+ path = g_build_filename(download_dir, sug_clean, NULL);
path2 = g_strdup(path);
while (g_file_test(path2, G_FILE_TEST_EXISTS) && suffix < 1000)
{
@@ -421,7 +427,7 @@ download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer da
tb = gtk_tool_button_new(NULL, NULL);
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(tb), "gtk-delete");
- gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), suggested_filename);
+ gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), sug_clean);
gtk_toolbar_insert(GTK_TOOLBAR(dm.toolbar), tb, 0);
gtk_widget_show_all(dm.win);
@@ -433,6 +439,7 @@ download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer da
G_CALLBACK(downloadmanager_cancel), download);
}
+ g_free(sug_clean);
g_free(path);
g_free(path2);