glibmm: Gio::FileMonitor Class Reference

glibmm 2.36.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gio::FileMonitor Class Reference

Monitors a file or directory for changes. More...

`#include <giomm/filemonitor.h>`

Inheritance diagram for Gio::FileMonitor:
[legend]

## Public Member Functions
virtual | ~FileMonitor ()
GFileMonitor* | gobj ()
| Provides access to the underlying C GObject. More...
const GFileMonitor* | gobj () const
| Provides access to the underlying C GObject. More...
GFileMonitor* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
bool | cancel ()
| Cancels a file monitor. More...
bool | is_cancelled () const
| Returns whether the monitor is canceled. More...
void | set_rate_limit (int limit_msecs)
| Sets the rate limit to which the monitor will report consecutive change events to the same file. More...
Glib::SignalProxy3< void, const Glib::RefPtr< File > &, const Glib::RefPtr< File > &, FileMonitorEvent > | signal_changed ()
Glib::PropertyProxy< int > | property_rate_limit ()
| The limit of the monitor to watch for changes, in milliseconds. More...
Glib::PropertyProxy_ReadOnly< int > | property_rate_limit () const
| The limit of the monitor to watch for changes, in milliseconds. More...
Glib::PropertyProxy_ReadOnly < bool > | property_cancelled () const
| Whether the monitor has been cancelled. More...
Public Member Functions inherited from Glib::Object
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
Public Member Functions inherited from Glib::ObjectBase
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Member Functions
virtual void | on_changed (const Glib::RefPtr< File >& file, const Glib::RefPtr< File >& other_file, FileMonitorEvent event_type)
| This is a default handler for the signal signal_changed(). More...
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
virtual | ~Object ()
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
virtual | ~ObjectBase ()=0
void | initialize (GObject* castitem)

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::FileMonitor > | wrap (GFileMonitor* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject* object, bool take_copy=false)

## Additional Inherited Members
Public Types inherited from Glib::Object
typedef void(* | DestroyNotify )(gpointer data)

## Detailed Description

Monitors a file or directory for changes.

To obtain a FileMonitor for a file or directory, use File::monitor_file() or File::monitor_directory().

To get informed about changes to the file or directory you are monitoring, connect to signal_changed().

Since glibmm 2.16:

## Constructor & Destructor Documentation

virtual Gio::FileMonitor::~FileMonitor | ( |  | ) |
| virtual

## Member Function Documentation

bool Gio::FileMonitor::cancel | ( |  | ) |

Cancels a file monitor.

Returns
  `true` if monitor was cancelled.

static GType Gio::FileMonitor::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

GFileMonitor* Gio::FileMonitor::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

const GFileMonitor* Gio::FileMonitor::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

GFileMonitor* Gio::FileMonitor::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gio::FileMonitor::is_cancelled | ( |  | ) | const

Returns whether the monitor is canceled.

Returns
  `true` if monitor is canceled. `false` otherwise.

virtual void Gio::FileMonitor::on_changed | ( | const Glib::RefPtr< File >& | file,
|  | const Glib::RefPtr< File >& | other_file,
|  | FileMonitorEvent | event_type
| ) |  |
| protectedvirtual

This is a default handler for the signal signal_changed().

Glib::PropertyProxy_ReadOnly< bool > Gio::FileMonitor::property_cancelled | ( |  | ) | const

Whether the monitor has been cancelled.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< int > Gio::FileMonitor::property_rate_limit | ( |  | ) |

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

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< int > Gio::FileMonitor::property_rate_limit | ( |  | ) | const

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

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

void Gio::FileMonitor::set_rate_limit | ( | int | limit_msecs | ) |

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

Parameters

  limit_msecs | A non-negative integer with the limit in milliseconds to poll for changes.

Glib::SignalProxy3< void,const Glib::RefPtr<File>&,const Glib::RefPtr<File>&,FileMonitorEvent > Gio::FileMonitor::signal_changed | ( |  | ) |

Slot Prototype:
  `void on_my_changed(const Glib::RefPtr<File>& file, const Glib::RefPtr<File>& other_file, FileMonitorEvent event_type)`

Emitted when file has been changed.

If using FILE_MONITOR_SEND_MOVED flag and event_type is FILE_MONITOR_EVENT_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 #`0`.

Parameters

  file | A File.
  other_file | A File or #`0`.
  event_type | A FileMonitorEvent.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::FileMonitor > wrap | ( | GFileMonitor * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.