Klasse FileDialog

Alle implementierten Schnittstellen:
PointerInterface

public class FileDialog extends PropertyHolder
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 [method@Gtk.FileDialog.open],
[method@Gtk.FileDialog.save], etc.

https://docs.gtk.org/gtk4/class.FileDialog.html

  • Konstruktordetails

    • FileDialog

      public FileDialog(PointerContainer pointer)
    • FileDialog

      public FileDialog()
      Creates a new `GtkFileDialog` object.
  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getAcceptLabel

      public Str getAcceptLabel()
      Retrieves the text used by the dialog on its accept button.
      Gibt zurück:
      the label shown on the file chooser's accept button
    • getDefaultFilter

      public FileFilter getDefaultFilter()
      Gets the filter that will be selected by default
      in the file chooser dialog.
      Gibt zurück:
      the default filter
    • getFilters

      public ListModel getFilters()
      Gets the filters that will be offered to the user
      in the file chooser dialog.
      Gibt zurück:
      the filters, as a list model of [class@Gtk.FileFilter]
    • getInitialFile

      public File getInitialFile()
      Gets the file that will be initially selected in
      the file chooser dialog.
      Gibt zurück:
      the file
    • getInitialFolder

      public File getInitialFolder()
      Gets the folder that will be set as the
      initial folder in the file chooser dialog.
      Gibt zurück:
      the folder
    • getInitialName

      public Str getInitialName()
      Gets the filename that will be initially selected.
      Gibt zurück:
      the name
    • getModal

      public boolean getModal()
      Returns whether the file chooser dialog blocks interaction
      with the parent window while it is presented.
      Gibt zurück:
      true if the file chooser dialog is modal
    • getTitle

      public Str getTitle()
      Returns the title that will be shown on the file chooser dialog.
      Gibt zurück:
      the title
    • open

      public void open(@Nullable Window parent, @Nullable Cancellable cancellable, FileDialog.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      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.
      Parameter:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      user_data - data to pass to @callback
    • openFinish

      public File openFinish(@Nonnull AsyncResult result) throws AllocationError
      Finishes the [method@Gtk.FileDialog.open] call.
      Parameter:
      result - the result
      Gibt zurück:
      the file that was selected
      Löst aus:
      AllocationError
    • openMultiple

      public void openMultiple(@Nullable Window parent, @Nullable Cancellable cancellable, FileDialog.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      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
      [property@Gtk.FileDialog:initial-folder].

      The @callback will be called when the dialog is dismissed.
      Parameter:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      user_data - data to pass to @callback
    • openMultipleFinish

      public ListModel openMultipleFinish(@Nonnull AsyncResult result) throws AllocationError
      Finishes the [method@Gtk.FileDialog.open] call.
      Parameter:
      result - the result
      Gibt zurück:
      the files that were selected, as a list model of [iface@Gio.File]
      Löst aus:
      AllocationError
    • openMultipleTextFiles

      public void openMultipleTextFiles(@Nullable Window parent, @Nullable Cancellable cancellable, FileDialog.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      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
      [property@Gtk.FileDialog:initial-folder].

      In contrast to [method@Gtk.FileDialog.open], this function
      lets the user select the text encoding for the files, if possible.

      The @callback will be called when the dialog is dismissed.
      Parameter:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      user_data - data to pass to @callback
    • openMultipleTextFilesFinish

      public ListModel openMultipleTextFilesFinish(@Nonnull AsyncResult result, @Nonnull Strs encoding) throws AllocationError
      Finishes the [method@Gtk.FileDialog.open] call.
      Parameter:
      result - the result
      encoding - return location for the text encoding to use
      Gibt zurück:
      the files that were selected, as a list model of [iface@Gio.File]
      Löst aus:
      AllocationError
    • openTextFile

      public void openTextFile(@Nullable Window parent, @Nullable Cancellable cancellable, FileDialog.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Initiates a file selection operation by presenting a file chooser
      dialog to the user.

      In contrast to [method@Gtk.FileDialog.open], this function
      lets the user select the text encoding for the file, if possible.

      The @callback will be called when the dialog is dismissed.
      Parameter:
      parent - the parent `GtkWindow`
      cancellable - a `GCancellable` to cancel the operation
      callback - a callback to call when the operation is complete
      user_data - data to pass to @callback
    • openTextFileFinish

      public File openTextFileFinish(@Nonnull AsyncResult result, @Nonnull Strs encoding) throws AllocationError
      Finishes the [method@Gtk.FileDialog.open_text_file] 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
      be `NULL`.
      Parameter:
      result - a `GAsyncResult`
      encoding - return location for the text encoding to use
      Gibt zurück:
      the file that was selected
      Löst aus:
      AllocationError
    • save

      public void save(@Nullable Window parent, @Nullable Cancellable cancellable, FileDialog.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      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.
      Parameter:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      user_data - data to pass to @callback
    • saveFinish

      public File saveFinish(@Nonnull AsyncResult result) throws AllocationError
      Finishes the [method@Gtk.FileDialog.save] call.
      Parameter:
      result - the result
      Gibt zurück:
      the file that was selected
      Löst aus:
      AllocationError
    • saveTextFile

      public void saveTextFile(@Nullable Window parent, @Nullable Cancellable cancellable, FileDialog.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Initiates a file save operation by presenting a file chooser
      dialog to the user.

      In contrast to [method@Gtk.FileDialog.save], 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.
      Parameter:
      parent - the parent `GtkWindow`
      cancellable - a `GCancellable` to cancel the operation
      callback - a callback to call when the operation is complete
      user_data - data to pass to @callback
    • saveTextFileFinish

      public File saveTextFileFinish(@Nonnull AsyncResult result, @Nonnull Strs encoding, @Nonnull Strs line_ending) throws AllocationError
      Finishes the [method@Gtk.FileDialog.save_text_file] 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
      be `NULL`.

      The @line_ending will be set to one of "\n", "\r\n", "\r" or "",
      where the latter means to preserve existing line endings.
      Parameter:
      result - a `GAsyncResult`
      encoding - return location for the text encoding to use
      line_ending - return location for the line endings to use
      Gibt zurück:
      the file that was selected. Otherwise, `NULL` is returned and @error is set
      Löst aus:
      AllocationError
    • selectFolder

      public void selectFolder(@Nullable Window parent, @Nullable Cancellable cancellable, FileDialog.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Presents a file chooser dialog to the user.

      The file chooser dialog will be set up to select a single folder.

      If you pass @initial_folder, the file chooser dialog will initially
      be opened in the parent directory of that folder, otherwise, it
      will be in the directory [property@Gtk.FileDialog:initial-folder].

      The @callback will be called when the dialog is dismissed.
      Parameter:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      user_data - data to pass to @callback
    • selectFolderFinish

      public File selectFolderFinish(@Nonnull AsyncResult result) throws AllocationError
      Finishes the [method@Gtk.FileDialog.select_folder] call.
      Parameter:
      result - the result
      Gibt zurück:
      the folder that was selected
      Löst aus:
      AllocationError
    • selectMultipleFolders

      public void selectMultipleFolders(@Nullable Window parent, @Nullable Cancellable cancellable, FileDialog.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      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 [property@Gtk.FileDialog:initial-folder].

      The @callback will be called when the dialog is dismissed.
      Parameter:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      user_data - data to pass to @callback
    • selectMultipleFoldersFinish

      public ListModel selectMultipleFoldersFinish(@Nonnull AsyncResult result) throws AllocationError
      Finishes the [method@Gtk.FileDialog.select_multiple_folders] call.
      Parameter:
      result - the result
      Gibt zurück:
      the folders that were selected, as a list model of [iface@Gio.File]
      Löst aus:
      AllocationError
    • setAcceptLabel

      public void setAcceptLabel(@Nullable Str accept_label)
      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.
      Parameter:
      accept_label - the new accept label
    • setAcceptLabel

      public void setAcceptLabel(String accept_label)
      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.
      Parameter:
      accept_label - the new accept label
    • setDefaultFilter

      public void setDefaultFilter(@Nullable FileFilter filter)
      Sets the filter that will be selected by default
      in the file chooser dialog.

      If set to `NULL`, the first item in [property@Gtk.FileDialog:filters]
      will be used as the default filter. If that list is empty, the dialog
      will be unfiltered.
      Parameter:
      filter - the file filter
    • setFilters

      public void setFilters(@Nullable ListModel filters)
      Sets the filters that will be offered to the user
      in the file chooser dialog.
      Parameter:
      filters - a list model of [class@Gtk.FileFilter]
    • setInitialFile

      public void setInitialFile(@Nullable File file)
      Sets the file that will be initially selected in
      the file chooser dialog.

      This function is a shortcut for calling both
      [method@Gtk.FileDialog.set_initial_folder] and
      [method@Gtk.FileDialog.set_initial_name] with the
      directory and name of @file, respectively.
      Parameter:
      file - a file
    • setInitialFolder

      public void setInitialFolder(@Nullable File folder)
      Sets the folder that will be set as the
      initial folder in the file chooser dialog.
      Parameter:
      folder - a file
    • setInitialName

      public void setInitialName(@Nullable Str name)
      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 [property@Gtk.FileDialog:initial-folder], the dialog will
      preselect it.
      Parameter:
      name - a string
    • setInitialName

      public void setInitialName(String name)
      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 [property@Gtk.FileDialog:initial-folder], the dialog will
      preselect it.
      Parameter:
      name - a string
    • setModal

      public void setModal(boolean modal)
      Sets whether the file chooser dialog blocks interaction
      with the parent window while it is presented.
      Parameter:
      modal - the new value
    • setTitle

      public void setTitle(@Nonnull Str title)
      Sets the title that will be shown on the file chooser dialog.
      Parameter:
      title - the new title
    • setTitle

      public void setTitle(String title)
      Sets the title that will be shown on the file chooser dialog.
      Parameter:
      title - the new title
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()