summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/web-view.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/web-view.c b/src/web-view.c
index 616ca40..a4e8af5 100644
--- a/src/web-view.c
+++ b/src/web-view.c
@@ -838,6 +838,21 @@ save_async_cb(WebKitWebView *web_view, GAsyncResult *result)
webkit_web_view_save_to_file_finish(web_view, result, NULL);
}
+static gchar *
+get_clean_title(MqWebView *web_view)
+{
+ gchar *title;
+
+ title = g_strdup(webkit_web_view_get_title(WEBKIT_WEB_VIEW(web_view)));
+ return g_strdelimit(title,
+#ifdef G_OS_WIN32
+ "/\\:*\"?<>|",
+#else
+ "/",
+#endif
+ '_');
+}
+
static void
save_response_cb(GtkWidget *dialog, gint response_id, MqWebView *web_view)
{
@@ -863,7 +878,7 @@ mq_web_view_save(MqWebView *web_view)
{
GtkWidget *dialog;
GtkFileChooser *chooser;
- const gchar *title;
+ gchar *title;
gchar *filename;
dialog = gtk_file_chooser_dialog_new("Save File",
@@ -875,9 +890,9 @@ mq_web_view_save(MqWebView *web_view)
chooser = GTK_FILE_CHOOSER(dialog);
gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
/* TODO: gtk_file_chooser_set_current_folder() */
- /* TODO: Clean up title for file name. */
- title = webkit_web_view_get_title(WEBKIT_WEB_VIEW(web_view));
+ title = get_clean_title(web_view);
filename = g_strconcat(title, ".mhtml", NULL);
+ g_free(title);
gtk_file_chooser_set_current_name(chooser, filename);
g_free(filename);
g_signal_connect(dialog, "response",