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

3
   nautilus-file-private.h:
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 24 25
#ifndef NAUTILUS_FILE_PRIVATE_H
#define NAUTILUS_FILE_PRIVATE_H

26 27 28
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-monitor.h>
29
#include <libnautilus-private/nautilus-file-undo-operations.h>
Ramiro Estrugo's avatar
Ramiro Estrugo committed
30
#include <eel/eel-glib-extensions.h>
Alexander Larsson's avatar
Alexander Larsson committed
31
#include <eel/eel-string.h>
32

Alexander Larsson's avatar
Alexander Larsson committed
33
#define NAUTILUS_FILE_DEFAULT_ATTRIBUTES				\
34
	"standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*,id::filesystem,trash::orig-path,trash::deletion-date,metadata::*"
Alexander Larsson's avatar
Alexander Larsson committed
35

36 37 38 39 40 41 42 43 44
/* These are in the typical sort order. Known things come first, then
 * things where we can't know, finally things where we don't yet know.
 */
typedef enum {
	KNOWN,
	UNKNOWABLE,
	UNKNOWN
} Knowledge;

45
struct NautilusFileDetails
46 47
{
	NautilusDirectory *directory;
Alexander Larsson's avatar
Alexander Larsson committed
48 49
	
	eel_ref_str name;
50

Alexander Larsson's avatar
Alexander Larsson committed
51 52
	/* File info: */
	GFileType type;
53

Alexander Larsson's avatar
Alexander Larsson committed
54 55
	eel_ref_str display_name;
	char *display_name_collation_key;
56
	char *directory_name_collation_key;
Alexander Larsson's avatar
Alexander Larsson committed
57
	eel_ref_str edit_name;
58

Alexander Larsson's avatar
Alexander Larsson committed
59 60 61 62 63 64 65
	goffset size; /* -1 is unknown */
	
	int sort_order;
	
	guint32 permissions;
	int uid; /* -1 is none */
	int gid; /* -1 is none */
66 67 68 69

	eel_ref_str owner;
	eel_ref_str owner_real;
	eel_ref_str group;
Alexander Larsson's avatar
Alexander Larsson committed
70 71 72 73 74 75 76 77
	
	time_t atime; /* 0 is unknown */
	time_t mtime; /* 0 is unknown */
	
	char *symlink_name;
	
	eel_ref_str mime_type;
	
78 79
	char *selinux_context;
	char *description;
Alexander Larsson's avatar
Alexander Larsson committed
80 81 82
	
	GError *get_info_error;
	
83
	guint directory_count;
84

85 86 87
	guint deep_directory_count;
	guint deep_file_count;
	guint deep_unreadable_count;
Alexander Larsson's avatar
Alexander Larsson committed
88
	goffset deep_size;
89

Alexander Larsson's avatar
Alexander Larsson committed
90 91 92 93
	GIcon *icon;
	
	char *thumbnail_path;
	GdkPixbuf *thumbnail;
94
	time_t thumbnail_mtime;
95 96 97 98

	GdkPixbuf *scaled_thumbnail;
	double thumbnail_scale;

99
	GList *mime_list; /* If this is a directory, the list of MIME types in it. */
Alexander Larsson's avatar
Alexander Larsson committed
100 101

	/* Info you might get from a link (.desktop, .directory or nautilus link) */
102
	GIcon *custom_icon;
103
	char *activation_uri;
104

105 106 107 108 109
	/* used during DND, for checking whether source and destination are on
	 * the same file system.
	 */
	eel_ref_str filesystem_id;

110 111
	char *trash_orig_path;

112 113 114 115 116 117
	/* The following is for file operations in progress. Since
	 * there are normally only a few of these, we can move them to
	 * a separate hash table or something if required to keep the
	 * file objects small.
	 */
	GList *operations_in_progress;
118

119 120 121 122 123 124 125 126 127 128 129
	/* NautilusInfoProviders that need to be run for this file */
	GList *pending_info_providers;

	/* Emblems provided by extensions */
	GList *extension_emblems;
	GList *pending_extension_emblems;

	/* Attributes provided by extensions */
	GHashTable *extension_attributes;
	GHashTable *pending_extension_attributes;

Alexander Larsson's avatar
Alexander Larsson committed
130 131
	GHashTable *metadata;

132 133 134
	/* Mount for mountpoint or the references GMount for a "mountable" */
	GMount *mount;
	
135 136 137
	/* boolean fields: bitfield to save space, since there can be
           many NautilusFile objects. */

Ramiro Estrugo's avatar
Ramiro Estrugo committed
138 139
	eel_boolean_bit unconfirmed                   : 1;
	eel_boolean_bit is_gone                       : 1;
140 141 142
	/* Set when emitting files_added on the directory to make sure we
	   add a file, and only once */
	eel_boolean_bit is_added                      : 1;
143 144 145
	/* Set by the NautilusDirectory while it's loading the file
	 * list so the file knows not to do redundant I/O.
	 */
Ramiro Estrugo's avatar
Ramiro Estrugo committed
146
	eel_boolean_bit loading_directory             : 1;
Alexander Larsson's avatar
Alexander Larsson committed
147
	eel_boolean_bit got_file_info                 : 1;
Ramiro Estrugo's avatar
Ramiro Estrugo committed
148 149
	eel_boolean_bit get_info_failed               : 1;
	eel_boolean_bit file_info_is_up_to_date       : 1;
150
	
Ramiro Estrugo's avatar
Ramiro Estrugo committed
151 152 153
	eel_boolean_bit got_directory_count           : 1;
	eel_boolean_bit directory_count_failed        : 1;
	eel_boolean_bit directory_count_is_up_to_date : 1;
154

155
	eel_boolean_bit deep_counts_status      : 2; /* NautilusRequestStatus */
156 157 158 159
	/* no deep_counts_are_up_to_date field; since we expose
           intermediate values for this attribute, we do actually
           forget it rather than invalidating. */

Ramiro Estrugo's avatar
Ramiro Estrugo committed
160 161 162
	eel_boolean_bit got_mime_list                 : 1;
	eel_boolean_bit mime_list_failed              : 1;
	eel_boolean_bit mime_list_is_up_to_date       : 1;
163

164 165
	eel_boolean_bit mount_is_up_to_date           : 1;
	
Alexander Larsson's avatar
Alexander Larsson committed
166 167
	eel_boolean_bit got_link_info                 : 1;
	eel_boolean_bit link_info_is_up_to_date       : 1;
Alexander Larsson's avatar
Alexander Larsson committed
168
	eel_boolean_bit got_custom_display_name       : 1;
169
	eel_boolean_bit got_custom_activation_uri     : 1;
170

Alexander Larsson's avatar
Alexander Larsson committed
171
	eel_boolean_bit thumbnail_is_up_to_date       : 1;
172
	eel_boolean_bit thumbnail_wants_original      : 1;
Alexander Larsson's avatar
Alexander Larsson committed
173 174 175
	eel_boolean_bit thumbnail_tried_original      : 1;
	eel_boolean_bit thumbnailing_failed           : 1;
	
Alexander Larsson's avatar
Alexander Larsson committed
176 177
	eel_boolean_bit is_thumbnailing               : 1;

178
	eel_boolean_bit is_launcher                   : 1;
179
	eel_boolean_bit is_trusted_link               : 1;
180
	eel_boolean_bit is_foreign_link               : 1;
Alexander Larsson's avatar
Alexander Larsson committed
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
	eel_boolean_bit is_symlink                    : 1;
	eel_boolean_bit is_mountpoint                 : 1;
	eel_boolean_bit is_hidden                     : 1;

	eel_boolean_bit has_permissions               : 1;
	
	eel_boolean_bit can_read                      : 1;
	eel_boolean_bit can_write                     : 1;
	eel_boolean_bit can_execute                   : 1;
	eel_boolean_bit can_delete                    : 1;
	eel_boolean_bit can_trash                     : 1;
	eel_boolean_bit can_rename                    : 1;
	eel_boolean_bit can_mount                     : 1;
	eel_boolean_bit can_unmount                   : 1;
	eel_boolean_bit can_eject                     : 1;
196
	eel_boolean_bit can_start                     : 1;
197
	eel_boolean_bit can_start_degraded            : 1;
198 199
	eel_boolean_bit can_stop                      : 1;
	eel_boolean_bit start_stop_type               : 3; /* GDriveStartStopType */
200 201
	eel_boolean_bit can_poll_for_media            : 1;
	eel_boolean_bit is_media_check_automatic      : 1;
202 203 204 205

	eel_boolean_bit filesystem_readonly           : 1;
	eel_boolean_bit filesystem_use_preview        : 2; /* GFilesystemPreviewType */
	eel_boolean_bit filesystem_info_is_up_to_date : 1;
206
        eel_ref_str     filesystem_type;
207 208

	time_t trash_time; /* 0 is unknown */
209

210 211
	gdouble search_relevance;

212 213
	guint64 free_space; /* (guint)-1 for unknown */
	time_t free_space_read; /* The time free_space was updated, or 0 for never */
214
};
215

