r2525: Use stock icons in pinboard and panel menus.
[rox-filer.git] / ROX-Filer / src / dir.h
blobd7a54aafd9bf3edb5a9050c5f29d0c266d13a5fb
1 /*
2 * ROX-Filer, filer for the ROX desktop project
3 * Thomas Leonard, <tal197@users.sourceforge.net>
4 */
7 #ifndef _DIR_H
8 #define _DIR_H
10 #include <sys/types.h>
11 #include <dirent.h>
13 #include <signal.h>
14 #include <fcntl.h>
16 /* Check for dnotify support */
17 #if defined(DN_MULTISHOT) && defined(SIGRTMIN)
18 # define USE_DNOTIFY
19 extern gboolean dnotify_wakeup_flag;
20 #endif
22 typedef enum {
23 DIR_START_SCAN, /* Set 'scanning' indicator */
24 DIR_END_SCAN, /* Clear 'scanning' indicator */
25 DIR_ADD, /* Add the listed items to the display */
26 DIR_REMOVE, /* Remove listed items from display */
27 DIR_UPDATE, /* Redraw these items */
28 DIR_ERROR_CHANGED, /* Check dir->error */
29 } DirAction;
31 typedef struct _DirUser DirUser;
32 typedef void (*DirCallback)(Directory *dir,
33 DirAction action,
34 GPtrArray *items,
35 gpointer data);
37 extern GFSCache *dir_cache;
39 struct _DirUser
41 DirCallback callback;
42 gpointer data;
45 typedef struct _DirectoryClass DirectoryClass;
47 struct _DirectoryClass {
48 GObjectClass parent;
51 struct _Directory
53 GObject object;
55 char *pathname; /* Internal use only */
56 GList *users; /* Functions to call on update */
57 char *error; /* NULL => no error */
59 struct stat stat_info; /* Internal use */
61 gboolean notify_active; /* Notify timeout is running */
62 gint idle_callback; /* Idle callback ID */
64 GHashTable *known_items; /* What our users know about */
65 GPtrArray *new_items; /* New items to add in */
66 GPtrArray *up_items; /* Items to redraw */
67 GPtrArray *gone_items; /* Items removed */
69 GList *recheck_list; /* Items to check on callback */
71 gboolean have_scanned; /* TRUE after first complete scan */
72 gboolean scanning; /* TRUE if we sent DIR_START_SCAN */
74 /* Indicates that the directory needs to be rescanned.
75 * This is cleared when scanning starts, and set when the fscache
76 * detects that the directory needs to be rescanned and is already
77 * scanning.
79 * If scanning finishes when this is set, or if someone attaches
80 * and scanning is not in progress, a rescan is triggered.
82 gboolean needs_update;
84 #ifdef USE_DNOTIFY
85 int dnotify_fd; /* -1 if not watching */
86 #endif
89 void dir_init(void);
90 void dir_attach(Directory *dir, DirCallback callback, gpointer data);
91 void dir_detach(Directory *dir, DirCallback callback, gpointer data);
92 void dir_update(Directory *dir, gchar *pathname);
93 void refresh_dirs(const char *path);
94 void dir_check_this(const guchar *path);
95 DirItem *dir_update_item(Directory *dir, const gchar *leafname);
96 void dir_merge_new(Directory *dir);
97 void dir_force_update_path(const gchar *path);
98 void dnotify_wakeup(void);
99 void dir_drop_all_dnotifies(void);
101 #endif /* _DIR_H */