summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-file-private.h
blob: 9be02878c35f3c73131dfacc7092d520915c67dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-

   nautilus-file-private.h:
 
   Copyright (C) 1999, 2000, 2001 Eazel, Inc.
  
   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
   License along with this program; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
  
   Author: Darin Adler <darin@bentspoon.com>
*/

#ifndef NAUTILUS_FILE_PRIVATE_H
#define NAUTILUS_FILE_PRIVATE_H

#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-monitor.h>
#include <eel/eel-glib-extensions.h>

#define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_CHARACTERS_PER_LINE 80
#define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_LINES               24
#define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_BYTES            10000

/* 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;

typedef struct {
	int automatic_emblems_as_integer;
	char emblem_keywords[1];
} NautilusFileSortByEmblemCache;

struct NautilusFileDetails
{
	NautilusDirectory *directory;
	char *relative_uri;

	/* Cached version of the display name, guaranteed UTF8 safe.
	 * This is used a lot for sorting views.
	 */
	char *cached_display_name;
	/* We cache the result of g_utf8_collate_key() on
	 * cached_display_name in order to do quick sorting on
	 * the display name
	 */
	char *display_name_collation_key;

	GnomeVFSFileInfo *info;
	GnomeVFSResult get_info_error;

	NautilusMonitor *monitor;
	
	guint directory_count;

	guint deep_directory_count;
	guint deep_file_count;
	guint deep_unreadable_count;
	GnomeVFSFileSize deep_size;

	GList *mime_list; /* If this is a directory, the list of MIME types in it. */
	char *top_left_text;

	/* Info you might get from a link (.desktop, .directory or nautilus link) */
	char *display_name;
	char *custom_icon_uri;
	char *activation_uri;

	/* 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;

	/* We use this to cache automatic emblems and emblem keywords
	   to speed up compare_by_emblems. */
	NautilusFileSortByEmblemCache *compare_by_emblem_cache;
	
	/* boolean fields: bitfield to save space, since there can be
           many NautilusFile objects. */

	eel_boolean_bit unconfirmed                   : 1;
	eel_boolean_bit is_gone                       : 1;
	/* Set by the NautilusDirectory while it's loading the file
	 * list so the file knows not to do redundant I/O.
	 */
	eel_boolean_bit loading_directory             : 1;
	/* got_info known from info field being non-NULL */
	eel_boolean_bit get_info_failed               : 1;
	eel_boolean_bit file_info_is_up_to_date       : 1;

	eel_boolean_bit got_directory_count           : 1;
	eel_boolean_bit directory_count_failed        : 1;
	eel_boolean_bit directory_count_is_up_to_date : 1;

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

	eel_boolean_bit got_mime_list                 : 1;
	eel_boolean_bit mime_list_failed              : 1;
	eel_boolean_bit mime_list_is_up_to_date       : 1;

	eel_boolean_bit got_top_left_text             : 1;
	eel_boolean_bit top_left_text_is_up_to_date   : 1;

	eel_boolean_bit got_link_info                 : 1;
	eel_boolean_bit link_info_is_up_to_date       : 1;
};

NautilusFile *nautilus_file_new_from_info                  (NautilusDirectory      *directory,
							    GnomeVFSFileInfo       *info);
NautilusFile *nautilus_file_get_existing                   (const char             *uri);
void          nautilus_file_emit_changed                   (NautilusFile           *file);
void          nautilus_file_mark_gone                      (NautilusFile           *file);
gboolean      nautilus_file_info_missing                   (NautilusFile           *file,
							    GnomeVFSFileInfoFields  needed_mask);
char *        nautilus_extract_top_left_text               (const char             *text,
							    int                     length);
void          nautilus_file_set_directory                  (NautilusFile           *file,
							    NautilusDirectory      *directory);
gboolean      nautilus_file_get_date                       (NautilusFile           *file,
							    NautilusDateType        date_type,
							    time_t                 *date);
void          nautilus_file_updated_deep_count_in_progress (NautilusFile           *file);
void          nautilus_file_clear_cached_display_name      (NautilusFile           *file);


/* 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
 * new state.  */
gboolean      nautilus_file_update_info                    (NautilusFile           *file,
							    GnomeVFSFileInfo       *info);
gboolean      nautilus_file_update_name                    (NautilusFile           *file,
							    const char             *name);

/* Return true if the top lefts of files in this directory should be
 * fetched, according to the preference settings.
 */
gboolean      nautilus_file_should_get_top_left_text       (NautilusFile           *file);

/* Mark specified attributes for this file out of date without canceling current
 * I/O or kicking off new I/O.
 */
void          nautilus_file_invalidate_attributes_internal (NautilusFile           *file,
							    GList                  *file_attributes);
GList *       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);

#endif