Alexander Larsson's avatar
Alexander Larsson committed
216 217 218 219 220 221 222 223 224
typedef struct {
	NautilusFile *file;
	GCancellable *cancellable;
	NautilusFileOperationCallback callback;
	gpointer callback_data;
	gboolean is_rename;
	
	gpointer data;
	GDestroyNotify free_data;
225
	NautilusFileUndoInfo *undo_info;
Alexander Larsson's avatar
Alexander Larsson committed
226 227
} NautilusFileOperation;

228
NautilusFile *nautilus_file_new_from_info                  (NautilusDirectory      *directory,
Alexander Larsson's avatar
Alexander Larsson committed
229
							    GFileInfo              *info);
230 231
void          nautilus_file_emit_changed                   (NautilusFile           *file);
void          nautilus_file_mark_gone                      (NautilusFile           *file);
Cosimo Cecchi's avatar
Cosimo Cecchi committed
232

233 234 235
gboolean      nautilus_file_get_date                       (NautilusFile           *file,
							    NautilusDateType        date_type,
							    time_t                 *date);
236
void          nautilus_file_updated_deep_count_in_progress (NautilusFile           *file);
237

238

Alexander Larsson's avatar
Alexander Larsson committed
239
void          nautilus_file_clear_info                     (NautilusFile           *file);
240 241
/* Compare file's state with a fresh file info struct, return FALSE if
 * no change, update file and return TRUE if the file info contains
242
 * new state.  */
