r1283: Added a whole load of 'const' modifiers so we can do extra checking...
[rox-filer.git] / ROX-Filer / src / dir.h
blobedba1178e5245345bc290921648cced66900a80d
1 /*
2 * $Id$
4 * Thomas Leonard, <tal197@users.sourceforge.net>
5 */
8 #ifndef _DIR_H
9 #define _DIR_H
11 #include <sys/types.h>
12 #include <dirent.h>
14 typedef enum {
15 DIR_START_SCAN, /* Set 'scanning' indicator */
16 DIR_END_SCAN, /* Clear 'scanning' indicator */
17 DIR_ADD, /* Add the listed items to the display */
18 DIR_REMOVE, /* Remove listed items from display */
19 DIR_UPDATE, /* Redraw these items */
20 } DirAction;
22 typedef struct _DirUser DirUser;
23 typedef void (*DirCallback)(Directory *dir,
24 DirAction action,
25 GPtrArray *items,
26 gpointer data);
28 extern GFSCache *dir_cache;
30 struct _DirUser
32 DirCallback callback;
33 gpointer data;
36 struct _Directory
38 char *pathname; /* Internal use only */
39 int ref;
40 GList *users; /* Functions to call on update */
41 char *error; /* NULL => no error */
43 gboolean notify_active; /* Notify timeout is running */
44 gint idle_callback; /* Idle callback ID */
46 GHashTable *known_items; /* What our users know about */
47 GPtrArray *new_items; /* New items to add in */
48 GPtrArray *up_items; /* Items to redraw */
49 GPtrArray *gone_items; /* Items removed */
51 GList *recheck_list; /* Items to check on callback */
53 gboolean have_scanned; /* TRUE after first complete scan */
54 gboolean scanning; /* TRUE if we sent DIR_START_SCAN */
56 /* Indicates that the directory needs to be rescanned.
57 * This is cleared when scanning starts, and set when the fscache
58 * detects that the directory needs to be rescanned and is already
59 * scanning.
61 * If scanning finishes when this is set, or if someone attaches
62 * and scanning is not in progress, a rescan is triggered.
64 gboolean needs_update;
67 void dir_init(void);
68 void dir_attach(Directory *dir, DirCallback callback, gpointer data);
69 void dir_detach(Directory *dir, DirCallback callback, gpointer data);
70 void dir_update(Directory *dir, gchar *pathname);
71 int dir_item_cmp(const void *a, const void *b);
72 void refresh_dirs(const char *path);
73 void dir_check_this(const guchar *path);
74 DirItem *dir_update_item(Directory *dir, const gchar *leafname);
75 void dir_rescan(Directory *dir, const guchar *pathname);
76 void dir_merge_new(Directory *dir);
77 void dir_force_update_path(const gchar *path);
79 #endif /* _DIR_H */