Class Download.Builder<B extends Download.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
BuilderInterface
Enclosing class:
Download

public static class Download.Builder<B extends Download.Builder<B>> extends GObject.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public Download build()
      Finish building the Download object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to Download.
      Overrides:
      build in class GObject.Builder<B extends Download.Builder<B>>
      Returns:
      a new instance of Download with the properties that were set in the Builder object.
    • setAllowOverwrite

      public B setAllowOverwrite(boolean allowOverwrite)
      Whether or not the download is allowed to overwrite an existing file on disk. If this property is false and the destination already exists, the download will fail.
      Parameters:
      allowOverwrite - the value for the allow-overwrite property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.6
    • onCreatedDestination

      public B onCreatedDestination(Download.CreatedDestinationCallback handler)
      This signal is emitted after WebKitDownload::decide-destination and before WebKitDownload::received-data to notify that destination file has been created successfully at destination.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onDecideDestination

      public B onDecideDestination(Download.DecideDestinationCallback handler)

      This signal is emitted after response is received to decide a destination for the download using webkit_download_set_destination(). If this signal is not handled, the file will be downloaded to UserDirectory.DIRECTORY_DOWNLOAD directory using suggestedFilename.

      Since 2.40, you may handle this signal asynchronously by returning true without calling webkit_download_set_destination(). This indicates intent to eventually call webkit_download_set_destination(). In this case, the download will not proceed until the destination is set or cancelled with webkit_download_cancel().

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onFailed

      public B onFailed(Download.FailedCallback handler)
      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 webkit_download_cancel(), this signal is emitted with error DownloadError.CANCELLED_BY_USER. The download operation finishes after an error and WebKitDownload::finished signal is emitted after this one.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onFinished

      public B onFinished(Download.FinishedCallback handler)
      This signal is emitted when download finishes successfully or due to an error. In case of errors WebKitDownload::failed signal is emitted before this one.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onReceivedData

      public B onReceivedData(Download.ReceivedDataCallback handler)
      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.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: