gtkmm 4.16.0
|
A list model for directory listings. More...
#include <gtkmm/directorylist.h>
Public Member Functions | |
DirectoryList (DirectoryList &&src) noexcept | |
DirectoryList & | operator= (DirectoryList &&src) noexcept |
~DirectoryList () noexcept override | |
GtkDirectoryList * | gobj () |
Provides access to the underlying C GObject. | |
const GtkDirectoryList * | gobj () const |
Provides access to the underlying C GObject. | |
GtkDirectoryList * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
void | set_file (const Glib::RefPtr< Gio::File > & file) |
Sets the file to be enumerated and starts the enumeration. | |
Glib::RefPtr< Gio::File > | get_file () |
Gets the file whose children are currently enumerated. | |
Glib::RefPtr< const Gio::File > | get_file () const |
Gets the file whose children are currently enumerated. | |
void | set_attributes (const std::string &attributes) |
Sets the attributes to be enumerated and starts the enumeration. | |
std::string | get_attributes () const |
Gets the attributes queried on the children. | |
void | set_io_priority (int io_priority) |
Sets the IO priority to use while loading directories. | |
int | get_io_priority () const |
Gets the IO priority set via set_io_priority(). | |
bool | is_loading () const |
Returns true if the children enumeration is currently in progress. | |
Glib::Error | get_error () const |
Gets the loading error, if any. | |
void | set_monitored (bool monitored=true) |
Sets whether the directory list will monitor the directory for changes. | |
bool | get_monitored () const |
Returns whether the directory list is monitoring the directory for changes. | |
Glib::PropertyProxy< std::string > | property_attributes () |
The attributes to query. | |
Glib::PropertyProxy_ReadOnly< std::string > | property_attributes () const |
The attributes to query. | |
Glib::PropertyProxy_ReadOnly< Glib::Error > | property_error () const |
Error encountered while loading files. | |
Glib::PropertyProxy< Glib::RefPtr< Gio::File > > | property_file () |
File to query. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::File > > | property_file () const |
File to query. | |
Glib::PropertyProxy< int > | property_io_priority () |
Priority used when loading. | |
Glib::PropertyProxy_ReadOnly< int > | property_io_priority () const |
Priority used when loading. | |
Glib::PropertyProxy_ReadOnly< GType > | property_item_type () const |
The type of items. | |
Glib::PropertyProxy_ReadOnly< bool > | property_loading () const |
true if files are being loaded. | |
Glib::PropertyProxy< bool > | property_monitored () |
true if the directory is monitored for changed. | |
Glib::PropertyProxy_ReadOnly< bool > | property_monitored () const |
true if the directory is monitored for changed. | |
Glib::PropertyProxy_ReadOnly< unsigned int > | property_n_items () const |
The number of items. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static Glib::RefPtr< DirectoryList > | create (const std::string &attributes, const Glib::RefPtr< Gio::File > & file={}) |
Protected Member Functions | |
DirectoryList (const std::string &attributes, const Glib::RefPtr< Gio::File > & file={}) | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::DirectoryList > | wrap (GtkDirectoryList *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
A list model for directory listings.
Gtk::DirectoryList is a list model that wraps Gio::File::enumerate_children_async(). It presents a Gio::ListModel and fills it asynchronously with the Gio::FileInfos returned from that function.
Enumeration will start automatically when the property_file() property is set.
While the Gtk::DirectoryList is being filled, the property_loading() property will be set to true
. You can listen to that property if you want to show information like a Gtk::Spinner or a "Loading..." text.
If loading fails at any point, the property_error() property will be set to give more indication about the failure.
The Gio::FileInfos returned from a Gtk::DirectoryList have the "standard::file" attribute set to the Gio::File they refer to. This way you can get at the file that is referred to in the same way you would via Gio::File::enumerator_get_child(). This means you do not need access to the Gtk::DirectoryList but can access the Gio::File directly from the Gio::FileInfo when operating with a Gtk::ListView or similar.
|
noexcept |
|
overridenoexcept |
|
explicitprotected |
|
static |
std::string Gtk::DirectoryList::get_attributes | ( | ) | const |
Gets the attributes queried on the children.
Glib::Error Gtk::DirectoryList::get_error | ( | ) | const |
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.
nullptr
if loading finished successfully. Glib::RefPtr< Gio::File > Gtk::DirectoryList::get_file | ( | ) |
Gets the file whose children are currently enumerated.
Glib::RefPtr< const Gio::File > Gtk::DirectoryList::get_file | ( | ) | const |
Gets the file whose children are currently enumerated.
int Gtk::DirectoryList::get_io_priority | ( | ) | const |
Gets the IO priority set via set_io_priority().
bool Gtk::DirectoryList::get_monitored | ( | ) | const |
Returns whether the directory list is monitoring the directory for changes.
true
if the directory is monitored.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GtkDirectoryList * Gtk::DirectoryList::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool Gtk::DirectoryList::is_loading | ( | ) | const |
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.
true
if self is loading.
|
noexcept |
Glib::PropertyProxy< std::string > Gtk::DirectoryList::property_attributes | ( | ) |
The attributes to query.
Default value: ""
Glib::PropertyProxy_ReadOnly< std::string > Gtk::DirectoryList::property_attributes | ( | ) | const |
The attributes to query.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::Error > Gtk::DirectoryList::property_error | ( | ) | const |
Error encountered while loading files.
Glib::PropertyProxy< Glib::RefPtr< Gio::File > > Gtk::DirectoryList::property_file | ( | ) |
File to query.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::File > > Gtk::DirectoryList::property_file | ( | ) | const |
File to query.
Glib::PropertyProxy< int > Gtk::DirectoryList::property_io_priority | ( | ) |
Priority used when loading.
Default value: 0
Glib::PropertyProxy_ReadOnly< int > Gtk::DirectoryList::property_io_priority | ( | ) | const |
Priority used when loading.
Default value: 0
Glib::PropertyProxy_ReadOnly< GType > Gtk::DirectoryList::property_item_type | ( | ) | const |
The type of items.
See Gio::ListModel::get_item_type().
Glib::PropertyProxy_ReadOnly< bool > Gtk::DirectoryList::property_loading | ( | ) | const |
true
if files are being loaded.
Default value: false
Glib::PropertyProxy< bool > Gtk::DirectoryList::property_monitored | ( | ) |
true
if the directory is monitored for changed.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::DirectoryList::property_monitored | ( | ) | const |
true
if the directory is monitored for changed.
Default value: true
Glib::PropertyProxy_ReadOnly< unsigned int > Gtk::DirectoryList::property_n_items | ( | ) | const |
The number of items.
See Gio::ListModel::get_n_items().
Default value: 0
void Gtk::DirectoryList::set_attributes | ( | const std::string & | attributes | ) |
Sets the attributes to be enumerated and starts the enumeration.
If attributes is nullptr
, the list of file infos will still be created, it will just not contain any extra attributes.
attributes | The attributes to enumerate. |
Sets the file to be enumerated and starts the enumeration.
If file is nullptr
, the result will be an empty list.
file | The Gio::File to be enumerated. |
void Gtk::DirectoryList::set_io_priority | ( | 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 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.
io_priority | IO priority to use. |
Sets whether the directory list will monitor the directory for changes.
If monitoring is enabled, the signal_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.
monitored | true to monitor the directory for changes. |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |