Class FileDialog
- All Implemented Interfaces:
Proxy
GtkFileDialog
object collects the arguments that
are needed to present a file chooser 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.
-
Nested Class Summary
Modifier 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
-
Constructor Summary
ConstructorDescriptionCreates a newGtkFileDialog
object.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 name for the file that should be initially set.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) This function initiates a file selection operation by presenting a file chooser dialog to the user.openFinish
(AsyncResult result) Finishes theopen(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting file.void
openMultiple
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function initiates a multi-file selection operation by presenting a file chooser dialog to the user.openMultipleFinish
(AsyncResult result) Finishes theopen(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting files in aGListModel
.void
save
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function initiates a file save operation by presenting a file chooser dialog to the user.saveFinish
(AsyncResult result) Finishes thesave(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting file.void
selectFolder
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function initiates a directory selection operation by presenting a file chooser dialog to the user.selectFolderFinish
(AsyncResult result) Finishes theselectFolder(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting file.void
selectMultipleFolders
(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) This function initiates a multi-directory selection operation by presenting a file chooser dialog to the user.Finishes theselectMultipleFolders(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting files in aGListModel
.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 name for the file that should be initially set.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, 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 newGtkFileDialog
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. -
getAcceptLabel
Retrieves the text used by the dialog on its accept button.- Returns:
- the label shown on the file chooser's accept button.
-
getDefaultFilter
Gets the filter that will be selected by default in the file chooser dialog.- Returns:
- the current filter
-
getFilters
Gets the filters that will be offered to the user in the file chooser dialog.- Returns:
- the filters, as
a
GListModel
ofGtkFileFilters
-
getInitialFile
Gets the file that will be initially selected in the file chooser dialog.- Returns:
- the file
-
getInitialFolder
Gets the folder that will be set as the initial folder in the file chooser dialog.- Returns:
- the folder
-
getInitialName
Gets the name for the file that should be initially set.- Returns:
- the name
-
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
-
getTitle
Returns the title that will be shown on the file chooser dialog.- Returns:
- the title
-
open
public void open(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) This function initiates a file selection operation by presenting a file chooser dialog to the user.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
-
openFinish
Finishes theopen(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting file.- Parameters:
result
- aGAsyncResult
- Returns:
- the file that was selected.
Otherwise,
NULL
is returned anderror
is set - Throws:
GErrorException
- seeGError
-
openMultiple
public void openMultiple(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) This function initiates a multi-file selection operation by presenting a file chooser dialog to the user.The file chooser will initially be opened in the directory
Gtk.FileDialog:initial-folder
.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
-
openMultipleFinish
Finishes theopen(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting files in aGListModel
.- Parameters:
result
- aGAsyncResult
- Returns:
- the file that was selected,
as a
GListModel
ofGFiles
. Otherwise,NULL
is returned anderror
is set - Throws:
GErrorException
- seeGError
-
save
public void save(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) This function initiates a file save operation by presenting a file chooser dialog to the user.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
-
saveFinish
Finishes thesave(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting file.- Parameters:
result
- aGAsyncResult
- Returns:
- the file that was selected.
Otherwise,
NULL
is returned anderror
is set - Throws:
GErrorException
- seeGError
-
selectFolder
public void selectFolder(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) This function initiates a directory selection operation by presenting a file chooser dialog to the user.If you pass
initialFolder
, the file chooser 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 parentGtkWindow
cancellable
- aGCancellable
to cancel the operationcallback
- a callback to call when the operation is complete
-
selectFolderFinish
Finishes theselectFolder(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting file.- Parameters:
result
- aGAsyncResult
- Returns:
- the file that was selected.
Otherwise,
NULL
is returned anderror
is set - Throws:
GErrorException
- seeGError
-
selectMultipleFolders
public void selectMultipleFolders(@Nullable @Nullable Window parent, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) This function initiates a multi-directory selection operation by presenting a file chooser dialog to the user.The file chooser will initially be opened in the directory
Gtk.FileDialog:initial-folder
.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
-
selectMultipleFoldersFinish
Finishes theselectMultipleFolders(org.gnome.gtk.Window, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)
call and returns the resulting files in aGListModel
.- Parameters:
result
- aGAsyncResult
- Returns:
- the file that was selected,
as a
GListModel
ofGFiles
. Otherwise,NULL
is returned anderror
is set - Throws:
GErrorException
- seeGError
-
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
-
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
- aGtkFileFilter
-
setFilters
Sets the filters that will be offered to the user in the file chooser dialog.- Parameters:
filters
- aGListModel
ofGtkFileFilters
-
setInitialFile
Sets the file that will be initially selected in the file chooser dialog.This function is a shortcut for calling both gtk_file_dialog_set_initial_folder() and gtk_file_dialog_set_initial_name() with the directory and name of
file
respectively.- Parameters:
file
- aGFile
-
setInitialFolder
Sets the folder that will be set as the initial folder in the file chooser dialog.- Parameters:
folder
- aGFile
-
setInitialName
Sets the name for the file that should be initially set. For saving dialogs, this 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 should preselect it.- Parameters:
name
- a UTF8 string
-
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
-
setTitle
Sets the title that will be shown on the file chooser dialog.- Parameters:
title
- the new title
-
builder
AFileDialog.Builder
object constructs aFileDialog
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withFileDialog.Builder.build()
.
-