Class DirectoryList

All Implemented Interfaces:
Iterable<FileInfo>, Collection<FileInfo>, List<FileInfo>, SequencedCollection<FileInfo>, ListModel<FileInfo>, Proxy, ListModelJavaList<FileInfo>

@Generated("org.javagi.JavaGI") public class DirectoryList extends GObject implements ListModel<FileInfo>

A list model that wraps File#enumerateChildrenAsync.

It presents a GListModel and fills it asynchronously with the GFileInfos returned from that function.

Enumeration will start automatically when the Gtk.DirectoryList:file property is set.

While the GtkDirectoryList is being filled, the Gtk.DirectoryList:loading property will be set to true. You can listen to that property if you want to show information like a GtkSpinner or a "Loading..." text.

If loading fails at any point, the Gtk.DirectoryList:error property will be set to give more indication about the failure.

The GFileInfos returned from a GtkDirectoryList have the "standard::file" attribute set to the GFile they refer to. This way you can get at the file that is referred to in the same way you would via g_file_enumerator_get_child(). This means you do not need access to the GtkDirectoryList, but can access the GFile directly from the GFileInfo when operating with a GtkListView or similar.

  • Constructor Details

    • DirectoryList

      public DirectoryList(MemorySegment address)
      Create a DirectoryList instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • DirectoryList

      public DirectoryList(@Nullable String attributes, @Nullable File file)

      Creates a new GtkDirectoryList.

      The GtkDirectoryList is querying the given file with the given attributes.

      Parameters:
      attributes - The attributes to query with
      file - The file to query
    • DirectoryList

      public DirectoryList()
      Create a new DirectoryList.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the DirectoryList class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected DirectoryList asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getAttributes

      public @Nullable String getAttributes()
      Gets the attributes queried on the children.
      Returns:
      The queried attributes
    • getError

      public @Nullable GError getError()

      Gets the loading error, if any.

      If an error occurs during the loading process, the loading process will finish and this property allows querying the error that happened. This error will persist until a file is loaded again.

      An error being set does not mean that no files were loaded, and all successfully queried files will remain in the list.

      Returns:
      The loading error or null if loading finished successfully
    • getFile

      public @Nullable File getFile()
      Gets the file whose children are currently enumerated.
      Returns:
      The file whose children are enumerated
    • getIoPriority

      public int getIoPriority()
      Gets the IO priority set via gtk_directory_list_set_io_priority().
      Returns:
      The IO priority.
    • getMonitored

      public boolean getMonitored()
      Returns whether the directory list is monitoring the directory for changes.
      Returns:
      true if the directory is monitored
    • isLoading

      public boolean isLoading()

      Returns true if the children enumeration is currently in progress.

      Files will be added to this DirectoryList from time to time while loading is going on. The order in which are added is undefined and may change in between runs.

      Returns:
      true if this DirectoryList is loading
    • setAttributes

      public void setAttributes(@Nullable String attributes)

      Sets the attributes to be enumerated and starts the enumeration.

      If attributes is null, the list of file infos will still be created, it will just not contain any extra attributes.

      Parameters:
      attributes - the attributes to enumerate
    • setFile

      public void setFile(@Nullable File file)

      Sets the file to be enumerated and starts the enumeration.

      If file is null, the result will be an empty list.

      Parameters:
      file - the GFile to be enumerated
    • setIoPriority

      public void setIoPriority(int ioPriority)

      Sets the IO priority to use while loading directories.

      Setting the priority while this DirectoryList is loading will reprioritize the ongoing load as soon as possible.

      The default IO priority is G_PRIORITY_DEFAULT, which is higher than the GTK redraw priority. If you are loading a lot of directories in parallel, lowering it to something like G_PRIORITY_DEFAULT_IDLE may increase responsiveness.

      Parameters:
      ioPriority - IO priority to use
    • setMonitored

      public void setMonitored(boolean monitored)

      Sets whether the directory list will monitor the directory for changes.

      If monitoring is enabled, the ::items-changed signal will be emitted when the directory contents change.

      When monitoring is turned on after the initial creation of the directory list, the directory is reloaded to avoid missing files that appeared between the initial loading and when monitoring was turned on.

      Parameters:
      monitored - true to monitor the directory for changes
    • builder

      public static DirectoryList.Builder<? extends DirectoryList.Builder> builder()
      A DirectoryList.Builder object constructs a DirectoryList with the specified properties. Use the various set...() methods to set properties, and finish construction with DirectoryList.Builder.build().
      Returns:
      the builder object