1.36 <GFileMonitor>

Class: <GFileMonitor>

It derives from <GObject>.

Monitors a file or directory for changes.

To obtain a <GFileMonitor> for a file or directory, use file:monitor, file:monitor-file, or file:monitor-directory.

To get informed about changes to the file or directory you are monitoring, connect to the file-monitor:changed signal. The signal will be emitted in the thread-default main context (see main-context:push-thread-default) of the thread that the monitor was created in (though if the global default main context is blocked, this may cause notifications to be blocked even if the thread-default context is still running).

Fields

parent-instance

Properties

Property: file-monitor:cancelled self

Whether the monitor has been cancelled.

Its value is a boolean.

It is read only.

Property: file-monitor:rate-limit self

The limit of the monitor to watch for changes, in milliseconds.

Its value is a 32-bit integer.

Set it with (set! (file-monitor:rate-limit self) value).

Procedures

Method: file-monitor:cancel? self ⇒ %return
Method: cancel? self ⇒ %return

Cancels a file monitor.

self

Passed: a <GFileMonitor>.

a <GFileMonitor>.

%return

Returned: a boolean.

always #t

Method: file-monitor:emit-event self child other-file event-type
Method: emit-event self child other-file event-type

Emits the file-monitor:changed signal if a change has taken place. Should be called from file monitor implementations only.

Implementations are responsible to call this method from the thread-default main context (see main-context:push-thread-default) of the thread that the monitor was created in.

self

Passed: a <GFileMonitor>.

a <GFileMonitor>.

child

Passed: a <GFile>.

a <GFile>.

other-file

Passed: a <GFile>, or #f.

a <GFile>, or #f.

event-type

Passed: a <GFileMonitorEvent>, or one of its symbols.

a set of <GFileMonitorEvent> flags.

Method: file-monitor:is-cancelled? self ⇒ %return
Method: is-cancelled? self ⇒ %return

Returns whether the monitor is canceled.

self

Passed: a <GFileMonitor>.

a <GFileMonitor>

%return

Returned: a boolean.

#t if monitor is canceled. #f otherwise.

Method: file-monitor:set-rate-limit self limit-msecs
Method: set-rate-limit self limit-msecs

Sets the rate limit to which the self will report consecutive change events to the same file.

self

Passed: a <GFileMonitor>.

a <GFileMonitor>.

limit-msecs

Passed: a 32-bit integer.

a non-negative integer with the limit in milliseconds to poll for changes

Signals

Signal: file-monitor:changed

Connect a handler with (connect object file-monitor:changed handler). It is called as (handler self file other-file event-type).

Emitted when file has been changed.

If using watch-moves on a directory monitor, and the information is available (and if supported by the backend), event-type may be renamed, moved-in or 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 moved-in as equivalent to created and moved-out as equivalent to deleted, with extra information. renamed is equivalent to a delete/create pair. This is exactly how the events will be reported in the case that the watch-moves flag is not in use.

If using the deprecated flag send-moved flag and event-type is moved, file will be set to a <GFile> containing the old path, and other-file will be set to a <GFile> containing the new path.

In all the other cases, other-file will be set to NULL.

self

Passed: a <GFileMonitor>.

file

Passed: a <GFile>.

a <GFile>.

other-file

Passed: a <GFile>, or #f.

a <GFile> or NULL.

event-type

Passed: a <GFileMonitorEvent>.

a <GFileMonitorEvent>.

Virtual methods

Virtual method: file-monitor:do-cancel implementor self ⇒ %return

Cancels a file monitor.

To override it in a new class, give register-type #:vfuncs `((cancel . ,procedure)). The procedure is called as (procedure self) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GFileMonitor>, or a class that derives from it, or its GType number.

self

Passed: a <GFileMonitor>.

a <GFileMonitor>.

%return

Returned: a boolean.

always #t

Virtual method: file-monitor:do-changed implementor self file other-file event-type

To override it in a new class, give register-type #:vfuncs `((changed . ,procedure)). The procedure is called as (procedure self file other-file event-type).

implementor

Passed: the class whose implementation to call: <GFileMonitor>, or a class that derives from it, or its GType number.

self

Passed: a <GFileMonitor>.

file

Passed: a <GFile>.

other-file

Passed: a <GFile>.

event-type

Passed: a <GFileMonitorEvent>, or one of its symbols.