Class DirectoryList<T extends GObject>
- All Implemented Interfaces:
Proxy
,ListModelJavaList<T>
,Iterable<T>
,Collection<T>
,List<T>
,SequencedCollection<T>
,ListModel<T>
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 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 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
DirectoryList.Builder<B extends DirectoryList.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
DirectoryList.DirectoryListClass<T extends GObject>
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModelImpl, ListModel.ListModelInterface
-
Constructor Summary
ConstructorDescriptionDirectoryList
(@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 DirectoryList
asParent()
Returns this instance as if it were its parent type.static DirectoryList.Builder
<? extends DirectoryList.Builder> builder()
ADirectoryList.Builder
object constructs aDirectoryList
with the specified properties.Gets the attributes queried on the children.getError()
Gets the loading error, if any.getFile()
Gets the file whose children are currently enumerated.int
Gets the IO priority set via gtk_directory_list_set_io_priority().boolean
Returns whether the directory list is monitoring the directory for changes.static Type
getType()
Get the GType of the DirectoryList classboolean
Returnstrue
if the children enumeration is currently in progress.void
setAttributes
(@Nullable String attributes) Sets theattributes
to be enumerated and starts the enumeration.void
Sets thefile
to be enumerated and starts the enumeration.void
setIoPriority
(int ioPriority) Sets the IO priority to use while loading directories.void
setMonitored
(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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
Methods inherited from interface org.gnome.gio.ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChanged
Methods inherited from interface io.github.jwharm.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
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, 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
null
if 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:
true
if the directory is monitored
-
isLoading
public boolean isLoading()Returnstrue
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
Sets theattributes
to be enumerated and starts the enumeration.If
attributes
isnull
, 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 thefile
to be enumerated and starts the enumeration.If
file
isnull
, the result will be an empty list.- Parameters:
file
- theGFile
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 likeG_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
ADirectoryList.Builder
object constructs aDirectoryList
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withDirectoryList.Builder.build()
.
-