GFileMonitor

GFileMonitor — File Monitor

Synopsis


#include <gio/gio.h>

enum                GFileMonitorEvent;
                    GFileMonitor;
gboolean            g_file_monitor_cancel               (GFileMonitor *monitor);
gboolean            g_file_monitor_is_cancelled         (GFileMonitor *monitor);
void                g_file_monitor_set_rate_limit       (GFileMonitor *monitor,
                                                         int limit_msecs);
void                g_file_monitor_emit_event           (GFileMonitor *monitor,
                                                         GFile *child,
                                                         GFile *other_file,
                                                         GFileMonitorEvent event_type);

Object Hierarchy

  GObject
   +----GFileMonitor

Properties

  "cancelled"                gboolean              : Read
  "rate-limit"               gint                  : Read / Write

Signals

  "changed"                                        : Run Last

Description

Monitors a file or directory for changes.

To obtain a GFileMonitor for a file or directory, use g_file_monitor(), g_file_monitor_file(), or g_file_monitor_directory().

To get informed about changes to the file or directory you are monitoring, connect to the "changed" signal.

Details

enum GFileMonitorEvent

typedef enum {
  G_FILE_MONITOR_EVENT_CHANGED,
  G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT,
  G_FILE_MONITOR_EVENT_DELETED,
  G_FILE_MONITOR_EVENT_CREATED,
  G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED,
  G_FILE_MONITOR_EVENT_PRE_UNMOUNT,
  G_FILE_MONITOR_EVENT_UNMOUNTED
} GFileMonitorEvent;

Specifies what type of event a monitor event is.

G_FILE_MONITOR_EVENT_CHANGED

a file changed.

G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT

a hint that this was probably the last change in a set of changes.

G_FILE_MONITOR_EVENT_DELETED

a file was deleted.

G_FILE_MONITOR_EVENT_CREATED

a file was created.

G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED

a file attribute was changed.

G_FILE_MONITOR_EVENT_PRE_UNMOUNT

the file location will soon be unmounted.

G_FILE_MONITOR_EVENT_UNMOUNTED

the file location was unmounted.

GFileMonitor

typedef struct _GFileMonitor GFileMonitor;

Watches for changes to a file.


g_file_monitor_cancel ()

gboolean            g_file_monitor_cancel               (GFileMonitor *monitor);

Cancels a file monitor.

monitor :

a GFileMonitor.

Returns :

TRUE if monitor was cancelled.

g_file_monitor_is_cancelled ()

gboolean            g_file_monitor_is_cancelled         (GFileMonitor *monitor);

Returns whether the monitor is canceled.

monitor :

a GFileMonitor

Returns :

TRUE if monitor is canceled. FALSE otherwise.

g_file_monitor_set_rate_limit ()

void                g_file_monitor_set_rate_limit       (GFileMonitor *monitor,
                                                         int limit_msecs);

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

monitor :

a GFileMonitor.

limit_msecs :

a integer with the limit in milliseconds to poll for changes.

g_file_monitor_emit_event ()

void                g_file_monitor_emit_event           (GFileMonitor *monitor,
                                                         GFile *child,
                                                         GFile *other_file,
                                                         GFileMonitorEvent event_type);

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

The signal will be emitted from an idle handler.

monitor :

a GFileMonitor.

child :

a GFile.

other_file :

a GFile.

event_type :

a set of GFileMonitorEvent flags.

Property Details

The "cancelled" property

  "cancelled"                gboolean              : Read

Whether the monitor has been cancelled.

Default value: FALSE


The "rate-limit" property

  "rate-limit"               gint                  : Read / Write

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

Allowed values: >= 0

Default value: 800

Signal Details

The "changed" signal

void                user_function                      (GFileMonitor     *monitor,
                                                        GFile            *file,
                                                        GFile            *other_file,
                                                        GFileMonitorEvent event_type,
                                                        gpointer          user_data)       : Run Last

Emitted when a file has been changed.

monitor :

a GFileMonitor.

file :

a GFile.

other_file :

a GFile.

event_type :

a GFileMonitorEvent.

user_data :

user data set when the signal handler was connected.