Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: FileMonitor

[22:7] extends: object

Monitors a file or directory for changes. To obtain a GFileMonitor for a file or directory, use [method@Gio.File.monitor], [method@Gio.File.monitor_file], or [method@Gio.File.monitor_directory]. To get informed about changes to the file or directory you are monitoring, connect to the [signal@Gio.FileMonitor::changed] signal. The signal will be emitted in the thread-default main context (see [method@GLib.MainContext.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).

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • FileMonitor (Handle = null)

    Creates a new FileMonitor by wrapping a native handle or another wrapper.

    • @p Handle is the native handle or another wrapper whose handle to adopt.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as Object.

    • @r A Object object.
  • connectSignal (string Name, CallbackObj)

    Connects one generated callback wrapper to a named signal.

    • @p Name is the signal name.
    • @p CallbackObj is the generated callback wrapper to connect.
    • @r The connected handler id.
  • disconnectSignalHandler (int HandlerId)

    Disconnects one retained signal handler id.

    • @p HandlerId is the signal handler id to disconnect.
    • @r None.
  • setOnChanged (callback Fn, UserData = null)

    Emitted when @file has been changed. If using %G_FILE_MONITOR_WATCH_MOVES on a directory monitor, and the information is available (and if supported by the backend), @event_type may be %G_FILE_MONITOR_EVENT_RENAMED, %G_FILE_MONITOR_EVENT_MOVED_IN or %G_FILE_MONITOR_EVENT_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 %G_FILE_MONITOR_EVENT_MOVED_IN as equivalent to %G_FILE_MONITOR_EVENT_CREATED and %G_FILE_MONITOR_EVENT_MOVED_OUT as equivalent to %G_FILE_MONITOR_EVENT_DELETED, with extra information. %G_FILE_MONITOR_EVENT_RENAMED is equivalent to a delete/create pair. This is exactly how the events will be reported in the case that the %G_FILE_MONITOR_WATCH_MOVES flag is not in use. If using the deprecated flag %G_FILE_MONITOR_SEND_MOVED flag and @event_type is %G_FILE_MONITOR_EVENT_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.
    • @p Fn is the Aussom callback.
    • @p Fn is called with (FileMonitor Self, File File, File Other_file, string Event_type).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setRatelimit (int Value)

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

    • @p Value is the new property value.
    • @r None.
  • cancel ()

    Cancels a file monitor.

  • emit_event (object child, object other_file, string event_type)

    Emits the #GFileMonitor::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 [method@GLib.MainContext.push_thread_default]) of the thread that the monitor was created in.

    • @p child is a #GFile..
    • @p other_file is a #GFile, or %NULL..
    • @p event_type is a set of #GFileMonitorEvent flags..
    • @r None.
  • is_cancelled ()

    Returns whether the monitor is canceled.

  • set_rate_limit (int limit_msecs)

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

    • @p limit_msecs is a non-negative integer with the limit in milliseconds to poll for changes.
    • @r None.

class: FileMonitorMeta

[330:14] static extends: object

Generated metadata helpers for FileMonitor class surfaces.

Methods

  • properties ()

    Returns property metadata for FileMonitor.

    • @r A list.
  • signals ()

    Returns signal metadata for FileMonitor.

    • @r A list.

class: FileMonitorChangedCallback

[257:7] extends: object

Generated low-level callback wrapper for GIR callback changed.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • FileMonitorChangedCallback (callback Fn, UserData = null)

    Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking Fn.

    • @p Fn is the Aussom callback implementation.
    • @p UserData is retained and passed through to Fn on each invocation when provided.
  • trampoline (nativeSelf, file, other_file, event_type, nativeUserData)

    Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.

  • callback ()

    Returns the wrapped NativeCallback.

  • handle ()

    Returns the callback as a NativeHandle.

  • close ()

    Closes the underlying NativeCallback.

  • isClosed ()

    Returns true when the callback has been closed.