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 class
FileDialog.Builder<B extends FileDialog.Builder<B>>
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
-
Field Summary
Fields inherited from class io.github.jwharm.javagi.base.ProxyInstance
address
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new FileDialog.FileDialog
(MemorySegment address) Create a FileDialog proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected FileDialog
asParent()
Returns this instance as if it were its parent type.static FileDialog.Builder
<? extends FileDialog.Builder> builder()
AFileDialog.Builder
object constructs aFileDialog
with the specified properties.Retrieves the text used by the dialog on its accept button.Gets the filter that will be selected by default in the file chooser dialog.Gets the filters that will be offered to the user in the file chooser dialog.Gets the file that will be initially selected in the file chooser dialog.Gets the folder that will be set as the initial folder in the file chooser dialog.Gets the filename that will be initially selected.boolean
getModal()
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 Type
getType()
Get the GType of the FileDialog classvoid
open
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openFinish
(AsyncResult result) void
openMultiple
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openMultipleFinish
(AsyncResult result) void
openMultipleTextFiles
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.openMultipleTextFilesFinish
(AsyncResult result, Out<String> encoding) 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.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.void
save
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.saveFinish
(AsyncResult result) 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.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.void
selectFolder
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.selectFolderFinish
(AsyncResult result) void
selectMultipleFolders
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.void
setAcceptLabel
(@Nullable String acceptLabel) Sets the label shown on the file chooser's accept button.void
setDefaultFilter
(@Nullable FileFilter filter) Sets the filter that will be selected by default in the file chooser dialog.void
setFilters
(@Nullable ListModel filters) Sets the filters that will be offered to the user in the file chooser dialog.void
setInitialFile
(@Nullable File file) Sets the file that will be initially selected in the file chooser dialog.void
setInitialFolder
(@Nullable File folder) Sets the folder that will be set as the initial folder in the file chooser dialog.void
setInitialName
(@Nullable String name) Sets the filename that will be initially selected.void
setModal
(boolean modal) Sets whether the file chooser dialog blocks interaction with the parent window while it is presented.void
Sets 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, 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
-
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 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. -
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 @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @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
callback
will be called when the dialog is dismissed.- 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.- Parameters:
result
- the result- Returns:
- the file that was selected
- Throws:
GErrorException
- seeGError
- Since:
- 4.10
-
openMultiple
public void openMultiple(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @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
callback
will be called when the dialog is dismissed.- 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.- 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 @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @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
callback
will be called when the dialog is dismissed.- 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.- 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 @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @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
callback
will be called when the dialog is dismissed.- Parameters:
parent
- the parentGtkWindow
cancellable
- aGCancellable
to 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
encoding
will be set to a codeset name that is suitable for passing to iconv_open(). Otherwise, it will beNULL
.- Parameters:
result
- aGAsyncResult
encoding
- 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 @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Presents a file chooser dialog to the user.The file chooser dialog will be save mode.
The
callback
will be called when the dialog is dismissed.- 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.- Parameters:
result
- the result- Returns:
- the file that was selected
- Throws:
GErrorException
- seeGError
- Since:
- 4.10
-
saveTextFile
public void saveTextFile(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @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
callback
will be called when the dialog is dismissed.- Parameters:
parent
- the parentGtkWindow
cancellable
- aGCancellable
to 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
encoding
will be set to a codeset name that is suitable for passing to iconv_open(). Otherwise, it will beNULL
.The
lineEnding
will be set to one of "\\n", "\\r\\n", "\\r" or "", where the latter means to preserve existing line endings.- Parameters:
result
- aGAsyncResult
encoding
- return location for the text encoding to uselineEnding
- return location for the line endings to use- Returns:
- the file that was selected.
Otherwise,
NULL
is returned anderror
is set - Throws:
GErrorException
- seeGError
- Since:
- 4.18
-
selectFolder
public void selectFolder(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @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
callback
will be called when the dialog is dismissed.- 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.- Parameters:
result
- the result- Returns:
- the folder that was selected
- Throws:
GErrorException
- seeGError
- Since:
- 4.10
-
selectMultipleFolders
public void selectMultipleFolders(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @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
callback
will be called when the dialog is dismissed.- 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.- 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
NULL
will 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:filters
will 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,
name
will 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.Builder
object constructs aFileDialog
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withFileDialog.Builder.build()
.
-