Trait gio::prelude::FileMonitorExt
source · pub trait FileMonitorExt: 'static {
// Required methods
fn cancel(&self) -> bool;
fn emit_event(
&self,
child: &impl IsA<File>,
other_file: &impl IsA<File>,
event_type: FileMonitorEvent
);
fn is_cancelled(&self) -> bool;
fn set_rate_limit(&self, limit_msecs: i32);
fn rate_limit(&self) -> i32;
fn connect_changed<F: Fn(&Self, &File, Option<&File>, FileMonitorEvent) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_cancelled_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
fn connect_rate_limit_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
}
Expand description
Required Methods§
sourcefn emit_event(
&self,
child: &impl IsA<File>,
other_file: &impl IsA<File>,
event_type: FileMonitorEvent
)
fn emit_event( &self, child: &impl IsA<File>, other_file: &impl IsA<File>, event_type: FileMonitorEvent )
Emits the signal::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.
child
a File
.
other_file
a File
.
event_type
a set of FileMonitorEvent
flags.
sourcefn is_cancelled(&self) -> bool
fn is_cancelled(&self) -> bool
sourcefn set_rate_limit(&self, limit_msecs: i32)
fn set_rate_limit(&self, limit_msecs: i32)
Sets the rate limit to which the self
will report
consecutive change events to the same file.
limit_msecs
a non-negative integer with the limit in milliseconds to poll for changes
fn rate_limit(&self) -> i32
sourcefn connect_changed<F: Fn(&Self, &File, Option<&File>, FileMonitorEvent) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_changed<F: Fn(&Self, &File, Option<&File>, FileMonitorEvent) + 'static>( &self, f: F ) -> SignalHandlerId
Emitted when file
has been changed.
If using FileMonitorFlags::WATCH_MOVES
on a directory monitor, and
the information is available (and if supported by the backend),
event_type
may be FileMonitorEvent::Renamed
,
FileMonitorEvent::MovedIn
or FileMonitorEvent::MovedOut
.
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 FileMonitorEvent::MovedIn
as
equivalent to FileMonitorEvent::Created
and
FileMonitorEvent::MovedOut
as equivalent to
FileMonitorEvent::Deleted
, with extra information.
FileMonitorEvent::Renamed
is equivalent to a delete/create
pair. This is exactly how the events will be reported in the case
that the FileMonitorFlags::WATCH_MOVES
flag is not in use.
If using the deprecated flag FileMonitorFlags::SEND_MOVED
flag and event_type
is
FileMonitorEvent::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 None
.
file
a File
.