]> icculus.org git repositories - dana/openbox.git/blob - obt/watch.h
Make warnings about parse problems in .desktop files "debug" messages. Most people...
[dana/openbox.git] / obt / watch.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    obt/watch.h for the Openbox window manager
4    Copyright (c) 2010        Dana Jansens
5
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.
10
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.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef __obt_watch_h
20 #define __obt_watch_h
21
22 #include <glib.h>
23
24 G_BEGIN_DECLS
25
26 typedef struct _ObtWatch ObtWatch;
27 typedef enum _ObtWatchNotifyType ObtWatchNotifyType;
28
29 /*! Notification function for changes in a watch file/directory.
30   @param base_path is the path to the watch target (file or directory).
31   @param sub_path is a path relative to the watched directory.  If the
32     notification is about the watch target itself, the subpath will be
33     an empty string.
34 */
35 typedef void (*ObtWatchFunc)(ObtWatch *w,
36                              const gchar *base_path,
37                              const gchar *sub_path,
38                              ObtWatchNotifyType type,
39                              gpointer data);
40
41 enum _ObtWatchNotifyType {
42     OBT_WATCH_ADDED, /*!< A file/dir was added in a watched dir */
43     OBT_WATCH_REMOVED, /*!< A file/dir was removed in a watched dir */
44     OBT_WATCH_MODIFIED, /*!< A watched file, or a file in a watched dir, was
45                              modified */
46     OBT_WATCH_SELF_REMOVED /*!< The watched target was removed. */ 
47 };
48
49 ObtWatch* obt_watch_new();
50 void obt_watch_ref(ObtWatch *w);
51 void obt_watch_unref(ObtWatch *w);
52
53 /*! Start watching a target file or directory.
54   If the target is a directory, the watch is performed recursively.
55   On start, if the target is a directory, an ADDED notification will come for
56   each file in the directory, and its subdirectories.
57   @param path The path to the target to watch.  Must be an absolute path that
58     starts with a /.
59   @param watch_hidden If TRUE, and if the target is a directory, dot-files (and
60     dot-subdirectories) will be included in the watch.  If the target is a
61     file, this parameter is ignored.
62 */
63 gboolean obt_watch_add(ObtWatch *w, const gchar *path,
64                        gboolean watch_hidden,
65                        ObtWatchFunc func, gpointer data);
66 void obt_watch_remove(ObtWatch *w, const gchar *path);
67
68 /*! Force a refresh of the watcher.
69   This will report any changes since the last time the watcher refreshed its
70   view of the file system.  Note that any watchers that work off notifications
71   will have nothing to report for this function.
72 */
73 void obt_watch_refresh(ObtWatch *w);
74
75 G_END_DECLS
76
77 #endif