Class FileDialog
- All Implemented Interfaces:
Proxy
GtkFileDialog collects the arguments that are needed to present
the dialog to the user, such as a title for the dialog and whether
it should be modal.
The dialog is shown with open(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback),
save(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback), etc.
- Since:
- 4.10
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFileDialog.Builder<B extends FileDialog.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new FileDialog.FileDialog(MemorySegment address) Create a FileDialog proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected FileDialogasParent()Returns this instance as if it were its parent type.static FileDialog.Builder<? extends FileDialog.Builder> builder()AFileDialog.Builderobject constructs aFileDialogwith the specified properties.@Nullable StringRetrieves the text used by the dialog on its accept button.@Nullable FileFilterGets the filter that will be selected by default in the file chooser dialog.@Nullable ListModelGets the filters that will be offered to the user in the file chooser dialog.@Nullable FileGets the file that will be initially selected in the file chooser dialog.@Nullable FileGets the folder that will be set as the initial folder in the file chooser dialog.@Nullable StringGets the filename that will be initially selected.booleangetModal()Returns whether the file chooser dialog blocks interaction with the parent window while it is presented.getTitle()Returns the title that will be shown on the file chooser dialog.static @Nullable TypegetType()Get the GType of the FileDialog classvoidopen(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openFinish(AsyncResult result) voidopenMultiple(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openMultipleFinish(AsyncResult result) voidopenMultipleTextFiles(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openMultipleTextFilesFinish(AsyncResult result, Out<String> encoding) voidopenTextFile(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Initiates a file selection operation by presenting a file chooser dialog to the user.openTextFileFinish(AsyncResult result, Out<String> encoding) Finishes theopenTextFile(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call and returns the resulting file and text encoding.voidsave(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.saveFinish(AsyncResult result) voidsaveTextFile(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Initiates a file save operation by presenting a file chooser dialog to the user.saveTextFileFinish(AsyncResult result, Out<String> encoding, Out<String> lineEnding) Finishes thesaveTextFile(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call and returns the resulting file, text encoding and line endings.voidselectFolder(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.selectFolderFinish(AsyncResult result) voidselectMultipleFolders(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.voidsetAcceptLabel(@Nullable String acceptLabel) Sets the label shown on the file chooser's accept button.voidsetDefaultFilter(@Nullable FileFilter filter) Sets the filter that will be selected by default in the file chooser dialog.voidsetFilters(@Nullable ListModel filters) Sets the filters that will be offered to the user in the file chooser dialog.voidsetInitialFile(@Nullable File file) Sets the file that will be initially selected in the file chooser dialog.voidsetInitialFolder(@Nullable File folder) Sets the folder that will be set as the initial folder in the file chooser dialog.voidsetInitialName(@Nullable String name) Sets the filename that will be initially selected.voidsetModal(boolean modal) Sets whether the file chooser dialog blocks interaction with the parent window while it is presented.voidSets the title that will be shown on the file chooser dialog.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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
FileDialog
Create a FileDialog proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
FileDialog
public FileDialog()Creates a new FileDialog.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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. -
getAcceptLabel
Retrieves the text used by the dialog on its accept button.- Returns:
- the label shown on the file chooser's accept button
- Since:
- 4.10
-
getDefaultFilter
Gets the filter that will be selected by default in the file chooser dialog.- Returns:
- the default filter
- Since:
- 4.10
-
getFilters
Gets the filters that will be offered to the user in the file chooser dialog.- Returns:
- the filters,
as a list model of
FileFilter - Since:
- 4.10
-
getInitialFile
Gets the file that will be initially selected in the file chooser dialog.- Returns:
- the file
- Since:
- 4.10
-
getInitialFolder
Gets the folder that will be set as the initial folder in the file chooser dialog.- Returns:
- the folder
- Since:
- 4.10
-
getInitialName
Gets the filename that will be initially selected.- Returns:
- the name
- Since:
- 4.10
-
getModal
public boolean getModal()Returns whether the file chooser dialog blocks interaction with the parent window while it is presented.- Returns:
- true if the file chooser dialog is modal
- Since:
- 4.10
-
getTitle
Returns the title that will be shown on the file chooser dialog.- Returns:
- the title
- Since:
- 4.10
-
open
public void open(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.The file chooser dialog will be set up to select a single file.
The
callbackwill be called when the dialog is closed.- Parameters:
parent- the parent windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.10
-
openFinish
Finishes theopen(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- the result- Returns:
- the file that was selected
- Throws:
GErrorException- seeGError- Since:
- 4.10
-
openMultiple
public void openMultiple(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.The file chooser dialog will be set up to select multiple files.
The file chooser dialog will initially be opened in the directory
Gtk.FileDialog:initial-folder.The
callbackwill be called when the dialog is closed.- Parameters:
parent- the parent windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.10
-
openMultipleFinish
Finishes theopen(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- the result- Returns:
- the files that were selected,
as a list model of
File - Throws:
GErrorException- seeGError- Since:
- 4.10
-
openMultipleTextFiles
public void openMultipleTextFiles(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.The file chooser dialog will be set up to select multiple files.
The file chooser dialog will initially be opened in the directory
Gtk.FileDialog:initial-folder.In contrast to
open(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback), this function lets the user select the text encoding for the files, if possible.The
callbackwill be called when the dialog is closed.- Parameters:
parent- the parent windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.18
-
openMultipleTextFilesFinish
public ListModel openMultipleTextFilesFinish(AsyncResult result, Out<String> encoding) throws GErrorException Finishes theopen(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- the resultencoding- return location for the text encoding to use- Returns:
- the files that were selected,
as a list model of
File - Throws:
GErrorException- seeGError- Since:
- 4.18
-
openTextFile
public void openTextFile(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Initiates a file selection operation by presenting a file chooser dialog to the user.In contrast to
open(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback), this function lets the user select the text encoding for the file, if possible.The
callbackwill be called when the dialog is closed.- Parameters:
parent- the parentGtkWindowcancellable- aGCancellableto cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.18
-
openTextFileFinish
Finishes theopenTextFile(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call and returns the resulting file and text encoding.If the user has explicitly selected a text encoding to use for the file, then
encodingwill be set to a codeset name that is suitable for passing to iconv_open(). Otherwise, it will beNULL.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- aGAsyncResultencoding- return location for the text encoding to use- Returns:
- the file that was selected
- Throws:
GErrorException- seeGError- Since:
- 4.18
-
save
public void save(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.The file chooser dialog will be save mode.
The
callbackwill be called when the dialog is closed.- Parameters:
parent- the parent windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.10
-
saveFinish
Finishes thesave(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- the result- Returns:
- the file that was selected
- Throws:
GErrorException- seeGError- Since:
- 4.10
-
saveTextFile
public void saveTextFile(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Initiates a file save operation by presenting a file chooser dialog to the user.In contrast to
save(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback), this function lets the user select the text encoding and line endings for the text file, if possible.The
callbackwill be called when the dialog is closed.- Parameters:
parent- the parentGtkWindowcancellable- aGCancellableto cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.18
-
saveTextFileFinish
public File saveTextFileFinish(AsyncResult result, Out<String> encoding, Out<String> lineEnding) throws GErrorException Finishes thesaveTextFile(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call and returns the resulting file, text encoding and line endings.If the user has explicitly selected a text encoding to use for the file, then
encodingwill be set to a codeset name that is suitable for passing to iconv_open(). Otherwise, it will beNULL.The
lineEndingwill be set to one of "\\n", "\\r\\n", "\\r" or "", where the latter means to preserve existing line endings.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- aGAsyncResultencoding- return location for the text encoding to uselineEnding- return location for the line endings to use- Returns:
- the file that was selected.
- Throws:
GErrorException- seeGError- Since:
- 4.18
-
selectFolder
public void selectFolder(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.The file chooser dialog will be set up to select a single folder.
If you pass
initialFolder,the file chooser dialog will initially be opened in the parent directory of that folder, otherwise, it will be in the directoryGtk.FileDialog:initial-folder.The
callbackwill be called when the dialog is closed.- Parameters:
parent- the parent windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.10
-
selectFolderFinish
Finishes theselectFolder(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- the result- Returns:
- the folder that was selected
- Throws:
GErrorException- seeGError- Since:
- 4.10
-
selectMultipleFolders
public void selectMultipleFolders(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.The file chooser dialog will be set up to allow selecting multiple folders.
The file chooser dialog will initially be opened in the directory
Gtk.FileDialog:initial-folder.The
callbackwill be called when the dialog is closed.- Parameters:
parent- the parent windowcancellable- a cancellable to cancel the operationcallback- a callback to call when the operation is complete- Since:
- 4.10
-
selectMultipleFoldersFinish
Finishes theselectMultipleFolders(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)call.Note that this function returns a
Gtk.DialogError.DISMISSEDerror if the user cancels the dialog.- Parameters:
result- the result- Returns:
- the folders that were selected,
as a list model of
File - Throws:
GErrorException- seeGError- Since:
- 4.10
-
setAcceptLabel
Sets the label shown on the file chooser's accept button.Leaving the accept label unset or setting it as
NULLwill fall back to a default label, depending on what API is used to launch the file dialog.- Parameters:
acceptLabel- the new accept label- Since:
- 4.10
-
setDefaultFilter
Sets the filter that will be selected by default in the file chooser dialog.If set to
NULL, the first item inGtk.FileDialog:filterswill be used as the default filter. If that list is empty, the dialog will be unfiltered.- Parameters:
filter- the file filter- Since:
- 4.10
-
setFilters
Sets the filters that will be offered to the user in the file chooser dialog.- Parameters:
filters- a list model ofFileFilter- Since:
- 4.10
-
setInitialFile
Sets the file that will be initially selected in the file chooser dialog.This function is a shortcut for calling both
setInitialFolder(org.gnome.gio.File)andsetInitialName(java.lang.String)with the directory and name offile,respectively.- Parameters:
file- a file- Since:
- 4.10
-
setInitialFolder
Sets the folder that will be set as the initial folder in the file chooser dialog.- Parameters:
folder- a file- Since:
- 4.10
-
setInitialName
Sets the filename that will be initially selected.For save dialogs,
namewill usually be pre-entered into the name field.If a file with this name already exists in the directory set via
Gtk.FileDialog:initial-folder, the dialog will preselect it.- Parameters:
name- a string- Since:
- 4.10
-
setModal
public void setModal(boolean modal) Sets whether the file chooser dialog blocks interaction with the parent window while it is presented.- Parameters:
modal- the new value- Since:
- 4.10
-
setTitle
Sets the title that will be shown on the file chooser dialog.- Parameters:
title- the new title- Since:
- 4.10
-
builder
AFileDialog.Builderobject constructs aFileDialogwith the specified properties. Use the variousset...()methods to set properties, and finish construction withFileDialog.Builder.build().- Returns:
- the builder object
-