nautilus-directory-private.h 10.8 KB
Newer Older
1 2
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-

3
   nautilus-directory-private.h: Nautilus directory model.
4
 
5
   Copyright (C) 1999, 2000, 2001 Eazel, Inc.
6 7 8 9 10 11 12 13 14 15 16 17
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.
  
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
  
   You should have received a copy of the GNU General Public
18
   License along with this program; if not, see <http://www.gnu.org/licenses/>.
19
  
20
   Author: Darin Adler <darin@bentspoon.com>
21 22
*/

23
#include <gio/gio.h>
24
#include <eel/eel-vfs-extensions.h>
25 26 27 28
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-file-queue.h>
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-monitor.h>
29
#include <libnautilus-extension/nautilus-info-provider.h>
30
#include <libxml/tree.h>
31

Alexander Larsson's avatar
Alexander Larsson committed
32
typedef struct LinkInfoReadState LinkInfoReadState;
33
typedef struct TopLeftTextReadState TopLeftTextReadState;
34
typedef struct FileMonitors FileMonitors;
Alexander Larsson's avatar
Alexander Larsson committed
35 36 37 38 39 40 41
typedef struct DirectoryLoadState DirectoryLoadState;
typedef struct DirectoryCountState DirectoryCountState;
typedef struct DeepCountState DeepCountState;
typedef struct GetInfoState GetInfoState;
typedef struct NewFilesState NewFilesState;
typedef struct MimeListState MimeListState;
typedef struct ThumbnailState ThumbnailState;
42
typedef struct MountState MountState;
43
typedef struct FilesystemInfoState FilesystemInfoState;
44

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
typedef enum {
	REQUEST_LINK_INFO,
	REQUEST_DEEP_COUNT,
	REQUEST_DIRECTORY_COUNT,
	REQUEST_FILE_INFO,
	REQUEST_FILE_LIST, /* always FALSE if file != NULL */
	REQUEST_MIME_LIST,
	REQUEST_EXTENSION_INFO,
	REQUEST_THUMBNAIL,
	REQUEST_MOUNT,
	REQUEST_FILESYSTEM_INFO,
	REQUEST_TYPE_LAST
} RequestType;

/* A request for information about one or more files. */
typedef guint32 Request;
61
typedef gint32 RequestCounter[REQUEST_TYPE_LAST];
62

63 64
#define REQUEST_WANTS_TYPE(request, type) ((request) & (1<<(type)))
#define REQUEST_SET_TYPE(request, type) (request) |= (1<<(type))
65

66 67
struct NautilusDirectoryDetails
{
68
	/* The location. */
Alexander Larsson's avatar
Alexander Larsson committed
69
	GFile *location;
70

71
	/* The file objects. */
72
	NautilusFile *as_file;
73 74
	GList *file_list;
	GHashTable *file_hash;
75

Alexander Larsson's avatar
Alexander Larsson committed
76 77 78
	/* Queues of files needing some I/O done. */
	NautilusFileQueue *high_priority_queue;
	NautilusFileQueue *low_priority_queue;
79
	NautilusFileQueue *extension_queue;
Alexander Larsson's avatar
Alexander Larsson committed
80

81
	/* These lists are going to be pretty short.  If we think they
82
	 * are going to get big, we can use hash tables instead.
83
	 */
84
	GList *call_when_ready_list;
85
	RequestCounter call_when_ready_counters;
86
	GList *monitor_list;
87
	RequestCounter monitor_counters;
88
	guint call_ready_idle_id;
89

90
	NautilusMonitor *monitor;
91
	gulong 		 mime_db_monitor;
92

93 94 95
	gboolean in_async_service_loop;
	gboolean state_changed;

96
	gboolean file_list_monitored;
97
	gboolean directory_loaded;
Maciej Stachowiak's avatar
Maciej Stachowiak committed
98
	gboolean directory_loaded_sent_notification;
Alexander Larsson's avatar
Alexander Larsson committed
99
	DirectoryLoadState *directory_load_in_progress;
100

101
	GList *pending_file_info; /* list of GnomeVFSFileInfo's that are pending */
102
	int confirmed_file_count;
103
        guint dequeue_pending_idle_id;
104

Alexander Larsson's avatar
Alexander Larsson committed
105
	GList *new_files_in_progress; /* list of NewFilesState * */
106

Alexander Larsson's avatar
Alexander Larsson committed
107
	DirectoryCountState *count_in_progress;
108

109
	NautilusFile *deep_count_file;
Alexander Larsson's avatar
Alexander Larsson committed
110
	DeepCountState *deep_count_in_progress;
111

Alexander Larsson's avatar
Alexander Larsson committed
112
	MimeListState *mime_list_in_progress;
113

114
	NautilusFile *get_info_file;
Alexander Larsson's avatar
Alexander Larsson committed
115
	GetInfoState *get_info_in_progress;
116

117 118 119
	NautilusFile *extension_info_file;
	NautilusInfoProvider *extension_info_provider;
	NautilusOperationHandle *extension_info_in_progress;
Alexander Larsson's avatar
Alexander Larsson committed
120
	guint extension_info_idle;
121

Alexander Larsson's avatar
Alexander Larsson committed
122
	ThumbnailState *thumbnail_state;
123 124

