<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="GFileMonitor">
<refmeta>
<refentrytitle role="top_of_page" id="GFileMonitor.top_of_page">GFileMonitor</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GIO Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>GFileMonitor</refname>
<refpurpose>File Monitor</refpurpose>
</refnamediv>

<refsynopsisdiv id="GFileMonitor.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;gio/gio.h&gt;

enum                <link linkend="GFileMonitorEvent">GFileMonitorEvent</link>;
                    <link linkend="GFileMonitor-struct">GFileMonitor</link>;
<link linkend="gboolean">gboolean</link>            <link linkend="g-file-monitor-cancel">g_file_monitor_cancel</link>               (<link linkend="GFileMonitor">GFileMonitor</link> *monitor);
<link linkend="gboolean">gboolean</link>            <link linkend="g-file-monitor-is-cancelled">g_file_monitor_is_cancelled</link>         (<link linkend="GFileMonitor">GFileMonitor</link> *monitor);
<link linkend="void">void</link>                <link linkend="g-file-monitor-set-rate-limit">g_file_monitor_set_rate_limit</link>       (<link linkend="GFileMonitor">GFileMonitor</link> *monitor,
                                                         <link linkend="int">int</link> limit_msecs);
<link linkend="void">void</link>                <link linkend="g-file-monitor-emit-event">g_file_monitor_emit_event</link>           (<link linkend="GFileMonitor">GFileMonitor</link> *monitor,
                                                         <link linkend="GFile">GFile</link> *child,
                                                         <link linkend="GFile">GFile</link> *other_file,
                                                         <link linkend="GFileMonitorEvent">GFileMonitorEvent</link> event_type);
</synopsis>
</refsynopsisdiv>

<refsect1 id="GFileMonitor.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<synopsis>
  <link linkend="GObject">GObject</link>
   +----GFileMonitor
</synopsis>
</refsect1>





<refsect1 id="GFileMonitor.properties" role="properties">
<title role="properties.title">Properties</title>
<synopsis>
  &quot;<link linkend="GFileMonitor--cancelled">cancelled</link>&quot;                <link linkend="gboolean">gboolean</link>              : Read
  &quot;<link linkend="GFileMonitor--rate-limit">rate-limit</link>&quot;               <link linkend="gint">gint</link>                  : Read / Write
</synopsis>
</refsect1>

<refsect1 id="GFileMonitor.signals" role="signal_proto">
<title role="signal_proto.title">Signals</title>
<synopsis>
  &quot;<link linkend="GFileMonitor-changed">changed</link>&quot;                                        : Run Last
</synopsis>
</refsect1>


<refsect1 id="GFileMonitor.description" role="desc">
<title role="desc.title">Description</title>
<para>
Monitors a file or directory for changes.
</para>
<para>
To obtain a <link linkend="GFileMonitor"><type>GFileMonitor</type></link> for a file or directory, use
<link linkend="g-file-monitor"><function>g_file_monitor()</function></link>, <link linkend="g-file-monitor-file"><function>g_file_monitor_file()</function></link>, or
<link linkend="g-file-monitor-directory"><function>g_file_monitor_directory()</function></link>.
</para>
<para>
To get informed about changes to the file or directory you are
monitoring, connect to the <link linkend="GFileMonitor-changed"><type>"changed"</type></link> signal. The
signal will be emitted in the <link
linkend="g-main-context-push-thread-default">thread-default main
context</link> 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).</para>
<para>
</para>
</refsect1>

<refsect1 id="GFileMonitor.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GFileMonitorEvent" role="enum">
<title>enum GFileMonitorEvent</title>
<indexterm zone="GFileMonitorEvent"><primary sortas="FileMonitorEvent">GFileMonitorEvent</primary></indexterm><programlisting>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;
</programlisting>
<para>
Specifies what type of event a monitor event is.</para>
<para>
</para><variablelist role="enum">
<varlistentry id="G-FILE-MONITOR-EVENT-CHANGED--CAPS" role="constant">
<term><literal>G_FILE_MONITOR_EVENT_CHANGED</literal></term>
<listitem><simpara> a file changed.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-FILE-MONITOR-EVENT-CHANGES-DONE-HINT--CAPS" role="constant">
<term><literal>G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT</literal></term>
<listitem><simpara> a hint that this was probably the last change in a set of changes.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-FILE-MONITOR-EVENT-DELETED--CAPS" role="constant">
<term><literal>G_FILE_MONITOR_EVENT_DELETED</literal></term>
<listitem><simpara> a file was deleted.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-FILE-MONITOR-EVENT-CREATED--CAPS" role="constant">
<term><literal>G_FILE_MONITOR_EVENT_CREATED</literal></term>
<listitem><simpara> a file was created.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-FILE-MONITOR-EVENT-ATTRIBUTE-CHANGED--CAPS" role="constant">
<term><literal>G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED</literal></term>
<listitem><simpara> a file attribute was changed.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-FILE-MONITOR-EVENT-PRE-UNMOUNT--CAPS" role="constant">
<term><literal>G_FILE_MONITOR_EVENT_PRE_UNMOUNT</literal></term>
<listitem><simpara> the file location will soon be unmounted.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-FILE-MONITOR-EVENT-UNMOUNTED--CAPS" role="constant">
<term><literal>G_FILE_MONITOR_EVENT_UNMOUNTED</literal></term>
<listitem><simpara> the file location was unmounted.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="GFileMonitor-struct" role="struct">
<title>GFileMonitor</title>
<indexterm zone="GFileMonitor-struct"><primary sortas="FileMonitor">GFileMonitor</primary></indexterm><programlisting>typedef struct _GFileMonitor GFileMonitor;</programlisting>
<para>
Watches for changes to a file.</para>
<para>
</para></refsect2>
<refsect2 id="g-file-monitor-cancel" role="function">
<title>g_file_monitor_cancel ()</title>
<indexterm zone="g-file-monitor-cancel"><primary sortas="file_monitor_cancel">g_file_monitor_cancel</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_file_monitor_cancel               (<link linkend="GFileMonitor">GFileMonitor</link> *monitor);</programlisting>
<para>
Cancels a file monitor.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>monitor</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFileMonitor"><type>GFileMonitor</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if monitor was cancelled.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-file-monitor-is-cancelled" role="function">
<title>g_file_monitor_is_cancelled ()</title>
<indexterm zone="g-file-monitor-is-cancelled"><primary sortas="file_monitor_is_cancelled">g_file_monitor_is_cancelled</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_file_monitor_is_cancelled         (<link linkend="GFileMonitor">GFileMonitor</link> *monitor);</programlisting>
<para>
Returns whether the monitor is canceled.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>monitor</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFileMonitor"><type>GFileMonitor</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if monitor is canceled. <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> otherwise.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-file-monitor-set-rate-limit" role="function">
<title>g_file_monitor_set_rate_limit ()</title>
<indexterm zone="g-file-monitor-set-rate-limit"><primary sortas="file_monitor_set_rate_limit">g_file_monitor_set_rate_limit</primary></indexterm><programlisting><link linkend="void">void</link>                g_file_monitor_set_rate_limit       (<link linkend="GFileMonitor">GFileMonitor</link> *monitor,
                                                         <link linkend="int">int</link> limit_msecs);</programlisting>
