GtkDirectoryList — A list model for directory listings
GtkDirectoryList * | gtk_directory_list_new () |
const char * | gtk_directory_list_get_attributes () |
void | gtk_directory_list_set_attributes () |
GFile * | gtk_directory_list_get_file () |
void | gtk_directory_list_set_file () |
int | gtk_directory_list_get_io_priority () |
void | gtk_directory_list_set_io_priority () |
gboolean | gtk_directory_list_get_monitored () |
void | gtk_directory_list_set_monitored () |
gboolean | gtk_directory_list_is_loading () |
const GError * | gtk_directory_list_get_error () |
char * | attributes | Read / Write |
GError * | error | Read |
GFile * | file | Read / Write |
int | io-priority | Read / Write |
gboolean | loading | Read |
gboolean | monitored | Read / Write |
GObject ╰── GtkDirectoryList
GtkDirectoryList implements GListModel.
#include <gtk/gtk.h>
GtkDirectoryList is a list model that wraps g_file_enumerate_children_async()
. It presents a GListModel and fills it asynchronously with the GFileInfos returned from that function.
Enumeration will start automatically when a 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 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.
GtkDirectoryList * gtk_directory_list_new (const char *attributes
,GFile *file
);
Creates a new GtkDirectoryList querying the given file
with the given attributes
.
file | The file to query. | [allow-none] |
attributes | The attributes to query with. | [allow-none] |
a new GtkDirectoryList
const char *
gtk_directory_list_get_attributes (GtkDirectoryList *self
);
Gets the attributes queried on the children.
self |
The queried attributes.
[nullable][transfer none]
void gtk_directory_list_set_attributes (GtkDirectoryList *self
,const char *attributes
);
Sets the attributes
to be enumerated and starts the enumeration.
If attributes
is NULL
, no attributes will be queried, but a list of GFileInfos will still be created.
self | ||
attributes | the attributes to enumerate. | [allow-none] |
GFile *
gtk_directory_list_get_file (GtkDirectoryList *self
);
Gets the file whose children are currently enumerated.
self |
The file whose children are enumerated.
[nullable][transfer none]
void gtk_directory_list_set_file (GtkDirectoryList *self
,GFile *file
);
Sets the file
to be enumerated and starts the enumeration.
If file
is NULL
, the result will be an empty list.
self | ||
file | the GFile to be enumerated. | [allow-none] |
int
gtk_directory_list_get_io_priority (GtkDirectoryList *self
);
Gets the IO priority set via gtk_directory_list_set_io_priority()
.
self |
The IO priority.
void gtk_directory_list_set_io_priority (GtkDirectoryList *self
,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.
self | ||
io_priority | IO priority to use |
gboolean
gtk_directory_list_get_monitored (GtkDirectoryList *self
);
Returns whether the directory list is monitoring the directory for changes.
self |
TRUE
if the directory is monitored
void gtk_directory_list_set_monitored (GtkDirectoryList *self
,gboolean 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.
self | ||
monitored |
|
gboolean
gtk_directory_list_is_loading (GtkDirectoryList *self
);
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.
self |
TRUE
if self
is loading
const GError *
gtk_directory_list_get_error (GtkDirectoryList *self
);
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.
self |
The loading error or NULL
if loading finished successfully.
[nullable][transfer none]
typedef struct _GtkDirectoryList GtkDirectoryList;
“attributes”
property“attributes” char *
The attributes to query
Owner: GtkDirectoryList
Flags: Read / Write
Default value: NULL
“error”
property“error” GError *
Error encountered while loading files
Owner: GtkDirectoryList
Flags: Read
“file”
property“file” GFile *
File to query
Owner: GtkDirectoryList
Flags: Read / Write
“io-priority”
property“io-priority” int
Priority used when loading
Owner: GtkDirectoryList
Flags: Read / Write
Allowed values: >= -2147483647
Default value: 0
“loading”
property“loading” gboolean
TRUE
if files are being loaded
Owner: GtkDirectoryList
Flags: Read
Default value: FALSE
“monitored”
property“monitored” gboolean
TRUE
if the directory is monitored for changed
Owner: GtkDirectoryList
Flags: Read / Write
Default value: TRUE
GListModel, g_file_enumerate_children()
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkDirectoryList.html