	MountState *mount_state;
125 126

	FilesystemInfoState *filesystem_info_state;
Alexander Larsson's avatar
Alexander Larsson committed
127
	
Alexander Larsson's avatar
Alexander Larsson committed
128
	LinkInfoReadState *link_info_read_state;
129 130

	GList *file_operations_in_progress; /* list of FileOperation * */
131 132
};

Alexander Larsson's avatar
Alexander Larsson committed
133
NautilusDirectory *nautilus_directory_get_existing                    (GFile                     *location);
134

135
/* async. interface */
136 137 138
void               nautilus_directory_async_state_changed             (NautilusDirectory         *directory);
void               nautilus_directory_call_when_ready_internal        (NautilusDirectory         *directory,
								       NautilusFile              *file,
139
								       NautilusFileAttributes     file_attributes,
140
								       gboolean                   wait_for_file_list,
141 142 143 144 145
								       NautilusDirectoryCallback  directory_callback,
								       NautilusFileCallback       file_callback,
								       gpointer                   callback_data);
gboolean           nautilus_directory_check_if_ready_internal         (NautilusDirectory         *directory,
								       NautilusFile              *file,
146
								       NautilusFileAttributes     file_attributes);
147 148 149 150 151 152 153 154
void               nautilus_directory_cancel_callback_internal        (NautilusDirectory         *directory,
								       NautilusFile              *file,
								       NautilusDirectoryCallback  directory_callback,
								       NautilusFileCallback       file_callback,
								       gpointer                   callback_data);
void               nautilus_directory_monitor_add_internal            (NautilusDirectory         *directory,
								       NautilusFile              *file,
								       gconstpointer              client,
155
								       gboolean                   monitor_hidden_files,
156
								       NautilusFileAttributes     attributes,
Darin Adler's avatar
Darin Adler committed
157 158
								       NautilusDirectoryCallback  callback,
								       gpointer                   callback_data);
159 160 161 162 163
void               nautilus_directory_monitor_remove_internal         (NautilusDirectory         *directory,
								       NautilusFile              *file,
								       gconstpointer              client);
void               nautilus_directory_get_info_for_new_files          (NautilusDirectory         *directory,
								       GList                     *vfs_uris);
164
NautilusFile *     nautilus_directory_get_existing_corresponding_file (NautilusDirectory         *directory);
165
void               nautilus_directory_invalidate_count_and_mime_list  (NautilusDirectory         *directory);
166 167
gboolean           nautilus_directory_is_file_list_monitored          (NautilusDirectory         *directory);
gboolean           nautilus_directory_is_anyone_monitoring_file_list  (NautilusDirectory         *directory);
168 169
gboolean           nautilus_directory_has_active_request_for_file     (NautilusDirectory         *directory,
								       NautilusFile              *file);
