Gtk.DirectoryList

g GObject.GInterface GObject.GInterface Gio.ListModel Gio.ListModel GObject.GInterface->Gio.ListModel GObject.Object GObject.Object Gtk.DirectoryList Gtk.DirectoryList GObject.Object->Gtk.DirectoryList Gio.ListModel->Gtk.DirectoryList

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.ListModel (4)

Structs:

GObject.ObjectClass (5)

class

new (attributes, file)

get_attributes ()

get_error ()

get_file ()

get_io_priority ()

get_monitored ()

is_loading ()

set_attributes (attributes)

set_file (file)

set_io_priority (io_priority)

set_monitored (monitored)

Virtual Methods

Inherited:

GObject.Object (7), Gio.ListModel (3)

Properties

Name

Type

Flags

Short Description

attributes

str

r/w/en

error

GLib.Error

r/en

file

Gio.File

r/w/en

io-priority

int

r/w/en

item-type

GObject.GType

r

loading

bool

r/en

monitored

bool

r/w/en

n-items

int

r

Signals

Inherited:

GObject.Object (1), Gio.ListModel (1)

Fields

Inherited:

GObject.Object (1), Gio.ListModel (1)

Class Details

class Gtk.DirectoryList(**kwargs)
Bases:

GObject.Object, Gio.ListModel

Abstract:

No

Structure:

Gtk.DirectoryListClass

GtkDirectoryList is a list model that wraps Gio.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 a the [property`Gtk`.DirectoryList:file] property is set.

While the GtkDirectoryList is being filled, the [property`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 [property`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 Gio.FileEnumerator.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.

classmethod new(attributes, file)[source]
Parameters:
  • attributes (str or None) – The attributes to query with

  • file (Gio.File or None) – The file to query

Returns:

a new GtkDirectoryList

Return type:

Gtk.DirectoryList

Creates a new GtkDirectoryList.

The GtkDirectoryList is querying the given file with the given attributes.

get_attributes()[source]
Returns:

The queried attributes

Return type:

str or None

Gets the attributes queried on the children.

get_error()[source]
Returns:

The loading error or None if loading finished successfully

Return type:

GLib.Error or 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_file()[source]
Returns:

The file whose children are enumerated

Return type:

Gio.File or None

Gets the file whose children are currently enumerated.

get_io_priority()[source]
Returns:

The IO priority.

Return type:

int

Gets the IO priority set via Gtk.DirectoryList.set_io_priority().

get_monitored()[source]
Returns:

True if the directory is monitored

Return type:

bool

Returns whether the directory list is monitoring the directory for changes.

is_loading()[source]
Returns:

True if self is loading

Return type:

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)[source]
Parameters:

attributes (str or None) – the attributes to enumerate

Sets the attributes to be enumerated and starts the enumeration.

If attributes is None, the list of file infos will still be created, it will just not contain any extra attributes.

set_file(file)[source]
Parameters:

file (Gio.File or None) – the GFile to be enumerated

Sets the file to be enumerated and starts the enumeration.

If file is None, the result will be an empty list.

set_io_priority(io_priority)[source]
Parameters:

io_priority (int) – IO priority to use

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 GLib.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 GLib.PRIORITY_DEFAULT_IDLE may increase responsiveness.

set_monitored(monitored)[source]
Parameters:

monitored (bool) – True to monitor the directory for changes

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.

Property Details

Gtk.DirectoryList.props.attributes
Name:

attributes

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The attributes to query.

Gtk.DirectoryList.props.error
Name:

error

Type:

GLib.Error

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

Error encountered while loading files.

Gtk.DirectoryList.props.file
Name:

file

Type:

Gio.File

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

File to query.

Gtk.DirectoryList.props.io_priority
Name:

io-priority

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Priority used when loading.

Gtk.DirectoryList.props.item_type
Name:

item-type

Type:

GObject.GType

Default Value:

<GType GFileInfo>

Flags:

READABLE

The type of items. See [method`Gio`.ListModel.get_item_type].

New in version 4.8.

Gtk.DirectoryList.props.loading
Name:

loading

Type:

bool

Default Value:

False

Flags:

READABLE, EXPLICIT_NOTIFY

True if files are being loaded.

Gtk.DirectoryList.props.monitored
Name:

monitored

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

True if the directory is monitored for changed.

Gtk.DirectoryList.props.n_items
Name:

n-items

Type:

int

Default Value:

0

Flags:

READABLE

The number of items. See [method`Gio`.ListModel.get_n_items].

New in version 4.8.