FileMonitor
Superclasses: Object
- Constructors:
FileMonitor(**properties)
Methods
- class FileMonitor
-
- emit_event(child: File, other_file: File, event_type: FileMonitorEvent) None
Emits the
FileMonitor
::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][g-main-context-push-thread-default] of the thread that the monitor was created in.
- Parameters:
child – a
File
.other_file – a
File
.event_type – a set of
FileMonitorEvent
flags.
Properties
Signals
- class FileMonitor.signals
- changed(file: File, other_file: File | None, event_type: FileMonitorEvent) None
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 beRENAMED
,MOVED_IN
orMOVED_OUT
.In all cases
file
will be a child of the monitored directory. For renames,file
will be the old name andother_file
is the new name. For “moved in” events,file
is the name of the file that appeared andother_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 andother_file
is the name of the file at its new location.It makes sense to treat
MOVED_IN
as equivalent toCREATED
andMOVED_OUT
as equivalent toDELETED
, with extra information.RENAMED
is equivalent to a delete/create pair. This is exactly how the events will be reported in the case that theWATCH_MOVES
flag is not in use.If using the deprecated flag
SEND_MOVED
flag andevent_type
isMOVED
,file
will be set to aFile
containing the old path, andother_file
will be set to aFile
containing the new path.In all the other cases,
other_file
will be set toNone
.- Parameters:
file – a
File
.other_file – a
File
orNone
.event_type – a
FileMonitorEvent
.