Class DirectoryList

All Implemented Interfaces:
PointerInterface

public class DirectoryList extends Object
`GtkDirectoryList` is a list model that wraps g_file_enumerate_children_async().

It presents a `GListModel` and fills it asynchronously with the `GFileInfo`s
returned from that function.

Enumeration will start automatically when a the
[property@Gtk.DirectoryList:file] property is set.

While the `GtkDirectoryList` is being filled, the
[property@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 [property@Gtk.DirectoryList:error]
property will be set to give more indication about the failure.

The `GFileInfo`s 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.

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

  • Constructor Details

    • DirectoryList

      public DirectoryList(PointerContainer pointer)
    • DirectoryList

      public DirectoryList(@Nullable Str 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(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
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getAttributes

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

      public Error 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 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 @self 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 @self is loading
    • setAttributes

      public void setAttributes(@Nullable Str attributes)
      Sets the @attributes to be enumerated and starts the enumeration.

      If @attributes is %NULL, no attributes will be queried, but a list
      of `GFileInfo`s will still be created.
      Parameters:
      attributes - the attributes to enumerate
    • setAttributes

      public void setAttributes(String attributes)
      Sets the @attributes to be enumerated and starts the enumeration.

      If @attributes is %NULL, no attributes will be queried, but a list
      of `GFileInfo`s will still be created.
      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 io_priority)
      Sets the IO priority to use while loading directories.

      Setting the priority while @self 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:
      io_priority - 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
    • asListModel

      public ListModel asListModel()
      Implements interface ListModel. Call this to get access to interface functions.
      Returns:
      ListModel
    • 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()