summaryrefslogtreecommitdiff
path: root/libnautilus/nautilus-file.h
blob: 6cc0c79be2f11036554c213b28cc76e4fbf20747 (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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-

   nautilus-file.h: Nautilus file model.
 
   Copyright (C) 1999, 2000 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@eazel.com>
*/

#ifndef NAUTILUS_FILE_H
#define NAUTILUS_FILE_H

#include <gtk/gtkobject.h>
#include <libgnomevfs/gnome-vfs-types.h>

/* NautilusFile is an object used to represent a single element of a
 * NautilusDirectory. It's lightweight and relies on NautilusDirectory
 * to do most of the work.
 */

typedef struct NautilusFile NautilusFile;
typedef struct NautilusFileClass NautilusFileClass;

#define NAUTILUS_TYPE_FILE \
	(nautilus_file_get_type ())
#define NAUTILUS_FILE(obj) \
	(GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_FILE, NautilusFile))
#define NAUTILUS_FILE_CLASS(klass) \
	(GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_FILE, NautilusFileClass))
#define NAUTILUS_IS_FILE(obj) \
	(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_FILE))
#define NAUTILUS_IS_FILE_CLASS(klass) \
	(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_FILE))

typedef enum {
	NAUTILUS_FILE_SORT_NONE,
	NAUTILUS_FILE_SORT_BY_NAME,
	NAUTILUS_FILE_SORT_BY_SIZE,
	NAUTILUS_FILE_SORT_BY_TYPE,
	NAUTILUS_FILE_SORT_BY_MTIME,
	NAUTILUS_FILE_SORT_BY_EMBLEMS
} NautilusFileSortType;	

typedef void (*NautilusFileCallback) (NautilusFile *file,
				      gpointer      callback_data);

/* GtkObject requirements. */
GtkType          nautilus_file_get_type                  (void);

/* Getting at a single file. */
NautilusFile *   nautilus_file_get                       (const char           *uri);

/* Basic operations on file objects. */
void             nautilus_file_ref                       (NautilusFile         *file);
void             nautilus_file_unref                     (NautilusFile         *file);
void             nautilus_file_delete                    (NautilusFile         *file);

/* Waiting for data that's read asynchronously.
 * This interface currently works only for metadata, but could be expanded
 * to other attributes as well.
 */
void             nautilus_file_call_when_ready           (NautilusFile         *file,
							  GList                *metadata_tags,
							  NautilusFileCallback  callback,
							  gpointer              callback_data);
void             nautilus_file_cancel_callback           (NautilusFile         *file,
							  NautilusFileCallback  callback,
							  gpointer              callback_data);

/* Basic attributes for file objects. */
char *           nautilus_file_get_name                  (NautilusFile         *file);
char *           nautilus_file_get_uri                   (NautilusFile         *file);
GnomeVFSFileSize nautilus_file_get_size                  (NautilusFile         *file);
GnomeVFSFileType nautilus_file_get_file_type             (NautilusFile         *file);
const char *     nautilus_file_get_mime_type             (NautilusFile         *file);
gboolean         nautilus_file_is_symbolic_link          (NautilusFile         *file);
gboolean         nautilus_file_is_executable             (NautilusFile         *file);
gboolean         nautilus_file_is_directory              (NautilusFile         *file);
guint            nautilus_file_get_directory_item_count  (NautilusFile         *file,
							  gboolean              ignore_invisible_items);
GList *          nautilus_file_get_keywords              (NautilusFile         *file);
void             nautilus_file_set_keywords              (NautilusFile         *file,
							  GList                *keywords);
GList *          nautilus_file_get_emblem_names          (NautilusFile         *file);

/* Basic operations for file objects. */
gboolean         nautilus_file_can_rename                (NautilusFile         *file);
GnomeVFSResult   nautilus_file_rename                    (NautilusFile         *file,
							  const char           *new_name);

/* Return true if this file has already been deleted.
   This object will be unref'd after sending the files_removed signal,
   but it could hang around longer if someone ref'd it.
*/
gboolean         nautilus_file_is_gone                   (NautilusFile         *file);

/* Simple getting and setting top-level metadata. */
char *           nautilus_file_get_metadata              (NautilusFile         *file,
							  const char           *tag,
							  const char           *default_metadata);
void             nautilus_file_set_metadata              (NautilusFile         *file,
							  const char           *tag,
							  const char           *default_metadata,
							  const char           *metadata);

/* Attributes for file objects as user-displayable strings. */
char *           nautilus_file_get_string_attribute      (NautilusFile         *file,
							  const char           *attribute_name);

/* Comparing two file objects for sorting */
int              nautilus_file_compare_for_sort          (NautilusFile         *file_1,
							  NautilusFile         *file_2,
							  NautilusFileSortType  sort_type);
int              nautilus_file_compare_for_sort_reversed (NautilusFile         *file_1,
							  NautilusFile         *file_2,
							  NautilusFileSortType  sort_type);

/* Change notification hack.
 * This is called when code modifies the file and it needs to trigger
 * a notification. Eventually this should become private, but for now
 * it needs to be used for code like the thumbnail generation.
 */
void             nautilus_file_changed                   (NautilusFile         *file);

/* Convenience functions for dealing with a list of NautilusFile objects that each have a ref. */
void             nautilus_file_list_ref                  (GList                *file_list);
void             nautilus_file_list_unref                (GList                *file_list);
void             nautilus_file_list_free                 (GList                *file_list);

typedef struct NautilusFileDetails NautilusFileDetails;

struct NautilusFile
{
	GtkObject object;
	NautilusFileDetails *details;
};

struct NautilusFileClass
{
	GtkObjectClass parent_class;
	
	void (* changed) (NautilusFile *file);
};

#endif /* NAUTILUS_FILE_H */