170 171 172 173 174 175
void               nautilus_directory_remove_file_monitor_link        (NautilusDirectory         *directory,
								       GList                     *link);
void               nautilus_directory_schedule_dequeue_pending        (NautilusDirectory         *directory);
void               nautilus_directory_stop_monitoring_file_list       (NautilusDirectory         *directory);
void               nautilus_directory_cancel                          (NautilusDirectory         *directory);
void               nautilus_async_destroying_file                     (NautilusFile              *file);
176
void               nautilus_directory_force_reload_internal           (NautilusDirectory         *directory,
177
								       NautilusFileAttributes     file_attributes);
178 179
void               nautilus_directory_cancel_loading_file_attributes  (NautilusDirectory         *directory,
								       NautilusFile              *file,
180
								       NautilusFileAttributes     file_attributes);
181

182
/* Calls shared between directory, file, and async. code. */
183 184 185 186
void               nautilus_directory_emit_files_added                (NautilusDirectory         *directory,
								       GList                     *added_files);
void               nautilus_directory_emit_files_changed              (NautilusDirectory         *directory,
								       GList                     *changed_files);
187
void               nautilus_directory_emit_change_signals             (NautilusDirectory         *directory,
188
								       GList                     *changed_files);
189
void               emit_change_signals_for_all_files		      (NautilusDirectory	 *directory);
Alexander Larsson's avatar
Alexander Larsson committed
190
void               emit_change_signals_for_all_files_in_all_directories (void);
191
void               nautilus_directory_emit_done_loading               (NautilusDirectory         *directory);
192
void               nautilus_directory_emit_load_error                 (NautilusDirectory         *directory,
Alexander Larsson's avatar
Alexander Larsson committed
193 194
								       GError                    *error);
NautilusDirectory *nautilus_directory_get_internal                    (GFile                     *location,
195
								       gboolean                   create);
196
char *             nautilus_directory_get_name_for_self_as_new_file   (NautilusDirectory         *directory);
197
Request            nautilus_directory_set_up_request                  (NautilusFileAttributes     file_attributes);
198

199
/* Interface to the file list. */
200
NautilusFile *     nautilus_directory_find_file_by_name               (NautilusDirectory         *directory,
Alexander Larsson's avatar
Alexander Larsson committed
201
								       const char                *filename);
202

203 204 205 206
void               nautilus_directory_add_file                        (NautilusDirectory         *directory,
								       NautilusFile              *file);
void               nautilus_directory_remove_file                     (NautilusDirectory         *directory,
								       NautilusFile              *file);
207 208 209 210 211 212 213
FileMonitors *     nautilus_directory_remove_file_monitors            (NautilusDirectory         *directory,
								       NautilusFile              *file);
void               nautilus_directory_add_file_monitors               (NautilusDirectory         *directory,
								       NautilusFile              *file,
								       FileMonitors              *monitors);
void               nautilus_directory_add_file                        (NautilusDirectory         *directory,
								       NautilusFile              *file);
214 215 216 217 218
GList *            nautilus_directory_begin_file_name_change          (NautilusDirectory         *directory,
								       NautilusFile              *file);
void               nautilus_directory_end_file_name_change            (NautilusDirectory         *directory,
								       NautilusFile              *file,
								       GList                     *node);
219
void               nautilus_directory_moved                           (const char                *from_uri,
220
								       const char                *to_uri);
Alexander Larsson's avatar
Alexander Larsson committed
221 222 223 224 225 226
/* Interface to the work queue. */

void               nautilus_directory_add_file_to_work_queue          (NautilusDirectory *directory,
								       NautilusFile *file);
void               nautilus_directory_remove_file_from_work_queue     (NautilusDirectory *directory,
								       NautilusFile *file);
227

228

229
/* debugging functions */
230
int                nautilus_directory_number_outstanding              (void);