[webkit-gtk] download with webkit

Deepak Mundra deepak.m at allaboutif.com
Mon May 31 00:50:04 PDT 2010


On Sat, May 29, 2010 at 12:31 AM, Giovanni <giovyemmanuel at hotmail.it> wrote:
> hi,
> i apologize in advance for my poor english, i'm italian! :)
> i have a problem with the download request of my browser written in c.
>
> i tried to do what Deepak Mundra said but it doesn't work.
>
> this is the code of the functions:
>
> "//-------------funzione MIME--------------------//
> gboolean permessi (WebKitWebView *web_view, WebKitWebFrame *frame,
> WebKitNetworkRequest *request, gchar *mimetype, WebKitWebPolicyDecision
> *policy_decision)
> {
> if (webkit_web_view_can_show_mime_type (WEBKIT_WEB_VIEW (web_view),mimetype))
>        return FALSE;
>
> webkit_web_policy_decision_download (policy_decision);
> webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (web_view));
>
> return TRUE;
> }
>
> //-------------funzione download---------------//
> gboolean download_func (WebKitWebView *web_view, WebKitDownload *download)
> {
>  webkit_download_set_destination_uri(download,"///home/john/Scaricati");
>  webkit_download_start(download);
>

Assuming that download_func is call back for
g_signal_connect (web_view, "download-requested", G_CALLBACK
(download_func), NULL);
the function should look some what like below..

gboolean download_func(WebKitWebView* page,WebKitDownload*
download,gpointer data)
{

gchar *destination = NULL;
destination     = g_filename_to_uri ("/home/john/Scaricat/test.ext",
NULL, NULL);
if(destination)
{
webkit_download_set_destination_uri(download,destination);
g_free (destination);
return TRUE;
}
else
return FALSE;

}

Please correct me if i am wrong in the following statement.

I dont see the necessity of calling webkit_web_view_request_download()
because when you return TRUE the function who emitted the download
request signal will call it automatically ..

Regards
Deepak


More information about the webkit-gtk mailing list