243
gboolean      nautilus_file_update_info                    (NautilusFile           *file,
Alexander Larsson's avatar
Alexander Larsson committed
244
							    GFileInfo              *info);
245 246
gboolean      nautilus_file_update_name                    (NautilusFile           *file,
							    const char             *name);
247 248
gboolean      nautilus_file_update_metadata_from_info      (NautilusFile           *file,
							    GFileInfo              *info);
249

250 251 252 253
gboolean      nautilus_file_update_name_and_directory      (NautilusFile           *file,
							    const char             *name,
							    NautilusDirectory      *directory);

Alexander Larsson's avatar
Alexander Larsson committed
254 255 256 257
gboolean      nautilus_file_set_display_name               (NautilusFile           *file,
							    const char             *display_name,
							    const char             *edit_name,
							    gboolean                custom);
258 259
void          nautilus_file_set_directory                  (NautilusFile           *file,
							    NautilusDirectory      *directory);
260 261
void          nautilus_file_set_mount                      (NautilusFile           *file,
							    GMount                 *mount);
Alexander Larsson's avatar
Alexander Larsson committed
262

263
/* Mark specified attributes for this file out of date without canceling current
264 265
 * I/O or kicking off new I/O.
 */
266 267 268 269 270 271 272 273
void                   nautilus_file_invalidate_attributes_internal     (NautilusFile           *file,
									 NautilusFileAttributes  file_attributes);
NautilusFileAttributes nautilus_file_get_all_attributes                 (void);
gboolean               nautilus_file_is_self_owned                      (NautilusFile           *file);
void                   nautilus_file_invalidate_count_and_mime_list     (NautilusFile           *file);
gboolean               nautilus_file_rename_in_progress                 (NautilusFile           *file);
void                   nautilus_file_invalidate_extension_info_internal (NautilusFile           *file);
void                   nautilus_file_info_providers_done                (NautilusFile           *file);
274

275

276 277 278 279
/* Thumbnailing: */
void          nautilus_file_set_is_thumbnailing            (NautilusFile           *file,
							    gboolean                is_thumbnailing);

Alexander Larsson's avatar
Alexander Larsson committed
280 281 282 283 284 285 286 287
NautilusFileOperation *nautilus_file_operation_new      (NautilusFile                  *file,
							 NautilusFileOperationCallback  callback,
							 gpointer                       callback_data);
void                   nautilus_file_operation_free     (NautilusFileOperation         *op);
void                   nautilus_file_operation_complete (NautilusFileOperation         *op,
							 GFile                         *result_location,
							 GError                        *error);
void                   nautilus_file_operation_cancel   (NautilusFileOperation         *op);
288

289
#endif