1 /* GTK - The GIMP Toolkit
2 * gtkfilesystem.h: Abstract file system interfaces
3 * Copyright (C) 2003, Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef __GTK_FILE_SYSTEM_H__
22 #define __GTK_FILE_SYSTEM_H__
24 /* This is a "semi-private" header; it is meant only for
25 * alternate GtkFileChooser backend modules; no stability guarantees
26 * are made at this point
28 #ifndef GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED
29 #error "GtkFileSystem is not supported API for general use"
32 #include <glib-object.h>
33 #include <gtk/gtkwidget.h> /* For icon handling */
37 typedef gint64 GtkFileTime;
39 typedef struct _GtkFileFolder GtkFileFolder;
40 typedef struct _GtkFileFolderIface GtkFileFolderIface;
41 typedef struct _GtkFileInfo GtkFileInfo;
42 typedef struct _GtkFileSystem GtkFileSystem;
43 typedef struct _GtkFileSystemIface GtkFileSystemIface;
44 typedef struct _GtkFileSystemVolume GtkFileSystemVolume;
46 typedef struct _GtkFilePath GtkFilePath;
48 /* Mask of information about a file, for monitoring and
49 * gtk_file_system_get_info()
52 GTK_FILE_INFO_DISPLAY_NAME = 1 << 0,
53 GTK_FILE_INFO_IS_FOLDER = 1 << 1,
54 GTK_FILE_INFO_IS_HIDDEN = 1 << 2,
55 GTK_FILE_INFO_MIME_TYPE = 1 << 3,
56 GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
57 GTK_FILE_INFO_SIZE = 1 << 5,
58 GTK_FILE_INFO_ALL = (1 << 6) - 1
61 /* GError enumeration for GtkFileSystem
64 #define GTK_FILE_SYSTEM_ERROR (gtk_file_system_error_quark ())
68 GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
69 GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
70 GTK_FILE_SYSTEM_ERROR_INVALID_URI,
71 GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
72 GTK_FILE_SYSTEM_ERROR_FAILED,
73 GTK_FILE_SYSTEM_ERROR_ALREADY_EXISTS
76 GQuark gtk_file_system_error_quark (void);
78 /* Boxed-type for gtk_file_folder_get_info() results
80 #define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ())
82 GType gtk_file_info_get_type (void);
84 GtkFileInfo *gtk_file_info_new (void);
85 GtkFileInfo *gtk_file_info_copy (GtkFileInfo *info);
86 void gtk_file_info_free (GtkFileInfo *info);
89 G_CONST_RETURN gchar *gtk_file_info_get_display_name (const GtkFileInfo *info);
90 G_CONST_RETURN gchar *gtk_file_info_get_display_key (const GtkFileInfo *info);
91 void gtk_file_info_set_display_name (GtkFileInfo *info,
92 const gchar *display_name);
93 gboolean gtk_file_info_get_is_folder (const GtkFileInfo *info);
94 void gtk_file_info_set_is_folder (GtkFileInfo *info,
96 gboolean gtk_file_info_get_is_hidden (const GtkFileInfo *info);
97 void gtk_file_info_set_is_hidden (GtkFileInfo *info,
99 G_CONST_RETURN gchar *gtk_file_info_get_mime_type (const GtkFileInfo *info);
100 void gtk_file_info_set_mime_type (GtkFileInfo *info,
101 const gchar *mime_type);
102 GtkFileTime gtk_file_info_get_modification_time (const GtkFileInfo *info);
103 void gtk_file_info_set_modification_time (GtkFileInfo *info,
104 GtkFileTime modification_time);
105 gint64 gtk_file_info_get_size (const GtkFileInfo *info);
106 void gtk_file_info_set_size (GtkFileInfo *info,
109 /* The base GtkFileSystem interface
111 #define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ())
112 #define GTK_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
113 #define GTK_IS_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
114 #define GTK_FILE_SYSTEM_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
116 struct _GtkFileSystemIface
118 GTypeInterface base_iface;
122 GSList * (*list_volumes) (GtkFileSystem *file_system);
123 GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem *file_system,
124 const GtkFilePath *path);
126 GtkFileFolder * (*get_folder) (GtkFileSystem *file_system,
127 const GtkFilePath *path,
128 GtkFileInfoType types,
130 gboolean (*create_folder) (GtkFileSystem *file_system,
131 const GtkFilePath *path,
137 void (*volume_free) (GtkFileSystem *file_system,
138 GtkFileSystemVolume *volume);
139 GtkFilePath * (*volume_get_base_path) (GtkFileSystem *file_system,
140 GtkFileSystemVolume *volume);
141 gboolean (*volume_get_is_mounted) (GtkFileSystem *file_system,
142 GtkFileSystemVolume *volume);
143 gboolean (*volume_mount) (GtkFileSystem *file_system,
144 GtkFileSystemVolume *volume,
146 char * (*volume_get_display_name) (GtkFileSystem *file_system,
147 GtkFileSystemVolume *volume);
148 GdkPixbuf * (*volume_render_icon) (GtkFileSystem *file_system,
149 GtkFileSystemVolume *volume,
156 gboolean (*get_parent) (GtkFileSystem *file_system,
157 const GtkFilePath *path,
158 GtkFilePath **parent,
160 GtkFilePath * (*make_path) (GtkFileSystem *file_system,
161 const GtkFilePath *base_path,
162 const gchar *display_name,
164 gboolean (*parse) (GtkFileSystem *file_system,
165 const GtkFilePath *base_path,
167 GtkFilePath **folder,
170 gchar * (*path_to_uri) (GtkFileSystem *file_system,
171 const GtkFilePath *path);
172 gchar * (*path_to_filename) (GtkFileSystem *file_system,
173 const GtkFilePath *path);
174 GtkFilePath *(*uri_to_path) (GtkFileSystem *file_system,
176 GtkFilePath *(*filename_to_path) (GtkFileSystem *file_system,
181 GdkPixbuf * (*render_icon) (GtkFileSystem *file_system,
182 const GtkFilePath *path,
189 gboolean (*insert_bookmark) (GtkFileSystem *file_system,
190 const GtkFilePath *path,
193 gboolean (*remove_bookmark) (GtkFileSystem *file_system,
194 const GtkFilePath *path,
196 GSList * (*list_bookmarks) (GtkFileSystem *file_system);
200 void (*volumes_changed) (GtkFileSystem *file_system);
201 void (*bookmarks_changed) (GtkFileSystem *file_system);
204 GType gtk_file_system_get_type (void);
206 GSList * gtk_file_system_list_volumes (GtkFileSystem *file_system);
208 GtkFileSystemVolume *gtk_file_system_get_volume_for_path (GtkFileSystem *file_system,
209 const GtkFilePath *path);
211 void gtk_file_system_volume_free (GtkFileSystem *file_system,
212 GtkFileSystemVolume *volume);
213 GtkFilePath * gtk_file_system_volume_get_base_path (GtkFileSystem *file_system,
214 GtkFileSystemVolume *volume);
215 gboolean gtk_file_system_volume_get_is_mounted (GtkFileSystem *file_system,
216 GtkFileSystemVolume *volume);
217 gboolean gtk_file_system_volume_mount (GtkFileSystem *file_system,
218 GtkFileSystemVolume *volume,
220 char * gtk_file_system_volume_get_display_name (GtkFileSystem *file_system,
221 GtkFileSystemVolume *volume);
222 GdkPixbuf * gtk_file_system_volume_render_icon (GtkFileSystem *file_system,
223 GtkFileSystemVolume *volume,
228 gboolean gtk_file_system_get_parent (GtkFileSystem *file_system,
229 const GtkFilePath *path,
230 GtkFilePath **parent,
232 GtkFileFolder *gtk_file_system_get_folder (GtkFileSystem *file_system,
233 const GtkFilePath *path,
234 GtkFileInfoType types,
236 gboolean gtk_file_system_create_folder (GtkFileSystem *file_system,
237 const GtkFilePath *path,
239 GtkFilePath * gtk_file_system_make_path (GtkFileSystem *file_system,
240 const GtkFilePath *base_path,
241 const gchar *display_name,
243 gboolean gtk_file_system_parse (GtkFileSystem *file_system,
244 const GtkFilePath *base_path,
246 GtkFilePath **folder,
250 gchar * gtk_file_system_path_to_uri (GtkFileSystem *file_system,
251 const GtkFilePath *path);
252 gchar * gtk_file_system_path_to_filename (GtkFileSystem *file_system,
253 const GtkFilePath *path);
254 GtkFilePath *gtk_file_system_uri_to_path (GtkFileSystem *file_system,
256 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
257 const gchar *filename);
259 gboolean gtk_file_system_path_is_local (GtkFileSystem *filesystem,
260 const GtkFilePath *path);
262 GdkPixbuf *gtk_file_system_render_icon (GtkFileSystem *file_system,
263 const GtkFilePath *path,
268 gboolean gtk_file_system_insert_bookmark (GtkFileSystem *file_system,
269 const GtkFilePath *path,
272 gboolean gtk_file_system_remove_bookmark (GtkFileSystem *file_system,
273 const GtkFilePath *path,
275 GSList *gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
279 * Detailed information about a particular folder
281 #define GTK_TYPE_FILE_FOLDER (gtk_file_folder_get_type ())
282 #define GTK_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER, GtkFileFolder))
283 #define GTK_IS_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER))
284 #define GTK_FILE_FOLDER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_FOLDER, GtkFileFolderIface))
286 struct _GtkFileFolderIface
288 GTypeInterface base_iface;
292 GtkFileInfo * (*get_info) (GtkFileFolder *folder,
293 const GtkFilePath *path,
295 gboolean (*list_children) (GtkFileFolder *folder,
299 /* ??? refresh() ??? */
303 void (*deleted) (GtkFileFolder *monitor);
304 void (*files_added) (GtkFileFolder *monitor,
306 void (*files_changed) (GtkFileFolder *monitor,
308 void (*files_removed) (GtkFileFolder *monitor,
312 GType gtk_file_folder_get_type (void);
313 gboolean gtk_file_folder_list_children (GtkFileFolder *folder,
316 GtkFileInfo *gtk_file_folder_get_info (GtkFileFolder *folder,
317 const GtkFilePath *path,
322 #define GTK_TYPE_FILE_PATH (gtk_file_path_get_type ())
323 #define GTK_FILE_PATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_PATH, GtkFilePath))
324 #define GTK_IS_FILE_PATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_PATH))
326 GType gtk_file_path_get_type (void);
328 #define gtk_file_path_new_dup(str) \
329 ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
330 #define gtk_file_path_new_steal(str) \
331 ({ gchar *__s = (str); (GtkFilePath *)__s; })
332 #define gtk_file_path_get_string(path) \
333 ({ const GtkFilePath *__p = (path); (const gchar *)__p; })
334 #define gtk_file_path_free(path) \
335 ({ GtkFilePath *__p = (path); g_free (__p); })
337 #define gtk_file_path_new_dup(str) ((GtkFilePath *)g_strdup(str))
338 #define gtk_file_path_new_steal(str) ((GtkFilePath *)(str))
339 #define gtk_file_path_get_string(str) ((const gchar *)(str))
340 #define gtk_file_path_free(path) g_free (path)
343 #define gtk_file_path_copy(path) gtk_file_path_new_dup (gtk_file_path_get_string(path))
344 #define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
345 gtk_file_path_get_string (path2))
347 GSList *gtk_file_paths_sort (GSList *paths);
348 GSList *gtk_file_paths_copy (GSList *paths);
349 void gtk_file_paths_free (GSList *paths);
351 /* GtkFileSystem modules support */
353 GtkFileSystem *_gtk_file_system_create (const char *file_system_name);
357 #endif /* __GTK_FILE_SYSTEM_H__ */