summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/web-view.c104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/web-view.c b/src/web-view.c
index 7975813..a4126c8 100644
--- a/src/web-view.c
+++ b/src/web-view.c
@@ -892,24 +892,31 @@ mq_web_view_open(MqWebView *web_view)
}
static void
-save_async_cb(WebKitWebView *web_view, GAsyncResult *result)
+save_html_replace_cb(GFile *file, GAsyncResult *result)
{
- webkit_web_view_save_to_file_finish(web_view, result, NULL);
+ g_file_replace_contents_finish(file, result, NULL, NULL);
+ /* TODO: Error handling? */
}
-static gchar *
-get_clean_title(MqWebView *web_view)
+static void
+save_html_get_data_cb(WebKitWebResource *resource, GAsyncResult *result,
+ MqWebView *web_view)
{
- gchar *title;
+ guchar *data;
+ gsize length;
- title = g_strdup(webkit_web_view_get_title(WEBKIT_WEB_VIEW(web_view)));
- return g_strdelimit(title,
-#ifdef G_OS_WIN32
- "/\\:*\"?<>|",
-#else
- "/",
-#endif
- '_');
+ data = webkit_web_resource_get_data_finish(resource, result, &length,
+ NULL); /* TODO: Error handling? */
+ g_file_replace_contents_async(web_view->save_file,
+ (gchar *) data, length,
+ NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL,
+ (GAsyncReadyCallback) save_html_replace_cb, NULL);
+}
+
+static void
+save_mhtml_cb(WebKitWebView *web_view, GAsyncResult *result)
+{
+ webkit_web_view_save_to_file_finish(web_view, result, NULL);
}
static gboolean
@@ -939,6 +946,38 @@ extension_is_mhtml(const gchar *extension)
}
static void
+save_html(MqWebView *web_view, GFile *file)
+{
+ web_view->save_file = file;
+ webkit_web_resource_get_data(
+ webkit_web_view_get_main_resource(WEBKIT_WEB_VIEW(web_view)),
+ NULL, (GAsyncReadyCallback) save_html_get_data_cb, web_view);
+}
+
+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_mhtml_cb, 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_type_changed_cb(GtkComboBox *combo_box, GtkFileChooser *chooser)
{
gchar *name;
@@ -972,45 +1011,6 @@ save_type_changed_cb(GtkComboBox *combo_box, GtkFileChooser *chooser)
}
static void
-save_html_replace_cb(GFile *file, GAsyncResult *result)
-{
- g_file_replace_contents_finish(file, result, NULL, NULL);
- /* TODO: Error handling? */
-}
-
-static void
-save_html_get_data_cb(WebKitWebResource *resource, GAsyncResult *result,
- MqWebView *web_view)
-{
- guchar *data;
- gsize length;
-
- data = webkit_web_resource_get_data_finish(resource, result, &length,
- NULL); /* TODO: Error handling? */
- g_file_replace_contents_async(web_view->save_file,
- (gchar *) data, length,
- NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL,
- (GAsyncReadyCallback) save_html_replace_cb, NULL);
-}
-
-static void
-save_html(MqWebView *web_view, GFile *file)
-{
- web_view->save_file = file;
- webkit_web_resource_get_data(
- webkit_web_view_get_main_resource(WEBKIT_WEB_VIEW(web_view)),
- NULL, (GAsyncReadyCallback) save_html_get_data_cb, web_view);
-}
-
-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;