Use WebKitDownload to save web pages with Save As

This commit is contained in:
Christian Dywan 2009-08-30 15:52:30 +02:00
parent e09ea1ef3a
commit d03a8226fa

View file

@ -179,6 +179,10 @@ static void
midori_browser_set_bookmarks (MidoriBrowser* browser, midori_browser_set_bookmarks (MidoriBrowser* browser,
KatzeArray* bookmarks); KatzeArray* bookmarks);
static void
midori_browser_add_download_item (MidoriBrowser* browser,
WebKitDownload* download);
static GtkAction* static GtkAction*
_action_by_name (MidoriBrowser* browser, _action_by_name (MidoriBrowser* browser,
const gchar* name) const gchar* name)
@ -784,6 +788,7 @@ midori_view_add_bookmark_cb (GtkWidget* menuitem,
midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE); midori_browser_edit_bookmark_dialog_new (browser, item, FALSE, FALSE);
} }
#if !WEBKIT_CHECK_VERSION (1, 1, 3)
static void static void
midori_browser_save_transfer_cb (KatzeNetRequest* request, midori_browser_save_transfer_cb (KatzeNetRequest* request,
gchar* filename) gchar* filename)
@ -808,6 +813,7 @@ midori_browser_save_transfer_cb (KatzeNetRequest* request,
} }
g_free (filename); g_free (filename);
} }
#endif
static void static void
midori_browser_save_uri (MidoriBrowser* browser, midori_browser_save_uri (MidoriBrowser* browser,
@ -869,10 +875,27 @@ midori_browser_save_uri (MidoriBrowser* browser,
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
{ {
#if WEBKIT_CHECK_VERSION (1, 1, 3)
WebKitNetworkRequest* request;
WebKitDownload* download;
gchar* destination;
#endif
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)); folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
#if WEBKIT_CHECK_VERSION (1, 1, 3)
request = webkit_network_request_new (uri);
download = webkit_download_new (request);
g_object_unref (request);
destination = g_filename_to_uri (filename, NULL, NULL);
webkit_download_set_destination_uri (download, destination);
g_free (destination);
midori_browser_add_download_item (browser, download);
webkit_download_start (download);
#else
katze_net_load_uri (browser->net, uri, NULL, katze_net_load_uri (browser->net, uri, NULL,
(KatzeNetTransferCb)midori_browser_save_transfer_cb, filename); (KatzeNetTransferCb)midori_browser_save_transfer_cb, filename);
#endif
g_free (last_dir); g_free (last_dir);
last_dir = folder; last_dir = folder;