:right-sidebar: True FileMonitor =================================================================== .. currentmodule:: gi.repository.Gio .. class:: FileMonitor(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: FileMonitor(**properties) Methods ------- .. rst-class:: interim-class .. class:: FileMonitor :no-index: .. method:: cancel() -> bool Cancels a file monitor. .. method:: emit_event(child: ~gi.repository.Gio.File, other_file: ~gi.repository.Gio.File, event_type: ~gi.repository.Gio.FileMonitorEvent) -> None Emits the :obj:`~gi.repository.Gio.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. :param child: a :obj:`~gi.repository.Gio.File`. :param other_file: a :obj:`~gi.repository.Gio.File`. :param event_type: a set of :obj:`~gi.repository.Gio.FileMonitorEvent` flags. .. method:: is_cancelled() -> bool Returns whether the monitor is canceled. .. method:: set_rate_limit(limit_msecs: int) -> None Sets the rate limit to which the ``monitor`` will report consecutive change events to the same file. :param limit_msecs: a non-negative integer with the limit in milliseconds to poll for changes Properties ---------- .. rst-class:: interim-class .. class:: FileMonitor :no-index: .. attribute:: props.cancelled :type: bool Whether the monitor has been cancelled. .. attribute:: props.rate_limit :type: int The limit of the monitor to watch for changes, in milliseconds. Signals ------- .. rst-class:: interim-class .. class:: FileMonitor.signals :no-index: .. method:: changed(file: ~gi.repository.Gio.File, other_file: ~gi.repository.Gio.File | None, event_type: ~gi.repository.Gio.FileMonitorEvent) -> None Emitted when ``file`` has been changed. If using :const:`~gi.repository.Gio.FileMonitorFlags.WATCH_MOVES` on a directory monitor, and the information is available (and if supported by the backend), ``event_type`` may be :const:`~gi.repository.Gio.FileMonitorEvent.RENAMED`, :const:`~gi.repository.Gio.FileMonitorEvent.MOVED_IN` or :const:`~gi.repository.Gio.FileMonitorEvent.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 :const:`~gi.repository.Gio.FileMonitorEvent.MOVED_IN` as equivalent to :const:`~gi.repository.Gio.FileMonitorEvent.CREATED` and :const:`~gi.repository.Gio.FileMonitorEvent.MOVED_OUT` as equivalent to :const:`~gi.repository.Gio.FileMonitorEvent.DELETED`, with extra information. :const:`~gi.repository.Gio.FileMonitorEvent.RENAMED` is equivalent to a delete/create pair. This is exactly how the events will be reported in the case that the :const:`~gi.repository.Gio.FileMonitorFlags.WATCH_MOVES` flag is not in use. If using the deprecated flag :const:`~gi.repository.Gio.FileMonitorFlags.SEND_MOVED` flag and ``event_type`` is :const:`~gi.repository.Gio.FileMonitorEvent.MOVED`, ``file`` will be set to a :obj:`~gi.repository.Gio.File` containing the old path, and ``other_file`` will be set to a :obj:`~gi.repository.Gio.File` containing the new path. In all the other cases, ``other_file`` will be set to :obj:`~gi.repository.None`. :param file: a :obj:`~gi.repository.Gio.File`. :param other_file: a :obj:`~gi.repository.Gio.File` or :obj:`~gi.repository.None`. :param event_type: a :obj:`~gi.repository.Gio.FileMonitorEvent`. Virtual Methods --------------- .. rst-class:: interim-class .. class:: FileMonitor :no-index: .. method:: do_cancel() -> bool Cancels a file monitor. .. method:: do_changed(file: ~gi.repository.Gio.File, other_file: ~gi.repository.Gio.File, event_type: ~gi.repository.Gio.FileMonitorEvent) -> None :param file: :param other_file: :param event_type: Fields ------ .. rst-class:: interim-class .. class:: FileMonitor :no-index: .. attribute:: parent_instance .. attribute:: priv