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 GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem *file_system,
149 const GtkFilePath *path);
151 GtkFileFolder * (*get_folder) (GtkFileSystem *file_system,
152 const GtkFilePath *path,
153 GtkFileInfoType types,
155 gboolean (*create_folder) (GtkFileSystem *file_system,
156 const GtkFilePath *path,
162 void (*volume_free) (GtkFileSystem *file_system,
163 GtkFileSystemVolume *volume);
164 GtkFilePath * (*volume_get_base_path) (GtkFileSystem *file_system,
165 GtkFileSystemVolume *volume);
166 gboolean (*volume_get_is_mounted) (GtkFileSystem *file_system,
167 GtkFileSystemVolume *volume);
168 gboolean (*volume_mount) (GtkFileSystem *file_system,
169 GtkFileSystemVolume *volume,
171 char * (*volume_get_display_name) (GtkFileSystem *file_system,
172 GtkFileSystemVolume *volume);
173 GdkPixbuf * (*volume_render_icon) (GtkFileSystem *file_system,
174 GtkFileSystemVolume *volume,
181 gboolean (*get_parent) (GtkFileSystem *file_system,
182 const GtkFilePath *path,
183 GtkFilePath **parent,
185 GtkFilePath * (*make_path) (GtkFileSystem *file_system,
186 const GtkFilePath *base_path,
187 const gchar *display_name,
189 gboolean (*parse) (GtkFileSystem *file_system,
190 const GtkFilePath *base_path,
192 GtkFilePath **folder,
195 gchar * (*path_to_uri) (GtkFileSystem *file_system,
196 const GtkFilePath *path);
197 gchar * (*path_to_filename) (GtkFileSystem *file_system,
198 const GtkFilePath *path);
199 GtkFilePath *(*uri_to_path) (GtkFileSystem *file_system,
201 GtkFilePath *(*filename_to_path) (GtkFileSystem *file_system,
206 GdkPixbuf * (*render_icon) (GtkFileSystem *file_system,
207 const GtkFilePath *path,
214 gboolean (*add_bookmark) (GtkFileSystem *file_system,
215 const GtkFilePath *path,
217 gboolean (*remove_bookmark) (GtkFileSystem *file_system,
218 const GtkFilePath *path,
220 GSList * (*list_bookmarks) (GtkFileSystem *file_system);
224 void (*volumes_changed) (GtkFileSystem *file_system);
225 void (*bookmarks_changed) (GtkFileSystem *file_system);
228 GType gtk_file_system_get_type (void);
230 GSList * gtk_file_system_list_volumes (GtkFileSystem *file_system);
232 GtkFileSystemVolume *gtk_file_system_get_volume_for_path (GtkFileSystem *file_system,
233 const GtkFilePath *path);
235 void gtk_file_system_volume_free (GtkFileSystem *file_system,
236 GtkFileSystemVolume *volume);
237 GtkFilePath * gtk_file_system_volume_get_base_path (GtkFileSystem *file_system,
238 GtkFileSystemVolume *volume);
239 gboolean gtk_file_system_volume_get_is_mounted (GtkFileSystem *file_system,
240 GtkFileSystemVolume *volume);
241 gboolean gtk_file_system_volume_mount (GtkFileSystem *file_system,
242 GtkFileSystemVolume *volume,
244 char * gtk_file_system_volume_get_display_name (GtkFileSystem *file_system,
245 GtkFileSystemVolume *volume);
246 GdkPixbuf * gtk_file_system_volume_render_icon (GtkFileSystem *file_system,
247 GtkFileSystemVolume *volume,
252 gboolean gtk_file_system_get_parent (GtkFileSystem *file_system,
253 const GtkFilePath *path,
254 GtkFilePath **parent,
256 GtkFileFolder *gtk_file_system_get_folder (GtkFileSystem *file_system,
257 const GtkFilePath *path,
258 GtkFileInfoType types,
260 gboolean gtk_file_system_create_folder (GtkFileSystem *file_system,
261 const GtkFilePath *path,
263 GtkFilePath * gtk_file_system_make_path (GtkFileSystem *file_system,
264 const GtkFilePath *base_path,
265 const gchar *display_name,
267 gboolean gtk_file_system_parse (GtkFileSystem *file_system,
268 const GtkFilePath *base_path,
270 GtkFilePath **folder,
274 gchar * gtk_file_system_path_to_uri (GtkFileSystem *file_system,
275 const GtkFilePath *path);
276 gchar * gtk_file_system_path_to_filename (GtkFileSystem *file_system,
277 const GtkFilePath *path);
278 GtkFilePath *gtk_file_system_uri_to_path (GtkFileSystem *file_system,
280 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
281 const gchar *filename);
283 GdkPixbuf *gtk_file_system_render_icon (GtkFileSystem *file_system,
284 const GtkFilePath *path,
289 gboolean gtk_file_system_add_bookmark (GtkFileSystem *file_system,
290 const GtkFilePath *path,
292 gboolean gtk_file_system_remove_bookmark (GtkFileSystem *file_system,
293 const GtkFilePath *path,
295 GSList *gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
299 * Detailed information about a particular folder
301 #define GTK_TYPE_FILE_FOLDER (gtk_file_folder_get_type ())
302 #define GTK_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER, GtkFileFolder))
303 #define GTK_IS_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER))
304 #define GTK_FILE_FOLDER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_FOLDER, GtkFileFolderIface))
306 struct _GtkFileFolderIface
308 GTypeInterface base_iface;
312 GtkFileInfo * (*get_info) (GtkFileFolder *folder,
313 const GtkFilePath *path,
315 gboolean (*list_children) (GtkFileFolder *folder,
319 /* ??? refresh() ??? */
323 void (*deleted) (GtkFileFolder *monitor);
324 void (*files_added) (GtkFileFolder *monitor,
326 void (*files_changed) (GtkFileFolder *monitor,
328 void (*files_removed) (GtkFileFolder *monitor,
332 GType gtk_file_folder_get_type (void);
333 gboolean gtk_file_folder_list_children (GtkFileFolder *folder,
336 GtkFileInfo *gtk_file_folder_get_info (GtkFileFolder *folder,
337 const GtkFilePath *path,
341 #define gtk_file_path_new_dup(str) \
342 ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
343 #define gtk_file_path_new_steal(str) \
344 ({ gchar *__s = (str); (GtkFilePath *)__s; })
345 #define gtk_file_path_get_string(path) \
346 ({ const GtkFilePath *__p = (path); (const gchar *)__p; })
347 #define gtk_file_path_free(path) \
348 ({ GtkFilePath *__p = (path); g_free (__p); })
350 #define gtk_file_path_new_dup(str) ((GtkFilePath *)g_strdup(str))
351 #define gtk_file_path_new_steal(str) ((GtkFilePath *)(str))
352 #define gtk_file_path_get_string(str) ((const gchar *)(str))
353 #define gtk_file_path_free(path) g_free (path)
356 #define gtk_file_path_copy(path) gtk_file_path_new_dup (gtk_file_path_get_string(path))
357 #define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
358 gtk_file_path_get_string (path2))
360 GSList *gtk_file_paths_sort (GSList *paths);
361 GSList *gtk_file_paths_copy (GSList *paths);
362 void gtk_file_paths_free (GSList *paths);
366 #endif /* __GTK_FILE_SYSTEM_H__ */