DirectoryList#
Superclasses: Object
Implemented Interfaces: ListModel
GtkDirectoryList
is a list model that wraps enumerate_children_async()
.
It presents a GListModel
and fills it asynchronously with the GFileInfo
’s
returned from that function.
Enumeration will start automatically when the
file
property is set.
While the GtkDirectoryList
is being filled, the
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 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 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.
Constructors#
Methods#
- class DirectoryList
-
- get_error() GError | None #
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.
- get_io_priority() int #
Gets the IO priority set via
set_io_priority()
.
- is_loading() bool #
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.
- set_attributes(attributes: str | None = None) None #
Sets the
attributes
to be enumerated and starts the enumeration.If
attributes
isNone
, the list of file infos will still be created, it will just not contain any extra attributes.- Parameters:
attributes – the attributes to enumerate
- set_file(file: File | None = None) None #
Sets the
file
to be enumerated and starts the enumeration.If
file
isNone
, the result will be an empty list.- Parameters:
file – the
GFile
to be enumerated
- set_io_priority(io_priority: int) None #
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
- set_monitored(monitored: bool) None #
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
Properties#
- class DirectoryList
-
- props.error: GError#
The type of the None singleton.