r898: Applied Bernard Jungen's latest patch:
[rox-filer.git] / ROX-Filer / src / dir.h
blob7441dfa3e30ab433a5319808fe4b8a4a8a176a1d
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_NAMES, /* Got a list of names (used for resizing) */
16 DIR_START_SCAN, /* Set 'scanning' indicator */
17 DIR_END_SCAN, /* Clear 'scanning' indicator */
18 DIR_ADD, /* Add the listed items to the display */
19 DIR_REMOVE, /* Remove listed items from display */
20 DIR_UPDATE, /* Redraw these items */
21 } DirAction;
23 typedef struct _DirUser DirUser;
24 typedef void (*DirCallback)(Directory *dir,
25 DirAction action,
26 GPtrArray *items,
27 gpointer data);
29 #include "fscache.h"
30 #include "diritem.h"
32 extern GFSCache *dir_cache;
34 struct _DirUser
36 DirCallback callback;
37 gpointer data;
40 struct _Directory
42 char *pathname; /* Internal use only */
43 int ref;
44 GList *users; /* Functions to call on update */
45 char *error; /* NULL => no error */
47 gboolean do_thumbs; /* Create thumbs while scanning */
48 gboolean notify_active; /* Notify timeout is running */
49 gint idle_callback; /* Idle callback ID */
51 GHashTable *known_items; /* What our users know about */
52 GPtrArray *new_items; /* New items to add in */
53 GPtrArray *up_items; /* Items to redraw */
55 GList *recheck_list; /* Items to check on callback */
57 gboolean have_scanned; /* TRUE after first complete scan */
58 gboolean scanning; /* TRUE if we sent DIR_START_SCAN */
60 /* Indicates that the directory needs to be rescanned.
61 * This is cleared when scanning starts, and set when the fscache
62 * detects that the directory needs to be rescanned and is already
63 * scanning.
65 * If scanning finishes when this is set, or if someone attaches
66 * and scanning is not in progress, a rescan is triggered.
68 gboolean needs_update;
71 void dir_init(void);
72 void dir_attach(Directory *dir, DirCallback callback, gpointer data);
73 void dir_detach(Directory *dir, DirCallback callback, gpointer data);
74 void dir_update(Directory *dir, gchar *pathname);
75 void dir_rescan_with_thumbs(Directory *dir, gchar *pathname);
76 int dir_item_cmp(const void *a, const void *b);
77 void refresh_dirs(char *path);
78 void dir_stat(guchar *path, DirItem *item, gboolean make_thumb);
79 void dir_restat(guchar *path, DirItem *item, gboolean make_thumb);
80 void dir_item_clear(DirItem *item);
81 void dir_check_this(guchar *path);
82 void dir_rescan(Directory *dir, guchar *pathname);
83 void dir_merge_new(Directory *dir);
85 #endif /* _DIR_H */