Class FileDialog
- All Implemented Interfaces:
Proxy
Asynchronous API to present a file chooser dialog.
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(Window, Cancellable, AsyncReadyCallback),
save(Window, Cancellable, 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 GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new FileDialog.FileDialog(MemorySegment address) Create a FileDialog instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected FileDialogasParent()Return 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.static MemoryLayoutThe memory layout of the native struct.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 class.voidopen(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openFinish(AsyncResult result) Finishes theopen(Window, Cancellable, AsyncReadyCallback)call.voidopenMultiple(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openMultipleFinish(AsyncResult result) Finishes theopen(Window, Cancellable, AsyncReadyCallback)call.voidopenMultipleTextFiles(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openMultipleTextFilesFinish(AsyncResult result, Out<String> encoding) Finishes theopen(Window, Cancellable, AsyncReadyCallback)call.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(Window, Cancellable, 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) Finishes thesave(Window, Cancellable, AsyncReadyCallback)call.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(Window, Cancellable, 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) Finishes theselectFolder(Window, Cancellable, AsyncReadyCallback)call.voidselectMultipleFolders(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.Finishes theselectMultipleFolders(Window, Cancellable, AsyncReadyCallback)call.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 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, 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 TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
FileDialog
Create a FileDialog instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
FileDialog
public FileDialog()Create a new FileDialog.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
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 the
open(Window, Cancellable, 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 the
open(Window, Cancellable, 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(Window, Cancellable, 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 the
open(Window, Cancellable, 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(Window, Cancellable, 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 the
openTextFile(Window, Cancellable, 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 the
save(Window, Cancellable, 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(Window, Cancellable, 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 the
saveTextFile(Window, Cancellable, 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 the
selectFolder(Window, Cancellable, 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 the
selectMultipleFolders(Window, Cancellable, 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(File)andsetInitialName(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
-