glibmm 2.80.0
|
Monitors a file or directory for changes. More...
#include <giomm/filemonitor.h>
Public Types | |
enum class | Event { CHANGED , CHANGES_DONE_HINT , DELETED , CREATED , ATTRIBUTE_CHANGED , PRE_UNMOUNT , UNMOUNTED , MOVED , RENAMED , MOVED_IN , MOVED_OUT } |
Public Types inherited from Glib::Object | |
using | DestroyNotify = void(*)(gpointer data) |
Public Member Functions | |
FileMonitor (FileMonitor &&src) noexcept | |
FileMonitor & | operator= (FileMonitor &&src) noexcept |
~FileMonitor () noexcept override | |
GFileMonitor * | gobj () |
Provides access to the underlying C GObject. | |
const GFileMonitor * | gobj () const |
Provides access to the underlying C GObject. | |
GFileMonitor * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
bool | cancel () |
Cancels a file monitor. | |
bool | is_cancelled () const |
Returns whether the monitor is canceled. | |
void | set_rate_limit (int limit_msecs) |
Sets the rate limit to which the monitor will report consecutive change events to the same file. | |
Glib::SignalProxy< void(const Glib::RefPtr< File > &, const Glib::RefPtr< File > &, Event)> | signal_changed () |
Glib::PropertyProxy< int > | property_rate_limit () |
The limit of the monitor to watch for changes, in milliseconds. | |
Glib::PropertyProxy_ReadOnly< int > | property_rate_limit () const |
The limit of the monitor to watch for changes, in milliseconds. | |
Glib::PropertyProxy_ReadOnly< bool > | property_cancelled () const |
Whether the monitor has been cancelled. | |
Public Member Functions inherited from Glib::Object | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
void * | get_data (const QueryQuark & key) |
void | set_data (const Quark & key, void *data) |
void | set_data_with_c_callback (const Quark & key, void *data, GDestroyNotify notify) |
void | set_data (const Quark & key, void *data, DestroyNotify notify) |
Prefer set_data_with_c_callback() with a callback with C linkage. | |
void | remove_data (const QueryQuark &quark) |
void * | steal_data (const QueryQuark &quark) |
Public Member Functions inherited from Glib::ObjectBase | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
void | set_property_value (const Glib::ustring & property_name, const Glib::ValueBase & value) |
You probably want to use a specific property_*() accessor method instead. | |
void | get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
void | set_property (const Glib::ustring & property_name, const PropertyType & value) |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
void | get_property (const Glib::ustring & property_name, PropertyType & value) const |
You probably want to use a specific property_*() accessor method instead. | |
template<class PropertyType > | |
PropertyType | get_property (const Glib::ustring & property_name) const |
You probably want to use a specific property_*() accessor method instead. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, const sigc::slot< void()> &slot) |
You can use the signal_changed() signal of the property proxy instead. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot) |
You can use the signal_changed() signal of the property proxy instead. | |
void | freeze_notify () |
Increases the freeze count on object. | |
void | thaw_notify () |
Reverts the effect of a previous call to freeze_notify(). | |
virtual void | reference () const |
Increment the reference count for this object. | |
virtual void | unreference () const |
Decrement the reference count for this object. | |
GObject * | gobj () |
Provides access to the underlying C GObject. | |
const GObject * | gobj () const |
Provides access to the underlying C GObject. | |
GObject * | gobj_copy () const |
Give a ref-ed copy to someone. Use for direct struct access. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Protected Member Functions | |
virtual void | on_changed (const Glib::RefPtr< File > & file, const Glib::RefPtr< File > &other_file, Event event_type) |
This is a default handler for the signal signal_changed(). | |
Protected Member Functions inherited from Glib::Object | |
Object () | |
Object (const Glib::ConstructParams &construct_params) | |
Object (GObject *castitem) | |
~Object () noexcept override | |
Protected Member Functions inherited from Glib::ObjectBase | |
ObjectBase () | |
This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. | |
ObjectBase (const char *custom_type_name) | |
A derived constructor always overrides this choice. | |
ObjectBase (const std::type_info &custom_type_info) | |
This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. | |
ObjectBase (ObjectBase &&src) noexcept | |
ObjectBase & | operator= (ObjectBase &&src) noexcept |
virtual | ~ObjectBase () noexcept=0 |
void | initialize (GObject *castitem) |
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper) |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gio::FileMonitor > | wrap (GFileMonitor *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Related Symbols inherited from Glib::Object | |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
Monitors a file or directory for changes.
To obtain a FileMonitor for a file or directory, use File::monitor_file() or File::monitor_directory().
To get informed about changes to the file or directory you are monitoring, connect to signal_changed().
|
strong |
Enumerator | |
---|---|
CHANGED | A file changed. |
CHANGES_DONE_HINT | A hint that this was probably the last change in a set of changes. |
DELETED | A file was deleted. |
CREATED | A file was created. |
ATTRIBUTE_CHANGED | A file attribute was changed. |
PRE_UNMOUNT | The file location will soon be unmounted. |
UNMOUNTED | The file location was unmounted. |
MOVED | The file was moved – only sent if the (deprecated) Gio::FileMonitorFlags::SEND_MOVED flag is set. |
RENAMED | The file was renamed within the current directory – only sent if the Gio::FileMonitorFlags::WATCH_MOVES flag is set. |
MOVED_IN | The file was moved into the monitored directory from another location – only sent if the Gio::FileMonitorFlags::WATCH_MOVES flag is set. |
MOVED_OUT | The file was moved out of the monitored directory to another location – only sent if the Gio::FileMonitorFlags::WATCH_MOVES flag is set. |
|
noexcept |
|
overridenoexcept |
bool Gio::FileMonitor::cancel | ( | ) |
Cancels a file monitor.
true
. 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.
GFileMonitor * Gio::FileMonitor::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool Gio::FileMonitor::is_cancelled | ( | ) | const |
Returns whether the monitor is canceled.
true
if monitor is canceled. false
otherwise.
|
protectedvirtual |
This is a default handler for the signal signal_changed().
|
noexcept |
Glib::PropertyProxy_ReadOnly< bool > Gio::FileMonitor::property_cancelled | ( | ) | const |
Whether the monitor has been cancelled.
Default value: false
Glib::PropertyProxy< int > Gio::FileMonitor::property_rate_limit | ( | ) |
The limit of the monitor to watch for changes, in milliseconds.
Default value: 800
Glib::PropertyProxy_ReadOnly< int > Gio::FileMonitor::property_rate_limit | ( | ) | const |
The limit of the monitor to watch for changes, in milliseconds.
Default value: 800
Sets the rate limit to which the monitor will report consecutive change events to the same file.
limit_msecs | A non-negative integer with the limit in milliseconds to poll for changes. |
Glib::SignalProxy< void(const Glib::RefPtr< File > &, const Glib::RefPtr< File > &, Event)> Gio::FileMonitor::signal_changed | ( | ) |
void on_my_changed(const Glib::RefPtr<File>& file, const Glib::RefPtr<File>& other_file, Event event_type)
Flags: Run Last
Emitted when file has been changed.
If using Gio::FileMonitorFlags::WATCH_MOVES on a directory monitor, and the information is available (and if supported by the backend), event_type may be Gio::FileMonitor::Event::RENAMED, Gio::FileMonitor::Event::MOVED_IN or Gio::FileMonitor::Event::MOVED_OUT.
In all cases file will be a child of the monitored directory. For renames, file will be the old name and other_file is the new name. For "moved in" events, file is the name of the file that appeared and other_file is the old name that it was moved from (in another directory). For "moved out" events, file is the name of the file that used to be in this directory and other_file is the name of the file at its new location.
It makes sense to treat Gio::FileMonitor::Event::MOVED_IN as equivalent to Gio::FileMonitor::Event::CREATED and Gio::FileMonitor::Event::MOVED_OUT as equivalent to Gio::FileMonitor::Event::DELETED, with extra information. Gio::FileMonitor::Event::RENAMED is equivalent to a delete/create pair. This is exactly how the events will be reported in the case that the Gio::FileMonitorFlags::WATCH_MOVES flag is not in use.
If using the deprecated flag Gio::FileMonitorFlags::SEND_MOVED flag and event_type is Gio::FileMonitor::Event::MOVED, file will be set to a File containing the old path, and other_file will be set to a File containing the new path.
In all the other cases, other_file will be set to #nullptr
.
file | A File. |
other_file | A File or #nullptr . |
event_type | A Gio::FileMonitor::Event. |
|
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. |