WebKit.FileChooserRequest

g GObject.Object GObject.Object WebKit.FileChooserRequest WebKit.FileChooserRequest GObject.Object->WebKit.FileChooserRequest

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

cancel ()

get_mime_types ()

get_mime_types_filter ()

get_select_multiple ()

get_selected_files ()

select_files (files)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

filter

Gtk.FileFilter

r

mime-types

[str]

r

select-multiple

bool

r

selected-files

[str]

r

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class WebKit.FileChooserRequest(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

WebKit.FileChooserRequestClass

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 Gtk.FileChooserDialog (which might be not desirable in some cases, which could prefer to use their own file chooser dialog), WebKit will fire the WebKit.WebView ::run-file-chooser signal with a WebKit.FileChooserRequest 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 Gtk.FileChooserDialog for the user to interact with.

cancel()

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.

get_mime_types()
Returns:

a None-terminated array of strings if a list of accepted MIME types is defined or None 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.

Return type:

[str]

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.

get_mime_types_filter()
Returns:

a Gtk.FileFilter if a list of accepted MIME types is defined or None otherwise. The returned object is owned by WebKit should not be modified or freed.

Return type:

Gtk.FileFilter

Get the filter currently associated with the request.

Get the filter currently associated with the request, ready to be used by Gtk.FileChooser. 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 WebKit.FileChooserRequest.get_mime_types() if you are interested in getting the list of accepted MIME types.

get_select_multiple()
Returns:

True if the file chooser should allow selecting multiple files or False otherwise.

Return type:

bool

Whether the file chooser should allow selecting multiple files.

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

get_selected_files()
Returns:

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

Return type:

[str]

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.FileChooserRequest.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.

select_files(files)
Parameters:

files ([str]) – a None-terminated array of strings, containing paths to local files.

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

Property Details

WebKit.FileChooserRequest.props.filter
Name:

filter

Type:

Gtk.FileFilter

Default Value:

None

Flags:

READABLE

The filter currently associated with the request. See WebKit.FileChooserRequest.get_mime_types_filter() for more details.

WebKit.FileChooserRequest.props.mime_types
Name:

mime-types

Type:

[str]

Default Value:

[]

Flags:

READABLE

A None-terminated array of strings containing the list of MIME types the file chooser dialog should handle. See WebKit.FileChooserRequest.get_mime_types() for more details.

WebKit.FileChooserRequest.props.select_multiple
Name:

select-multiple

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the file chooser should allow selecting multiple files. See WebKit.FileChooserRequest.get_select_multiple() for more details.

WebKit.FileChooserRequest.props.selected_files
Name:

selected-files

Type:

[str]

Default Value:

[]

Flags:

READABLE

A None-terminated array of strings containing the list of selected files associated to the current request. See WebKit.FileChooserRequest.get_selected_files() for more details.