summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-28 17:40:29 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-28 17:40:29 (EDT)
commit1804f4f321f457622378a5c33f76671d246eaea9 (patch)
tree0349fe027329db66c12d70107a09893c2655e9b7 /src
parentdfe4b34451627184e62e1e297adf78add917a32d (diff)
downloadmarquee-1804f4f321f457622378a5c33f76671d246eaea9.zip
marquee-1804f4f321f457622378a5c33f76671d246eaea9.tar.gz
marquee-1804f4f321f457622378a5c33f76671d246eaea9.tar.bz2
mq_web_view_save(): Clean up title for file name
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",