1.14 <WebKitFileChooserRequest>

Class: <WebKitFileChooserRequest>

It derives from <GObject>.

A request to open a file chooser.

Whenever the user interacts with an HTML input element with file type, WebKit will need to show a dialog to choose one or more files to be uploaded to the server along with the rest of the form data. For that to happen in a general way, instead of just opening a GtkFileChooserDialog (which might be not desirable in some cases, which could prefer to use their own file chooser dialog), WebKit will fire the web-view:run-file-chooser signal with a <WebKitFileChooserRequest> object, which will allow the client application to specify the files to be selected, to inspect the details of the request (e.g. if multiple selection should be allowed) and to cancel the request, in case nothing was selected.

In case the client application does not wish to handle this signal, WebKit will provide a default handler which will asynchronously run a regular GtkFileChooserDialog for the user to interact with.

Properties

Property: file-chooser-request:filter self

The filter currently associated with the request. See file-chooser-request:get-mime-types-filter for more details.

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

It is read only.

Property: file-chooser-request:mime-types self

A #f-terminated array of strings containing the list of MIME types the file chooser dialog should handle. See file-chooser-request:get-mime-types for more details.

Its value is a vector, each a string, or #f.

It is read only.

Property: file-chooser-request:select-multiple self

Whether the file chooser should allow selecting multiple files. See file-chooser-request:get-select-multiple? for more details.

Its value is a boolean.

It is read only.

Property: file-chooser-request:selected-files self

A #f-terminated array of strings containing the list of selected files associated to the current request. See file-chooser-request:get-selected-files for more details.

Its value is a vector, each a string, or #f.

It is read only.

Procedures

Method: file-chooser-request:cancel self
Method: cancel self

Ask WebKit to cancel the request.

It’s important to do this in case no selection has been made in the client, otherwise the request won’t be properly completed and the browser will keep the request pending forever, which might cause the browser to hang.

self

Passed: a <WebKitFileChooserRequest>.

a <WebKitFileChooserRequest>

Method: file-chooser-request:get-mime-types self ⇒ %return
Method: get-mime-types self ⇒ %return

Get the list of MIME types the file chooser dialog should handle.

Get the list of MIME types the file chooser dialog should handle, in the format specified in RFC 2046 for "media types". Its contents depend on the value of the ’accept’ attribute for HTML input elements. This function should normally be called before presenting the file chooser dialog to the user, to decide whether to allow the user to select multiple files at once or only one.

self

Passed: a <WebKitFileChooserRequest>.

a <WebKitFileChooserRequest>

%return

Returned: a vector, each a string.

a #f-terminated array of strings if a list of accepted MIME types is defined or #f otherwise, meaning that any MIME type should be accepted. This array and its contents are owned by WebKit and should not be modified or freed.

Method: file-chooser-request:get-mime-types-filter self ⇒ %return
Method: get-mime-types-filter self ⇒ %return

Get the filter currently associated with the request.

Get the filter currently associated with the request, ready to be used by GtkFileChooser. This function should normally be called before presenting the file chooser dialog to the user, to decide whether to apply a filter so the user would not be allowed to select files with other MIME types.

See file-chooser-request:get-mime-types if you are interested in getting the list of accepted MIME types.

self

Passed: a <WebKitFileChooserRequest>.

a <WebKitFileChooserRequest>

%return

Returned: a <GtkFileFilter>.

a <GtkFileFilter> if a list of accepted MIME types is defined or #f otherwise. The returned object is owned by WebKit should not be modified or freed.

Method: file-chooser-request:get-select-multiple? self ⇒ %return
Method: get-select-multiple? self ⇒ %return

Whether the file chooser should allow selecting multiple files.

Determine whether the file chooser associated to this <WebKitFileChooserRequest> should allow selecting multiple files, which depends on the HTML input element having a ’multiple’ attribute defined.

self

Passed: a <WebKitFileChooserRequest>.

a <WebKitFileChooserRequest>

%return

Returned: a boolean.

#t if the file chooser should allow selecting multiple files or #f otherwise.

Method: file-chooser-request:get-selected-files self ⇒ %return
Method: get-selected-files self ⇒ %return

Get the list of selected files associated to the request.

Get the list of selected files currently associated to the request. Initially, the return value of this method contains any files selected in previous file chooser requests for this HTML input element. Once webkit_file_chooser_request_select_files, the value will reflect whatever files are given.

This function should normally be called only before presenting the file chooser dialog to the user, to decide whether to perform some extra action, like pre-selecting the files from a previous request.

self

Passed: a <WebKitFileChooserRequest>.

a <WebKitFileChooserRequest>

%return

Returned: a vector, each a string.

a #f-terminated array of strings if there are selected files associated with the request or #f otherwise. This array and its contents are owned by WebKit and should not be modified or freed.

Method: file-chooser-request:select-files self files
Method: select-files self files

Ask WebKit to select local files for upload and complete the request.

self

Passed: a <WebKitFileChooserRequest>.

a <WebKitFileChooserRequest>

files

Passed: a list or vector, each a string.

a #f-terminated array of strings, containing paths to local files.