Class DirectoryList
- All Implemented Interfaces:
Iterable<FileInfo>,Collection<FileInfo>,List<FileInfo>,SequencedCollection<FileInfo>,ListModel<FileInfo>,Proxy,ListModelJavaList<FileInfo>
File.enumerateChildrenAsync(java.lang.String, java.util.Set<org.gnome.gio.FileQueryInfoFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback).
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDirectoryList.Builder<B extends DirectoryList.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModel$Impl, ListModel.ListModelInterfaceNested classes/interfaces inherited from interface org.javagi.gio.ListModelJavaList
ListModelJavaList.SubList<E extends @Nullable GObject,List extends ListModelJavaList<E>> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DirectoryList.DirectoryList(@Nullable String attributes, @Nullable File file) Creates a newGtkDirectoryList.DirectoryList(MemorySegment address) Create a DirectoryList proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected DirectoryListasParent()Returns this instance as if it were its parent type.static DirectoryList.Builder<? extends DirectoryList.Builder> builder()ADirectoryList.Builderobject constructs aDirectoryListwith the specified properties.@Nullable StringGets the attributes queried on the children.@Nullable GErrorgetError()Gets the loading error, if any.@Nullable FilegetFile()Gets the file whose children are currently enumerated.intGets the IO priority set via gtk_directory_list_set_io_priority().booleanReturns whether the directory list is monitoring the directory for changes.static @Nullable TypegetType()Get the GType of the DirectoryList classbooleanReturnstrueif the children enumeration is currently in progress.voidsetAttributes(@Nullable String attributes) Sets theattributesto be enumerated and starts the enumeration.voidSets thefileto be enumerated and starts the enumeration.voidsetIoPriority(int ioPriority) Sets the IO priority to use while loading directories.voidsetMonitored(boolean monitored) Sets whether the directory list will monitor the directory for changes.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliteratorMethods inherited from interface org.gnome.gio.ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChangedMethods inherited from interface org.javagi.gio.ListModelJavaList
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
-
Constructor Details
-
DirectoryList
Create a DirectoryList proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
DirectoryList
-
DirectoryList
public DirectoryList()Creates a new DirectoryList.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getAttributes
Gets the attributes queried on the children.- Returns:
- The queried attributes
-
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
nullif loading finished successfully
-
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:
trueif the directory is monitored
-
isLoading
public boolean isLoading()Returnstrueif 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:
trueif this DirectoryList is loading
-
setAttributes
Sets theattributesto be enumerated and starts the enumeration.If
attributesisnull, the list of file infos will still be created, it will just not contain any extra attributes.- Parameters:
attributes- the attributes to enumerate
-
setFile
Sets thefileto be enumerated and starts the enumeration.If
fileisnull, the result will be an empty list.- Parameters:
file- theGFileto 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 likeG_PRIORITY_DEFAULT_IDLEmay 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-trueto monitor the directory for changes
-
builder
ADirectoryList.Builderobject constructs aDirectoryListwith the specified properties. Use the variousset...()methods to set properties, and finish construction withDirectoryList.Builder.build().- Returns:
- the builder object
-