GtkDirectoryList

GtkDirectoryList — A list model for directory listings

Properties

gchar * attributes Read / Write
GError * error Read
GFile * file Read / Write
gint io-priority Read / Write
GType * item-type Read
gboolean loading Read

Types and Values

Object Hierarchy

    GObject
    ╰── GtkDirectoryList

Implemented Interfaces

GtkDirectoryList implements GListModel.

Includes

#include <gtk/gtk.h>

Description

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 GtkDirectoryList:file property is set.

While the GtkDirectoryList is being filled, the GtkDirectoryList: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 GtkDirectoryList: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.

Functions

gtk_directory_list_new ()

GtkDirectoryList *
gtk_directory_list_new (const char *attributes,
                        GFile *file);

Creates a new GtkDirectoryList querying the given file with the given attributes .

Parameters

file

The file to query.

[allow-none]

attributes

The attributes to query with.

[allow-none]

Returns

a new GtkDirectoryList


gtk_directory_list_get_attributes ()

const char *
gtk_directory_list_get_attributes (GtkDirectoryList *self);

Gets the attributes queried on the children.

Parameters

self

a GtkDirectoryList

 

Returns

The queried attributes.

[nullable][transfer none]


gtk_directory_list_set_attributes ()

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.

Parameters

self

a GtkDirectoryList

 

attributes

the attributes to enumerate.

[allow-none]

gtk_directory_list_get_file ()

GFile *
gtk_directory_list_get_file (GtkDirectoryList *self);

Gets the file whose children are currently enumerated.

Parameters

self

a GtkDirectoryList

 

Returns

The file whose children are enumerated.

[nullable][transfer none]


gtk_directory_list_set_file ()

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.

Parameters

self

a GtkDirectoryList

 

file

the GFile to be enumerated.

[allow-none]

gtk_directory_list_get_io_priority ()

int
gtk_directory_list_get_io_priority (GtkDirectoryList *self);

Gets the IO priority set via gtk_directory_list_set_io_priority().

Parameters

self

a GtkDirectoryList

 

Returns

The IO priority.


gtk_directory_list_set_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 parrallel, lowering it to something like G_PRIORITY_DEFAULT_IDLE may increase responsiveness.

Parameters

self

a GtkDirectoryList

 

io_priority

IO priority to use

 

gtk_directory_list_is_loading ()

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 inbetween runs.

Parameters

self

a GtkDirectoryList

 

Returns

TRUE if self is loading


gtk_directory_list_get_error ()

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.

Parameters

self

a GtkDirectoryList

 

Returns

The loading error or NULL if loading finished successfully.

[nullable][transfer none]

Types and Values

GtkDirectoryList

typedef struct _GtkDirectoryList GtkDirectoryList;

Property Details

The “attributes” property

  “attributes”               gchar *

The attributes to query

Owner: GtkDirectoryList

Flags: Read / Write

Default value: NULL


The “error” property

  “error”                    GError *

Error encountered while loading files

Owner: GtkDirectoryList

Flags: Read


The “file” property

  “file”                     GFile *

File to query

Owner: GtkDirectoryList

Flags: Read / Write


The “io-priority” property

  “io-priority”              gint

Priority used when loading

Owner: GtkDirectoryList

Flags: Read / Write

Allowed values: >= -2147483647

Default value: 0


The “item-type” property

  “item-type”                GType *

The GType for elements of this object

Owner: GtkDirectoryList

Flags: Read

Allowed values: GFileInfo


The “loading” property

  “loading”                  gboolean

TRUE if files are being loaded

Owner: GtkDirectoryList

Flags: Read

Default value: FALSE

See Also

GListModel, g_file_enumerate_children()