nautilus-directory-private.h 10.4 KB
Newer Older
1
/*
2
   nautilus-directory-private.h: Nautilus directory model.
3
 
4
   Copyright (C) 1999, 2000, 2001 Eazel, Inc.
5 6 7 8 9 10 11 12 13 14 15 16
  
   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
17
   License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
  
19
   Author: Darin Adler <darin@bentspoon.com>
20 21
*/

22 23
#pragma once

24
#include <eel/eel-vfs-extensions.h>
25 26 27
#include <gio/gio.h>
#include <nautilus-extension.h>

28 29
#include "nautilus-directory.h"
#include "nautilus-file.h"
30

31
typedef struct FileMonitors FileMonitors;
Alexander Larsson's avatar
Alexander Larsson committed
32 33 34 35 36 37 38
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;
39
typedef struct MountState MountState;
40
typedef struct FilesystemInfoState FilesystemInfoState;
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
typedef enum {
	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;
57
typedef gint32 RequestCounter[REQUEST_TYPE_LAST];
58

59 60
#define REQUEST_WANTS_TYPE(request, type) ((request) & (1<<(type)))
#define REQUEST_SET_TYPE(request, type) (request) |= (1<<(type))
61

62 63
struct NautilusDirectoryDetails
{
64
	/* The location. */
Alexander Larsson's avatar
Alexander Larsson committed
65
	GFile *location;
66

67
	/* The file objects. */
68
	NautilusFile *as_file;
69 70
	GList *file_list;
	GHashTable *file_hash;
71

72 73 74
	/* Queues of files needing some I/O done. */
	NautilusFileQueue *high_priority_queue;
	NautilusFileQueue *low_priority_queue;
75
	NautilusFileQueue *extension_queue;
76

77
	/* These lists are going to be pretty short.  If we think they
78
	 * are going to get big, we can use hash tables instead.
79
	 */
80
	GList *call_when_ready_list;
81
	RequestCounter call_when_ready_counters;
82
	GHashTable *monitor_table;
83
	RequestCounter monitor_counters;
84
	guint call_ready_idle_id;
85

86
	NautilusMonitor *monitor;
87
	gulong 		 mime_db_monitor;
88

89 90 91
	gboolean in_async_service_loop;
	gboolean state_changed;

92
	gboolean file_list_monitored;
93
	gboolean directory_loaded;
Maciej Stachowiak's avatar
Maciej Stachowiak committed
94
	gboolean directory_loaded_sent_notification;
Alexander Larsson's avatar
Alexander Larsson committed
95
	DirectoryLoadState *directory_load_in_progress;
96

97
	GList *pending_file_info; /* list of GnomeVFSFileInfo's that are pending */
98
	int confirmed_file_count;
99
        guint dequeue_pending_idle_id;
100

Alexander Larsson's avatar
Alexander Larsson committed
101
	GList *new_files_in_progress; /* list of NewFilesState * */
102

Alexander Larsson's avatar
Alexander Larsson committed
103
	DirectoryCountState *count_in_progress;
104

105
	NautilusFile *deep_count_file;
Alexander Larsson's avatar
Alexander Larsson committed
106
	DeepCountState *deep_count_in_progress;
107

Alexander Larsson's avatar
Alexander Larsson committed
108
	MimeListState *mime_list_in_progress;
109

110
	NautilusFile *get_info_file;
Alexander Larsson's avatar
Alexander Larsson committed
111
	GetInfoState *get_info_in_progress;
112

113 114 115
	NautilusFile *extension_info_file;
	NautilusInfoProvider *extension_info_provider;
	NautilusOperationHandle *extension_info_in_progress;
116
	guint extension_info_idle;
117

Alexander Larsson's avatar
Alexander Larsson committed
118
	ThumbnailState *thumbnail_state;
119 120

	MountState *mount_state;
121 122

	FilesystemInfoState *filesystem_info_state;
123 124

	GList *file_operations_in_progress; /* list of FileOperation * */
125 126
};

Alexander Larsson's avatar
Alexander Larsson committed
127
NautilusDirectory *nautilus_directory_get_existing                    (GFile                     *location);
128

129
/* async. interface */
130 131 132
void               nautilus_directory_async_state_changed             (NautilusDirectory         *directory);
void               nautilus_directory_call_when_ready_internal        (NautilusDirectory         *directory,
								       NautilusFile              *file,
133
								       NautilusFileAttributes     file_attributes,
134
								       gboolean                   wait_for_file_list,
135 136 137 138 139
								       NautilusDirectoryCallback  directory_callback,
								       NautilusFileCallback       file_callback,
								       gpointer                   callback_data);
gboolean           nautilus_directory_check_if_ready_internal         (NautilusDirectory         *directory,
								       NautilusFile              *file,
140
								       NautilusFileAttributes     file_attributes);
141 142 143 144 145 146 147 148
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,
149
								       gboolean                   monitor_hidden_files,
150
								       NautilusFileAttributes     attributes,
Darin Adler's avatar
Darin Adler committed
151 152
								       NautilusDirectoryCallback  callback,
								       gpointer                   callback_data);
153 154 155 156 157
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);
158
NautilusFile *     nautilus_directory_get_existing_corresponding_file (NautilusDirectory         *directory);
159
void               nautilus_directory_invalidate_count_and_mime_list  (NautilusDirectory         *directory);
160 161
gboolean           nautilus_directory_is_file_list_monitored          (NautilusDirectory         *directory);
gboolean           nautilus_directory_is_anyone_monitoring_file_list  (NautilusDirectory         *directory);
162 163
gboolean           nautilus_directory_has_active_request_for_file     (NautilusDirectory         *directory,
								       NautilusFile              *file);
164 165 166 167 168 169
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);
170
void               nautilus_directory_force_reload_internal           (NautilusDirectory         *directory,
171
								       NautilusFileAttributes     file_attributes);
172 173
void               nautilus_directory_cancel_loading_file_attributes  (NautilusDirectory         *directory,
								       NautilusFile              *file,
174
								       NautilusFileAttributes     file_attributes);
175

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

193
/* Interface to the file list. */
194
NautilusFile *     nautilus_directory_find_file_by_name               (NautilusDirectory         *directory,
Alexander Larsson's avatar
Alexander Larsson committed
195
								       const char                *filename);
196

197 198 199 200
void               nautilus_directory_add_file                        (NautilusDirectory         *directory,
								       NautilusFile              *file);
void               nautilus_directory_remove_file                     (NautilusDirectory         *directory,
								       NautilusFile              *file);
201 202 203 204 205 206 207
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);
208 209 210 211 212
GList *            nautilus_directory_begin_file_name_change          (NautilusDirectory         *directory,
								       NautilusFile              *file);
void               nautilus_directory_end_file_name_change            (NautilusDirectory         *directory,
								       NautilusFile              *file,
								       GList                     *node);
213
void               nautilus_directory_moved                           (const char                *from_uri,
214
								       const char                *to_uri);
215 216 217 218 219 220
/* 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);
221

222

223
/* debugging functions */
224
int                nautilus_directory_number_outstanding              (void);