1.11 <WebKitDownload>

Class: <WebKitDownload>

It derives from <GObject>.

Object used to communicate with the application when downloading.

<WebKitDownload> carries information about a download request and response, including a <WebKitURIRequest> and a <WebKitURIResponse> objects. The application may use this object to control the download process, or to simply figure out what is to be downloaded, and handle the download process itself.

Properties

Property: download:allow-overwrite self

Whether or not the download is allowed to overwrite an existing file on disk. If this property is #f and the destination already exists, the download will fail.

Its value is a boolean.

Set it with (set! (download:allow-overwrite self) value).

Property: download:destination self

The local path to where the download will be saved.

Its value is a string, or #f.

It is read only.

Property: download:estimated-progress self

An estimate of the percent completion for the download operation. This value will range from 0.0 to 1.0. The value is an estimate based on the total number of bytes expected to be received for a download. If you need a more accurate progress information you can connect to download:received-data signal to track the progress.

Its value is a real number.

It is read only.

Property: download:response self

The <WebKitURIResponse> associated with this download.

Its value is a <WebKitURIResponse>, or #f.

It is read only.

Procedures

Method: download:cancel self
Method: cancel self

Cancels the download.

When the ongoing download operation is effectively cancelled the signal download:failed is emitted with cancelled-by-user error.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

Method: download:get-allow-overwrite? self ⇒ %return
Method: get-allow-overwrite? self ⇒ %return

Returns the current value of the download:allow-overwrite property.

Returns the current value of the download:allow-overwrite property, which determines whether the download will overwrite an existing file on disk, or if it will fail if the destination already exists.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

%return

Returned: a boolean.

the current value of the download:allow-overwrite property

Method: download:get-destination self ⇒ %return
Method: get-destination self ⇒ %return

Obtains the destination to which the downloaded file will be written.

You can connect to download:created-destination to make sure this method returns a valid destination.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

%return

Returned: a string, or #f.

the destination or #f

Method: download:get-elapsed-time self ⇒ %return
Method: get-elapsed-time self ⇒ %return

Gets the elapsed time in seconds, including any fractional part.

If the download finished, had an error or was cancelled this is the time between its start and the event.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

%return

Returned: a real number.

seconds since the download was started

Method: download:get-estimated-progress self ⇒ %return
Method: get-estimated-progress self ⇒ %return

Gets the value of the download:estimated-progress property. Gets the value of the download:estimated-progress property. You can monitor the estimated progress of the download operation by connecting to the notify::estimated-progress signal of self.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

%return

Returned: a real number.

an estimate of the of the percent complete for a download as a range from 0.0 to 1.0.

Method: download:get-received-data-length self ⇒ %return
Method: get-received-data-length self ⇒ %return

Gets the length of the data already downloaded for self.

Gets the length of the data already downloaded for self in bytes.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

%return

Returned: an unsigned 64-bit integer.

the amount of bytes already downloaded.

Method: download:get-request self ⇒ %return
Method: get-request self ⇒ %return

Retrieves the <WebKitURIRequest> object that backs the download process.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

%return

Returned: a <WebKitURIRequest>.

the <WebKitURIRequest> of self

Method: download:get-response self ⇒ %return
Method: get-response self ⇒ %return

Retrieves the <WebKitURIResponse> object that backs the download process.

Retrieves the <WebKitURIResponse> object that backs the download process. This method returns #f if called before the response is received from the server. You can connect to notify::response signal to be notified when the response is received.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

%return

Returned: a <WebKitURIResponse>.

the <WebKitURIResponse>, or #f if the response hasn’t been received yet.

Method: download:get-web-view self ⇒ %return
Method: get-web-view self ⇒ %return

Get the <WebKitWebView> that initiated the download.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

%return

Returned: a <WebKitWebView>.

the <WebKitWebView> that initiated self, or #f if self was not initiated by a <WebKitWebView>.

Method: download:set-allow-overwrite self allowed
Method: set-allow-overwrite self allowed

Sets the download:allow-overwrite property.

Sets the download:allow-overwrite property, which determines whether the download may overwrite an existing file on disk, or if it will fail if the destination already exists.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

allowed

Passed: a boolean.

the new value for the download:allow-overwrite property

Method: download:set-destination self destination
Method: set-destination self destination

Sets the destination to which the downloaded file will be written.

This method should be called before the download transfer starts or it will not have any effect on the ongoing download operation. To set the destination using the filename suggested by the server connect to download:decide-destination signal and call download:set-destination. If you want to set a fixed destination that doesn’t depend on the suggested filename you can connect to notify::response signal and call download:set-destination.

If download:decide-destination signal is not handled and destination is not set when the download transfer starts, the file will be saved with the filename suggested by the server in directory-download directory.

self

Passed: a <WebKitDownload>.

a <WebKitDownload>

destination

Passed: a string.

the destination

Signals

Signal: download:created-destination

Connect a handler with (connect object download:created-destination handler). It is called as (handler self destination).

This signal is emitted after download:decide-destination and before download:received-data to notify that destination file has been created successfully at destination.

self

Passed: a <WebKitDownload>.

destination

Passed: a string.

the destination

Signal: download:decide-destination

Connect a handler with (connect object download:decide-destination handler). It is called as (handler self suggested-filename) ⇒ %return.

This signal is emitted after response is received to decide a destination for the download using download:set-destination. If this signal is not handled, the file will be downloaded to directory-download directory using suggested-filename.

Since 2.40, you may handle this signal asynchronously by returning #t without calling download:set-destination. This indicates intent to eventually call download:set-destination. In this case, the download will not proceed until the destination is set or cancelled with download:cancel.

self

Passed: a <WebKitDownload>.

suggested-filename

Passed: a string.

the filename suggested for the download

%return

Returned: a boolean.

#t to stop other handlers from being invoked for the event, or #f to propagate the event further.

Signal: download:failed

Connect a handler with (connect object download:failed handler). It is called as (handler self error).

This signal is emitted when an error occurs during the download operation. The given error, of the domain WEBKIT_DOWNLOAD_ERROR, contains further details of the failure. If the download is cancelled with download:cancel, this signal is emitted with error cancelled-by-user. The download operation finishes after an error and download:finished signal is emitted after this one.

self

Passed: a <WebKitDownload>.

error

Passed: a <GError>.

the <GError> that was triggered

Signal: download:finished

Connect a handler with (connect object download:finished handler). It is called as (handler self).

This signal is emitted when download finishes successfully or due to an error. In case of errors download:failed signal is emitted before this one.

self

Passed: a <WebKitDownload>.

Signal: download:received-data

Connect a handler with (connect object download:received-data handler). It is called as (handler self data-length).

This signal is emitted after response is received, every time new data has been written to the destination. It’s useful to know the progress of the download operation.

self

Passed: a <WebKitDownload>.

data-length

Passed: an unsigned 64-bit integer.

the length of data received in bytes