<para>
Sets the rate limit to which the <parameter>monitor</parameter> will report
consecutive change events to the same file.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>monitor</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFileMonitor"><type>GFileMonitor</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>limit_msecs</parameter>&#160;:</term>
<listitem><simpara> a integer with the limit in milliseconds to 
poll for changes.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-file-monitor-emit-event" role="function">
<title>g_file_monitor_emit_event ()</title>
<indexterm zone="g-file-monitor-emit-event"><primary sortas="file_monitor_emit_event">g_file_monitor_emit_event</primary></indexterm><programlisting><link linkend="void">void</link>                g_file_monitor_emit_event           (<link linkend="GFileMonitor">GFileMonitor</link> *monitor,
                                                         <link linkend="GFile">GFile</link> *child,
                                                         <link linkend="GFile">GFile</link> *other_file,
                                                         <link linkend="GFileMonitorEvent">GFileMonitorEvent</link> event_type);</programlisting>
<para>
Emits the <link linkend="GFileMonitor-changed"><type>"changed"</type></link> signal if a change
has taken place. Should be called from file monitor 
implementations only.
</para>
<para>
The signal will be emitted from an idle handler (in the <link
linkend="g-main-context-push-thread-default">thread-default main
context</link>).</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>monitor</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFileMonitor"><type>GFileMonitor</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>child</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFile"><type>GFile</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>other_file</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFile"><type>GFile</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>event_type</parameter>&#160;:</term>
<listitem><simpara> a set of <link linkend="GFileMonitorEvent"><type>GFileMonitorEvent</type></link> flags.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>
<refsect1 id="GFileMonitor.property-details" role="property_details">
<title role="property_details.title">Property Details</title>
<refsect2 id="GFileMonitor--cancelled" role="property"><title>The <literal>&quot;cancelled&quot;</literal> property</title>
<indexterm zone="GFileMonitor--cancelled"><primary sortas="FileMonitor:cancelled">GFileMonitor:cancelled</primary></indexterm><programlisting>  &quot;cancelled&quot;                <link linkend="gboolean">gboolean</link>              : Read</programlisting>
<para>Whether the monitor has been cancelled.</para><para>Default value: FALSE</para>
</refsect2>
<refsect2 id="GFileMonitor--rate-limit" role="property"><title>The <literal>&quot;rate-limit&quot;</literal> property</title>
<indexterm zone="GFileMonitor--rate-limit"><primary sortas="FileMonitor:rate-limit">GFileMonitor:rate-limit</primary></indexterm><programlisting>  &quot;rate-limit&quot;               <link linkend="gint">gint</link>                  : Read / Write</programlisting>
<para>The limit of the monitor to watch for changes, in milliseconds.</para><para>Allowed values: &gt;= 0</para>
<para>Default value: 800</para>
</refsect2>
</refsect1>

<refsect1 id="GFileMonitor.signal-details" role="signals">
<title role="signals.title">Signal Details</title>
<refsect2 id="GFileMonitor-changed" role="signal"><title>The <literal>&quot;changed&quot;</literal> signal</title>
<indexterm zone="GFileMonitor-changed"><primary sortas="FileMonitor::changed">GFileMonitor::changed</primary></indexterm><programlisting><link linkend="void">void</link>                user_function                      (<link linkend="GFileMonitor">GFileMonitor</link>     *monitor,
                                                        <link linkend="GFile">GFile</link>            *file,
                                                        <link linkend="GFile">GFile</link>            *other_file,
                                                        <link linkend="GFileMonitorEvent">GFileMonitorEvent</link> event_type,
                                                        <link linkend="gpointer">gpointer</link>          user_data)       : Run Last</programlisting>
<para>
Emitted when a file has been changed.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>monitor</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFileMonitor"><type>GFileMonitor</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>file</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFile"><type>GFile</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>other_file</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFile"><type>GFile</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>event_type</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFileMonitorEvent"><type>GFileMonitorEvent</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>user data set when the signal handler was connected.</simpara></listitem></varlistentry>
</variablelist></refsect2>
</refsect1>



</refentry>
