1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 obt/watch.h for the Openbox window manager
4 Copyright (c) 2010 Dana Jansens
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 See the COPYING file for a copy of the GNU General Public License.
26 typedef struct _ObtWatch ObtWatch;
27 typedef enum _ObtWatchNotifyType ObtWatchNotifyType;
29 typedef void (*ObtWatchFunc)(ObtWatch *w, const gchar *subpath,
30 ObtWatchNotifyType type, gpointer data);
32 enum _ObtWatchNotifyType {
33 OBT_WATCH_ADDED, /*!< A file/dir was added in a watched dir */
34 OBT_WATCH_REMOVED, /*!< A file/dir was removed in a watched dir */
35 OBT_WATCH_MODIFIED, /*!< A watched file, or a file in a watched dir, was
37 OBT_WATCH_SELF_REMOVED /*!< The watched target was removed. */
40 ObtWatch* obt_watch_new();
41 void obt_watch_ref(ObtWatch *w);
42 void obt_watch_unref(ObtWatch *w);
44 /*! Start watching a target file or directory.
45 If the target is a directory, the watch is performed recursively.
46 On start, if the target is a directory, an ADDED notification will come for
47 each file in the directory, and its subdirectories.
48 @param path The path to the target to watch. Must be an absolute path that
50 @param watch_hidden If TRUE, and if the target is a directory, dot-files (and
51 dot-subdirectories) will be included in the watch. If the target is a
52 file, this parameter is ignored.
54 gboolean obt_watch_add(ObtWatch *w, const gchar *path,
55 gboolean watch_hidden,
56 ObtWatchFunc func, gpointer data);
57 void obt_watch_remove(ObtWatch *w, const gchar *path);