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;
45 typedef struct _GtkFilePath GtkFilePath;
47 /* Mask of information about a file, for monitoring and
48 * gtk_file_system_get_info()
51 GTK_FILE_INFO_DISPLAY_NAME = 1 << 0,
52 GTK_FILE_INFO_IS_FOLDER = 1 << 1,
53 GTK_FILE_INFO_IS_HIDDEN = 1 << 2,
54 GTK_FILE_INFO_MIME_TYPE = 1 << 3,
55 GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
56 GTK_FILE_INFO_SIZE = 1 << 5,
57 GTK_FILE_INFO_ICON = 1 << 6,
58 GTK_FILE_INFO_ALL = (1 << 7) - 1
61 /* Icon type, supplemented by MIME type
64 GTK_FILE_ICON_REGULAR, /* Use mime type for icon */
65 GTK_FILE_ICON_BLOCK_DEVICE,
66 GTK_FILE_ICON_BROKEN_SYMBOLIC_LINK,
67 GTK_FILE_ICON_CHARACTER_DEVICE,
68 GTK_FILE_ICON_DIRECTORY,
69 GTK_FILE_ICON_EXECUTABLE,
74 /* GError enumeration for GtkFileSystem
77 #define GTK_FILE_SYSTEM_ERROR (gtk_file_system_error_quark ())
81 GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
82 GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
83 GTK_FILE_SYSTEM_ERROR_INVALID_URI,
84 GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
85 GTK_FILE_SYSTEM_ERROR_FAILED,
88 GQuark gtk_file_system_error_quark (void);
90 /* Boxed-type for gtk_file_folder_get_info() results
92 #define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ())
94 GType gtk_file_info_get_type (void);
96 GtkFileInfo *gtk_file_info_new (void);
97 GtkFileInfo *gtk_file_info_copy (GtkFileInfo *info);
98 void gtk_file_info_free (GtkFileInfo *info);
101 G_CONST_RETURN gchar *gtk_file_info_get_display_name (const GtkFileInfo *info);
102 G_CONST_RETURN gchar *gtk_file_info_get_display_key (const GtkFileInfo *info);
103 void gtk_file_info_set_display_name (GtkFileInfo *info,
104 const gchar *display_name);
105 gboolean gtk_file_info_get_is_folder (const GtkFileInfo *info);
106 void gtk_file_info_set_is_folder (GtkFileInfo *info,
108 gboolean gtk_file_info_get_is_hidden (const GtkFileInfo *info);
109 void gtk_file_info_set_is_hidden (GtkFileInfo *info,
111 G_CONST_RETURN gchar *gtk_file_info_get_mime_type (const GtkFileInfo *info);
112 void gtk_file_info_set_mime_type (GtkFileInfo *info,
113 const gchar *mime_type);
114 GtkFileTime gtk_file_info_get_modification_time (const GtkFileInfo *info);
115 void gtk_file_info_set_modification_time (GtkFileInfo *info,
116 GtkFileTime modification_time);
117 gint64 gtk_file_info_get_size (const GtkFileInfo *info);
118 void gtk_file_info_set_size (GtkFileInfo *info,
120 void gtk_file_info_set_icon_type (GtkFileInfo *info,
121 GtkFileIconType icon_type);
122 GtkFileIconType gtk_file_info_get_icon_type (const GtkFileInfo *info);
123 GdkPixbuf * gtk_file_info_render_icon (const GtkFileInfo *info,
127 /* The base GtkFileSystem interface
129 #define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ())
130 #define GTK_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
131 #define GTK_IS_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
132 #define GTK_FILE_SYSTEM_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
134 struct _GtkFileSystemIface
136 GTypeInterface base_iface;
140 GSList * (*list_roots) (GtkFileSystem *file_system);
142 GtkFileInfo * (*get_root_info) (GtkFileSystem *file_system,
143 const GtkFilePath *path,
144 GtkFileInfoType types,
147 GtkFileFolder * (*get_folder) (GtkFileSystem *file_system,
148 const GtkFilePath *path,
149 GtkFileInfoType types,
151 gboolean (*create_folder) (GtkFileSystem *file_system,
152 const GtkFilePath *path,
157 gboolean (*get_parent) (GtkFileSystem *file_system,
158 const GtkFilePath *path,
159 GtkFilePath **parent,
161 GtkFilePath * (*make_path) (GtkFileSystem *file_system,
162 const GtkFilePath *base_path,
163 const gchar *display_name,
165 gboolean (*parse) (GtkFileSystem *file_system,
166 const GtkFilePath *base_path,
168 GtkFilePath **folder,
171 gchar * (*path_to_uri) (GtkFileSystem *file_system,
172 const GtkFilePath *path);
173 gchar * (*path_to_filename) (GtkFileSystem *file_system,
174 const GtkFilePath *path);
175 GtkFilePath *(*uri_to_path) (GtkFileSystem *file_system,
177 GtkFilePath *(*filename_to_path) (GtkFileSystem *file_system,
182 gboolean (*add_bookmark) (GtkFileSystem *file_system,
183 const GtkFilePath *path,
185 gboolean (*remove_bookmark) (GtkFileSystem *file_system,
186 const GtkFilePath *path,
188 GSList * (*list_bookmarks) (GtkFileSystem *file_system);
192 void (*roots_changed) (GtkFileSystem *file_system);
193 void (*bookmarks_changed) (GtkFileSystem *file_system);
196 GType gtk_file_system_get_type (void);
198 GSList * gtk_file_system_list_roots (GtkFileSystem *file_system);
199 GtkFileInfo * gtk_file_system_get_root_info (GtkFileSystem *file_system,
200 const GtkFilePath *path,
201 GtkFileInfoType types,
204 gboolean gtk_file_system_get_parent (GtkFileSystem *file_system,
205 const GtkFilePath *path,
206 GtkFilePath **parent,
208 GtkFileFolder *gtk_file_system_get_folder (GtkFileSystem *file_system,
209 const GtkFilePath *path,
210 GtkFileInfoType types,
212 gboolean gtk_file_system_create_folder (GtkFileSystem *file_system,
213 const GtkFilePath *path,
215 GtkFilePath * gtk_file_system_make_path (GtkFileSystem *file_system,
216 const GtkFilePath *base_path,
217 const gchar *display_name,
219 gboolean gtk_file_system_parse (GtkFileSystem *file_system,
220 const GtkFilePath *base_path,
222 GtkFilePath **folder,
226 gchar * gtk_file_system_path_to_uri (GtkFileSystem *file_system,
227 const GtkFilePath *path);
228 gchar * gtk_file_system_path_to_filename (GtkFileSystem *file_system,
229 const GtkFilePath *path);
230 GtkFilePath *gtk_file_system_uri_to_path (GtkFileSystem *file_system,
232 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
233 const gchar *filename);
235 gboolean gtk_file_system_add_bookmark (GtkFileSystem *file_system,
236 const GtkFilePath *path,
238 gboolean gtk_file_system_remove_bookmark (GtkFileSystem *file_system,
239 const GtkFilePath *path,
241 GSList *gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
245 * Detailed information about a particular folder
247 #define GTK_TYPE_FILE_FOLDER (gtk_file_folder_get_type ())
248 #define GTK_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER, GtkFileFolder))
249 #define GTK_IS_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER))
250 #define GTK_FILE_FOLDER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_FOLDER, GtkFileFolderIface))
252 struct _GtkFileFolderIface
254 GTypeInterface base_iface;
258 GtkFileInfo * (*get_info) (GtkFileFolder *folder,
259 const GtkFilePath *path,
261 gboolean (*list_children) (GtkFileFolder *folder,
265 /* ??? refresh() ??? */
269 void (*deleted) (GtkFileFolder *monitor);
270 void (*files_added) (GtkFileFolder *monitor,
272 void (*files_changed) (GtkFileFolder *monitor,
274 void (*files_removed) (GtkFileFolder *monitor,
278 GType gtk_file_folder_get_type (void);
279 gboolean gtk_file_folder_list_children (GtkFileFolder *folder,
282 GtkFileInfo *gtk_file_folder_get_info (GtkFileFolder *folder,
283 const GtkFilePath *path,
287 #define gtk_file_path_new_dup(str) \
288 ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
289 #define gtk_file_path_new_steal(str) \
290 ({ gchar *__s = (str); (GtkFilePath *)__s; })
291 #define gtk_file_path_get_string(path) \
292 ({ const GtkFilePath *__p = (path); (const gchar *)__p; })
293 #define gtk_file_path_free(path) \
294 ({ GtkFilePath *__p = (path); g_free (__p); })
296 #define gtk_file_path_new_dup(str) ((GtkFilePath *)g_strdup(str))
297 #define gtk_file_path_new_steal(str) ((GtkFilePath *)(str))
298 #define gtk_file_path_get_string(str) ((const gchar *)(str))
299 #define gtk_file_path_free(path) g_free (path)
302 #define gtk_file_path_copy(path) gtk_file_path_new_dup (gtk_file_path_get_string(path))
303 #define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
304 gtk_file_path_get_string (path2))
306 GSList *gtk_file_paths_sort (GSList *paths);
307 GSList *gtk_file_paths_copy (GSList *paths);
308 void gtk_file_paths_free (GSList *paths);
312 #endif /* __GTK_FILE_SYSTEM_H__ */