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,
59 GTK_FILE_INFO_ICON = 1 << 6,
61 GTK_FILE_INFO_ALL = (1 << 7) - 1
65 /* Icon type, supplemented by MIME type
68 GTK_FILE_ICON_REGULAR, /* Use mime type for icon */
69 GTK_FILE_ICON_BLOCK_DEVICE,
70 GTK_FILE_ICON_BROKEN_SYMBOLIC_LINK,
71 GTK_FILE_ICON_CHARACTER_DEVICE,
72 GTK_FILE_ICON_DIRECTORY,
73 GTK_FILE_ICON_EXECUTABLE,
79 /* GError enumeration for GtkFileSystem
82 #define GTK_FILE_SYSTEM_ERROR (gtk_file_system_error_quark ())
86 GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
87 GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
88 GTK_FILE_SYSTEM_ERROR_INVALID_URI,
89 GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
90 GTK_FILE_SYSTEM_ERROR_FAILED,
93 GQuark gtk_file_system_error_quark (void);
95 /* Boxed-type for gtk_file_folder_get_info() results
97 #define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ())
99 GType gtk_file_info_get_type (void);
101 GtkFileInfo *gtk_file_info_new (void);
102 GtkFileInfo *gtk_file_info_copy (GtkFileInfo *info);
103 void gtk_file_info_free (GtkFileInfo *info);
106 G_CONST_RETURN gchar *gtk_file_info_get_display_name (const GtkFileInfo *info);
107 G_CONST_RETURN gchar *gtk_file_info_get_display_key (const GtkFileInfo *info);
108 void gtk_file_info_set_display_name (GtkFileInfo *info,
109 const gchar *display_name);
110 gboolean gtk_file_info_get_is_folder (const GtkFileInfo *info);
111 void gtk_file_info_set_is_folder (GtkFileInfo *info,
113 gboolean gtk_file_info_get_is_hidden (const GtkFileInfo *info);
114 void gtk_file_info_set_is_hidden (GtkFileInfo *info,
116 G_CONST_RETURN gchar *gtk_file_info_get_mime_type (const GtkFileInfo *info);
117 void gtk_file_info_set_mime_type (GtkFileInfo *info,
118 const gchar *mime_type);
119 GtkFileTime gtk_file_info_get_modification_time (const GtkFileInfo *info);
120 void gtk_file_info_set_modification_time (GtkFileInfo *info,
121 GtkFileTime modification_time);
122 gint64 gtk_file_info_get_size (const GtkFileInfo *info);
123 void gtk_file_info_set_size (GtkFileInfo *info,
126 void gtk_file_info_set_icon_type (GtkFileInfo *info,
127 GtkFileIconType icon_type);
128 GtkFileIconType gtk_file_info_get_icon_type (const GtkFileInfo *info);
129 GdkPixbuf * gtk_file_info_render_icon (const GtkFileInfo *info,
134 /* The base GtkFileSystem interface
136 #define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ())
137 #define GTK_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
138 #define GTK_IS_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
139 #define GTK_FILE_SYSTEM_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
141 struct _GtkFileSystemIface
143 GTypeInterface base_iface;
147 GSList * (*list_volumes) (GtkFileSystem *file_system);
148 GSList * (*list_roots) (GtkFileSystem *file_system);
150 GtkFileInfo * (*get_root_info) (GtkFileSystem *file_system,
151 const GtkFilePath *path,
152 GtkFileInfoType types,
155 GtkFileFolder * (*get_folder) (GtkFileSystem *file_system,
156 const GtkFilePath *path,
157 GtkFileInfoType types,
159 gboolean (*create_folder) (GtkFileSystem *file_system,
160 const GtkFilePath *path,
166 void (*volume_free) (GtkFileSystem *file_system,
167 GtkFileSystemVolume *volume);
168 GtkFilePath * (*volume_get_base_path) (GtkFileSystem *file_system,
169 GtkFileSystemVolume *volume);
170 gboolean (*volume_get_is_mounted) (GtkFileSystem *file_system,
171 GtkFileSystemVolume *volume);
172 gboolean (*volume_mount) (GtkFileSystem *file_system,
173 GtkFileSystemVolume *volume,
175 char * (*volume_get_display_name) (GtkFileSystem *file_system,
176 GtkFileSystemVolume *volume);
177 GdkPixbuf * (*volume_render_icon) (GtkFileSystem *file_system,
178 GtkFileSystemVolume *volume,
185 gboolean (*get_parent) (GtkFileSystem *file_system,
186 const GtkFilePath *path,
187 GtkFilePath **parent,
189 GtkFilePath * (*make_path) (GtkFileSystem *file_system,
190 const GtkFilePath *base_path,
191 const gchar *display_name,
193 gboolean (*parse) (GtkFileSystem *file_system,
194 const GtkFilePath *base_path,
196 GtkFilePath **folder,
199 gchar * (*path_to_uri) (GtkFileSystem *file_system,
200 const GtkFilePath *path);
201 gchar * (*path_to_filename) (GtkFileSystem *file_system,
202 const GtkFilePath *path);
203 GtkFilePath *(*uri_to_path) (GtkFileSystem *file_system,
205 GtkFilePath *(*filename_to_path) (GtkFileSystem *file_system,
210 GdkPixbuf * (*render_icon) (GtkFileSystem *file_system,
211 const GtkFilePath *path,
218 gboolean (*add_bookmark) (GtkFileSystem *file_system,
219 const GtkFilePath *path,
221 gboolean (*remove_bookmark) (GtkFileSystem *file_system,
222 const GtkFilePath *path,
224 GSList * (*list_bookmarks) (GtkFileSystem *file_system);
228 void (*volumes_changed) (GtkFileSystem *file_system);
229 void (*roots_changed) (GtkFileSystem *file_system);
230 void (*bookmarks_changed) (GtkFileSystem *file_system);
233 GType gtk_file_system_get_type (void);
235 GSList * gtk_file_system_list_volumes (GtkFileSystem *file_system);
236 GSList * gtk_file_system_list_roots (GtkFileSystem *file_system);
237 GtkFileInfo * gtk_file_system_get_root_info (GtkFileSystem *file_system,
238 const GtkFilePath *path,
239 GtkFileInfoType types,
242 void gtk_file_system_volume_free (GtkFileSystem *file_system,
243 GtkFileSystemVolume *volume);
244 GtkFilePath * gtk_file_system_volume_get_base_path (GtkFileSystem *file_system,
245 GtkFileSystemVolume *volume);
246 gboolean gtk_file_system_volume_get_is_mounted (GtkFileSystem *file_system,
247 GtkFileSystemVolume *volume);
248 gboolean gtk_file_system_volume_mount (GtkFileSystem *file_system,
249 GtkFileSystemVolume *volume,
251 char * gtk_file_system_volume_get_display_name (GtkFileSystem *file_system,
252 GtkFileSystemVolume *volume);
253 GdkPixbuf * gtk_file_system_volume_render_icon (GtkFileSystem *file_system,
254 GtkFileSystemVolume *volume,
259 gboolean gtk_file_system_get_parent (GtkFileSystem *file_system,
260 const GtkFilePath *path,
261 GtkFilePath **parent,
263 GtkFileFolder *gtk_file_system_get_folder (GtkFileSystem *file_system,
264 const GtkFilePath *path,
265 GtkFileInfoType types,
267 gboolean gtk_file_system_create_folder (GtkFileSystem *file_system,
268 const GtkFilePath *path,
270 GtkFilePath * gtk_file_system_make_path (GtkFileSystem *file_system,
271 const GtkFilePath *base_path,
272 const gchar *display_name,
274 gboolean gtk_file_system_parse (GtkFileSystem *file_system,
275 const GtkFilePath *base_path,
277 GtkFilePath **folder,
281 gchar * gtk_file_system_path_to_uri (GtkFileSystem *file_system,
282 const GtkFilePath *path);
283 gchar * gtk_file_system_path_to_filename (GtkFileSystem *file_system,
284 const GtkFilePath *path);
285 GtkFilePath *gtk_file_system_uri_to_path (GtkFileSystem *file_system,
287 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
288 const gchar *filename);
290 GdkPixbuf *gtk_file_system_render_icon (GtkFileSystem *file_system,
291 const GtkFilePath *path,
296 gboolean gtk_file_system_add_bookmark (GtkFileSystem *file_system,
297 const GtkFilePath *path,
299 gboolean gtk_file_system_remove_bookmark (GtkFileSystem *file_system,
300 const GtkFilePath *path,
302 GSList *gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
306 * Detailed information about a particular folder
308 #define GTK_TYPE_FILE_FOLDER (gtk_file_folder_get_type ())
309 #define GTK_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER, GtkFileFolder))
310 #define GTK_IS_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER))
311 #define GTK_FILE_FOLDER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_FOLDER, GtkFileFolderIface))
313 struct _GtkFileFolderIface
315 GTypeInterface base_iface;
319 GtkFileInfo * (*get_info) (GtkFileFolder *folder,
320 const GtkFilePath *path,
322 gboolean (*list_children) (GtkFileFolder *folder,
326 /* ??? refresh() ??? */
330 void (*deleted) (GtkFileFolder *monitor);
331 void (*files_added) (GtkFileFolder *monitor,
333 void (*files_changed) (GtkFileFolder *monitor,
335 void (*files_removed) (GtkFileFolder *monitor,
339 GType gtk_file_folder_get_type (void);
340 gboolean gtk_file_folder_list_children (GtkFileFolder *folder,
343 GtkFileInfo *gtk_file_folder_get_info (GtkFileFolder *folder,
344 const GtkFilePath *path,
348 #define gtk_file_path_new_dup(str) \
349 ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
350 #define gtk_file_path_new_steal(str) \
351 ({ gchar *__s = (str); (GtkFilePath *)__s; })
352 #define gtk_file_path_get_string(path) \
353 ({ const GtkFilePath *__p = (path); (const gchar *)__p; })
354 #define gtk_file_path_free(path) \
355 ({ GtkFilePath *__p = (path); g_free (__p); })
357 #define gtk_file_path_new_dup(str) ((GtkFilePath *)g_strdup(str))
358 #define gtk_file_path_new_steal(str) ((GtkFilePath *)(str))
359 #define gtk_file_path_get_string(str) ((const gchar *)(str))
360 #define gtk_file_path_free(path) g_free (path)
363 #define gtk_file_path_copy(path) gtk_file_path_new_dup (gtk_file_path_get_string(path))
364 #define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
365 gtk_file_path_get_string (path2))
367 GSList *gtk_file_paths_sort (GSList *paths);
368 GSList *gtk_file_paths_copy (GSList *paths);
369 void gtk_file_paths_free (GSList *paths);
373 #endif /* __GTK_FILE_SYSTEM_H__ */