org.gnome.gtk

## Interface FileChooser

- All Known Implementing Classes:
    FileChooserButton, FileChooserDialog, FileChooserWidget

      public interface FileChooser

  Widgets which allow you to select a file or directory. GNOME has a unified FileChooser which is used by all applications to select files. It comes in several pre-baked forms, notably `FileChooserDialog` (a Dialog which can be used as a modal popup), and `FileChooserButton` (which is a Button which displays the selected filename and pops up a FileChooserDialog when activated).

  Be aware that much of FileChooser's internal behaviour depends on the main loop cycling; calls to methods like `setCurrentFolder()` and `setFilename()` will not actually take effect until you start the main loop or return from the current signal handler (as the case may be).

  Since:
    4.0.2
  Author:
    Andrew Cowie, Vreixo Formoso

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addFilter(FileFilter filter)` Add a FileFilter to the list of filters that the user can select between.
    `FileChooserAction` | `getAction()` Gets the type of operation that the file chooser is performing.
    `String` | `getCurrentFolder()` Get the current folder being displayed in this FileChooser.
    `String` | `getFilename()` Get the filename currently selected by this FileChooser.
    `FileFilter` | `getFilter()` Gets the current filter.
    `URI` | `getURI()` Get the URI representing the file or directory currently selected by this FileChooser.
    `void` | `setAction(FileChooserAction action)` Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action.
    `boolean` | `setCurrentFolder(String directory)` Set the current directory for this FileChooser.
    `boolean` | `setFilename(String filename)` Set the file you want selected in the FileChooser.
    `void` | `setFilter(FileFilter filter)` Sets the current filter; only the files that pass the filter will be displayed.

- - ### Method Detail

    - #### addFilter

          void addFilter(FileFilter filter)

      Add a FileFilter to the list of filters that the user can select between. When a filter is selected, only files that are passed by that filter are displayed.
      Since:
        4.0.12
      See Also:
        `FileFilter`

    - #### getAction

          FileChooserAction getAction()

      Gets the type of operation that the file chooser is performing.
      Since:
        4.0.3
      See Also:
        `setAction(FileChooserAction)`

    - #### getCurrentFolder

          String getCurrentFolder()

      Get the current folder being displayed in this FileChooser. Note that this is not the same as the currently-selected folder if the FileChooser is in `SELECT_FOLDER` mode. To get the currently-selected folder in that mode, you can use `getURI()` instead.
      Returns:
        The current folder, or `null` if if the FileChooser was unable to load the last folder that was requested of it (as would happen if calling `setCurrentFolder(String)` on a nonexistent directory).
      Since:
        4.0.2
      See Also:
        `getFilename()`

    - #### getFilename

          String getFilename()

      Get the filename currently selected by this FileChooser.
      Returns:
        The filename, or if no file is selected then this will return `null`. If multiple files are selected, one of the filenames will be returned at random. If the FileChooser is in one of the folder modes, this returns the selected folder's name.
      Since:
        4.0.2

    - #### getFilter

          FileFilter getFilter()

      Gets the current filter.

      This function is specially useful on "Save" FileChoosers, to know the file type chosen by the user.

      Since:
        4.0.12
      See Also:
        `FileFilter`

    - #### getURI

          URI getURI()

      Get the URI representing the file or directory currently selected by this FileChooser.
      Returns:
        The selected file's URI, or if no file is selected then this will return `null`. If multiple files are selected, one of the filenames will be returned at random. If the FileChooser is in one of the folder modes, this returns the selected folder's URI.
      Since:
        4.0.2

    - #### setAction

          void setAction(FileChooserAction action)

      Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action. For example, an option to create a new folder might be shown if the action is `SAVE` but not if the action is `OPEN`.
      Since:
        4.0.3

    - #### setCurrentFolder

          boolean setCurrentFolder(String directory)

      Set the current directory for this FileChooser. The user will be shown the full contents of that folder, plus user interface elements for navigating to other folders.
      Parameters:
        `directory` - the full path of the new current folder
      Returns:
        `true` if the folder could be changed successfully, `false` otherwise.
      Since:
        4.0.2

    - #### setFilename

          boolean setFilename(String filename)

      Set the file you want selected in the FileChooser.

      If the folder currently showing in the FileChooser isn't the directory containing the filename you specify, then the FileChooser will be changed to that directory.

      Parameters:
        `filename` - Must be an absolute path.
      Returns:
        `true` if the the directory was changed (if necessary) and a file was successfully selected.
      Since:
        4.0.5

    - #### setFilter

          void setFilter(FileFilter filter)

      Sets the current filter; only the files that pass the filter will be displayed. If the user-selectable list of filters is non-empty, then the filter should be one of the filters in that list.

      Setting the current filter when the list of filters is empty is useful if you want to restrict the displayed set of files without letting the user change it.

      Since:
        4.0.12
      See Also:
        `FileFilter`