WebKit2.Download¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w |
|||
r |
|||
r |
|||
r |
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
This signal is emitted after |
|
This signal is emitted after response is received to decide a destination for the download using |
|
This signal is emitted when an error occurs during the download operation. |
|
This signal is emitted when download finishes successfully or due to an error. |
|
This signal is emitted after response is received, every time new data has been written to the destination. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent |
r |
Class Details¶
- class WebKit2.Download(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Object used to communicate with the application when downloading.
WebKit2.Downloadcarries information about a download request and response, including aWebKit2.URIRequestand aWebKit2.URIResponseobjects. 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.- cancel()¶
Cancels the download.
When the ongoing download operation is effectively cancelled the signal
WebKit2.Download::failedis emitted withWebKit2.DownloadError.CANCELLED_BY_USERerror.
- get_allow_overwrite()¶
- Returns:
the current value of the
WebKit2.Download:allow-overwriteproperty- Return type:
Returns the current value of the
WebKit2.Download:allow-overwriteproperty.Returns the current value of the
WebKit2.Download:allow-overwriteproperty, which determines whether the download will overwrite an existing file on disk, or if it will fail if the destination already exists.New in version 2.6.
- get_destination()¶
-
Obtains the destination to which the downloaded file will be written.
You can connect to
WebKit2.Download::created-destinationto make sure this method returns a valid destination.
- get_elapsed_time()¶
- Returns:
seconds since the download was started
- Return type:
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.
- get_estimated_progress()¶
- Returns:
an estimate of the of the percent complete for a download as a range from 0.0 to 1.0.
- Return type:
Gets the value of the
WebKit2.Download:estimated-progressproperty. Gets the value of theWebKit2.Download:estimated-progressproperty. You can monitor the estimated progress of the download operation by connecting to the notify::estimated-progress signal of self.
- get_received_data_length()¶
- Returns:
the amount of bytes already downloaded.
- Return type:
Gets the length of the data already downloaded for self.
Gets the length of the data already downloaded for self in bytes.
- get_request()¶
- Returns:
the
WebKit2.URIRequestof self- Return type:
Retrieves the
WebKit2.URIRequestobject that backs the download process.
- get_response()¶
- Returns:
the
WebKit2.URIResponse, orNoneif the response hasn’t been received yet.- Return type:
Retrieves the
WebKit2.URIResponseobject that backs the download process.Retrieves the
WebKit2.URIResponseobject that backs the download process. This method returnsNoneif called before the response is received from the server. You can connect to notify::response signal to be notified when the response is received.
- get_web_view()¶
- Returns:
the
WebKit2.WebViewthat initiated self, orNoneif self was not initiated by aWebKit2.WebView.- Return type:
Get the
WebKit2.WebViewthat initiated the download.
- set_allow_overwrite(allowed)¶
- Parameters:
allowed (
bool) – the new value for theWebKit2.Download:allow-overwriteproperty
Sets the
WebKit2.Download:allow-overwriteproperty.Sets the
WebKit2.Download:allow-overwriteproperty, which determines whether the download may overwrite an existing file on disk, or if it will fail if the destination already exists.New in version 2.6.
- set_destination(destination)¶
- Parameters:
destination (
str) – the 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
WebKit2.Download::decide-destinationsignal and callWebKit2.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 callWebKit2.Download.set_destination().If
WebKit2.Download::decide-destinationsignal 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 inGLib.UserDirectory.DIRECTORY_DOWNLOADdirectory.
Signal Details¶
- WebKit2.Download.signals.created_destination(download, destination)¶
- Signal Name:
created-destination- Flags:
- Parameters:
download (
WebKit2.Download) – The object which received the signaldestination (
str) – the destination
This signal is emitted after
WebKit2.Download::decide-destinationand beforeWebKit2.Download::received-datato notify that destination file has been created successfully at destination.
- WebKit2.Download.signals.decide_destination(download, suggested_filename)¶
- Signal Name:
decide-destination- Flags:
- Parameters:
download (
WebKit2.Download) – The object which received the signalsuggested_filename (
str) – the filename suggested for the download
- Returns:
Trueto stop other handlers from being invoked for the event, orFalseto propagate the event further.- Return type:
This signal is emitted after response is received to decide a destination for the download using
WebKit2.Download.set_destination(). If this signal is not handled, the file will be downloaded toGLib.UserDirectory.DIRECTORY_DOWNLOADdirectory using suggested_filename.Since 2.40, you may handle this signal asynchronously by returning
Truewithout callingWebKit2.Download.set_destination(). This indicates intent to eventually callWebKit2.Download.set_destination(). In this case, the download will not proceed until the destination is set or cancelled withWebKit2.Download.cancel().
- WebKit2.Download.signals.failed(download, error)¶
- Signal Name:
failed- Flags:
- Parameters:
download (
WebKit2.Download) – The object which received the signalerror (
GLib.Error) – theGLib.Errorthat was triggered
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
WebKit2.Download.cancel(), this signal is emitted with errorWebKit2.DownloadError.CANCELLED_BY_USER. The download operation finishes after an error andWebKit2.Download::finishedsignal is emitted after this one.
- WebKit2.Download.signals.finished(download)¶
- Signal Name:
finished- Flags:
- Parameters:
download (
WebKit2.Download) – The object which received the signal
This signal is emitted when download finishes successfully or due to an error. In case of errors
WebKit2.Download::failedsignal is emitted before this one.
- WebKit2.Download.signals.received_data(download, data_length)¶
- Signal Name:
received-data- Flags:
- Parameters:
download (
WebKit2.Download) – The object which received the signaldata_length (
int) – the length of data received in bytes
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.
Property Details¶
- WebKit2.Download.props.allow_overwrite¶
-
Whether or not the download is allowed to overwrite an existing file on disk. If this property is
Falseand the destination already exists, the download will fail.New in version 2.6.
- WebKit2.Download.props.destination¶
-
The local path to where the download will be saved.
- WebKit2.Download.props.estimated_progress¶
-
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
WebKit2.Download::received-datasignal to track the progress.
- WebKit2.Download.props.response¶
- Name:
response- Type:
- Default Value:
- Flags:
The
WebKit2.URIResponseassociated with this download.