Class FileChooserRequest
- All Implemented Interfaces:
Proxy
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 WebKitWebView
::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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionFileChooserRequest
(MemorySegment address) Create a FileChooserRequest proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected FileChooserRequest
asParent()
Returns this instance as if it were its parent type.static FileChooserRequest.Builder
<? extends FileChooserRequest.Builder> builder()
AFileChooserRequest.Builder
object constructs aFileChooserRequest
with the specified properties.void
cancel()
Ask WebKit to cancel the request.String[]
Get the list of MIME types the file chooser dialog should handle.Get the filter currently associated with the request.String[]
Get the list of selected files associated to the request.boolean
Whether the file chooser should allow selecting multiple files.static Type
getType()
Get the GType of the FileChooserRequest classvoid
selectFiles
(String[] files) Ask WebKit to select local files for upload and complete the request.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
FileChooserRequest
Create a FileChooserRequest proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
cancel
public void 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.
-
getMimeTypes
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.
- Returns:
- a
null
-terminated array of strings if a list of accepted MIME types is defined ornull
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.
-
getMimeTypesFilter
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 webkit_file_chooser_request_get_mime_types() if you are interested in getting the list of accepted MIME types.
- Returns:
- a
GtkFileFilter
if a list of accepted MIME types is defined ornull
otherwise. The returned object is owned by WebKit should not be modified or freed.
-
getSelectMultiple
public boolean getSelectMultiple()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.- Returns:
true
if the file chooser should allow selecting multiple files orfalse
otherwise.
-
getSelectedFiles
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.
- Returns:
- a
null
-terminated array of strings if there are selected files associated with the request ornull
otherwise. This array and its contents are owned by WebKit and should not be modified or freed.
-
selectFiles
Ask WebKit to select local files for upload and complete the request.- Parameters:
files
- anull
-terminated array of strings, containing paths to local files.
-
builder
AFileChooserRequest.Builder
object constructs aFileChooserRequest
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withFileChooserRequest.Builder.build()
.
-