diff options
-rw-r--r-- | src/web-view.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/web-view.c b/src/web-view.c index 3f03a49..970cc96 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -39,6 +39,7 @@ struct _MqWebView { MqConfig *config; WebKitHitTestResult *hit_test_result; WebKitHitTestResult *mouse_target_hit_test_result; + GtkComboBox *save_type_combo_box; }; enum { @@ -960,11 +961,20 @@ save_type_changed_cb(GtkComboBox *combo_box, GtkFileChooser *chooser) } static void +save_mhtml(MqWebView *web_view, GFile *file) +{ + webkit_web_view_save_to_file(WEBKIT_WEB_VIEW(web_view), file, + WEBKIT_SAVE_MODE_MHTML, NULL, + (GAsyncReadyCallback) save_async_cb, NULL); +} + +static void save_response_cb(GtkWidget *dialog, gint response_id, MqWebView *web_view) { - gchar *dir; - gchar *filename; - GFile *file; + gchar *dir; + gchar *filename; + GFile *file; + const gchar *active_id; if (response_id == GTK_RESPONSE_ACCEPT) { dir = gtk_file_chooser_get_current_folder( @@ -975,14 +985,21 @@ save_response_cb(GtkWidget *dialog, gint response_id, MqWebView *web_view) g_free(dir); mq_config_save(web_view->config); } + filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog)); file = g_file_new_for_path(filename); g_free(filename); - /* TODO: HTML-only file format? */ - webkit_web_view_save_to_file(WEBKIT_WEB_VIEW(web_view), file, - WEBKIT_SAVE_MODE_MHTML, NULL, - (GAsyncReadyCallback) save_async_cb, NULL); + + active_id = gtk_combo_box_get_active_id( + web_view->save_type_combo_box); + if (g_strcmp0(active_id, "detect") == 0) { + /* TODO */ + } else if (g_strcmp0(active_id, "html") == 0) { + /* TODO */ + } else if (g_strcmp0(active_id, "mhtml") == 0) { + save_mhtml(web_view, file); + } } gtk_widget_destroy(dialog); @@ -1031,6 +1048,7 @@ mq_web_view_save(MqWebView *web_view) gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo_box), 0); g_signal_connect(type_combo_box, "changed", G_CALLBACK(save_type_changed_cb), chooser); + web_view->save_type_combo_box = GTK_COMBO_BOX(type_combo_box); type_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start(GTK_BOX(type_box), gtk_label_new("File type:"), |