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 #include <glib-object.h>
25 #include <gtk/gtkwidget.h> /* For icon handling */
29 typedef gint64 GtkFileTime;
31 typedef struct _GtkFileFolder GtkFileFolder;
32 typedef struct _GtkFileFolderIface GtkFileFolderIface;
33 typedef struct _GtkFileInfo GtkFileInfo;
34 typedef struct _GtkFileSystem GtkFileSystem;
35 typedef struct _GtkFileSystemIface GtkFileSystemIface;
37 typedef struct _GtkFilePath GtkFilePath;
39 /* Mask of information about a file, for monitoring and
40 * gtk_file_system_get_info()
43 GTK_FILE_INFO_DISPLAY_NAME = 1 << 0,
44 GTK_FILE_INFO_IS_FOLDER = 1 << 1,
45 GTK_FILE_INFO_IS_HIDDEN = 1 << 2,
46 GTK_FILE_INFO_MIME_TYPE = 1 << 3,
47 GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
48 GTK_FILE_INFO_SIZE = 1 << 5,
49 GTK_FILE_INFO_ICON = 1 << 6,
50 GTK_FILE_INFO_ALL = (1 << 7) - 1
53 /* Icon type, supplemented by MIME type
56 GTK_FILE_ICON_REGULAR, /* Use mime type for icon */
57 GTK_FILE_ICON_BLOCK_DEVICE,
58 GTK_FILE_ICON_BROKEN_SYMBOLIC_LINK,
59 GTK_FILE_ICON_CHARACTER_DEVICE,
60 GTK_FILE_ICON_DIRECTORY,
61 GTK_FILE_ICON_EXECUTABLE,
66 /* GError enumeration for GtkFileSystem
69 #define GTK_FILE_SYSTEM_ERROR (gtk_file_system_error_quark ())
73 GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
74 GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
75 GTK_FILE_SYSTEM_ERROR_INVALID_URI,
76 GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
77 GTK_FILE_SYSTEM_ERROR_FAILED,
80 GQuark gtk_file_system_error_quark (void);
82 /* Boxed-type for gtk_file_folder_get_info() results
84 #define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ())
86 GType gtk_file_info_get_type (void);
88 GtkFileInfo *gtk_file_info_new (void);
89 GtkFileInfo *gtk_file_info_copy (GtkFileInfo *info);
90 void gtk_file_info_free (GtkFileInfo *info);
93 G_CONST_RETURN gchar *gtk_file_info_get_display_name (const GtkFileInfo *info);
94 G_CONST_RETURN gchar *gtk_file_info_get_display_key (const GtkFileInfo *info);
95 void gtk_file_info_set_display_name (GtkFileInfo *info,
96 const gchar *display_name);
97 gboolean gtk_file_info_get_is_folder (const GtkFileInfo *info);
98 void gtk_file_info_set_is_folder (GtkFileInfo *info,
100 gboolean gtk_file_info_get_is_hidden (const GtkFileInfo *info);
101 void gtk_file_info_set_is_hidden (GtkFileInfo *info,
103 G_CONST_RETURN gchar *gtk_file_info_get_mime_type (const GtkFileInfo *info);
104 void gtk_file_info_set_mime_type (GtkFileInfo *info,
105 const gchar *mime_type);
106 GtkFileTime gtk_file_info_get_modification_time (const GtkFileInfo *info);
107 void gtk_file_info_set_modification_time (GtkFileInfo *info,
108 GtkFileTime modification_time);
109 gint64 gtk_file_info_get_size (const GtkFileInfo *info);
110 void gtk_file_info_set_size (GtkFileInfo *info,
112 void gtk_file_info_set_icon_type (GtkFileInfo *info,
113 GtkFileIconType icon_type);
114 GtkFileIconType gtk_file_info_get_icon_type (const GtkFileInfo *info);
115 GdkPixbuf * gtk_file_info_render_icon (const GtkFileInfo *info,
119 /* The base GtkFileSystem interface
121 #define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ())
122 #define GTK_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
123 #define GTK_IS_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
124 #define GTK_FILE_SYSTEM_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
126 struct _GtkFileSystemIface
128 GTypeInterface base_iface;
132 GSList * (*list_roots) (GtkFileSystem *file_system);
134 GtkFileInfo * (*get_root_info) (GtkFileSystem *file_system,
135 const GtkFilePath *path,
136 GtkFileInfoType types,
139 GtkFileFolder * (*get_folder) (GtkFileSystem *file_system,
140 const GtkFilePath *path,
141 GtkFileInfoType types,
143 gboolean (*create_folder) (GtkFileSystem *file_system,
144 const GtkFilePath *path,
147 gboolean (*supports_shortcuts) (GtkFileSystem *file_system);
148 GSList * (*list_shortcuts) (GtkFileSystem *file_system,
150 gboolean (*set_shortcuts) (GtkFileSystem *file_system,
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 gboolean (*get_supports_bookmarks) (GtkFileSystem *file_system);
182 void (*set_bookmarks) (GtkFileSystem *file_system,
185 GSList * (*list_bookmarks) (GtkFileSystem *file_system);
189 void (*roots_changed) (GtkFileSystem *file_system);
190 void (*bookmarks_changed) (GtkFileSystem *file_system);
193 GType gtk_file_system_get_type (void);
195 GSList * gtk_file_system_list_roots (GtkFileSystem *file_system);
196 GtkFileInfo * gtk_file_system_get_root_info (GtkFileSystem *file_system,
197 const GtkFilePath *path,
198 GtkFileInfoType types,
201 gboolean gtk_file_system_supports_shortcuts (GtkFileSystem *file_system);
202 GSList * gtk_file_system_list_shortcuts (GtkFileSystem *file_system,
204 gboolean gtk_file_system_set_shortcuts (GtkFileSystem *file_system,
208 gboolean gtk_file_system_get_parent (GtkFileSystem *file_system,
209 const GtkFilePath *path,
210 GtkFilePath **parent,
212 GtkFileFolder *gtk_file_system_get_folder (GtkFileSystem *file_system,
213 const GtkFilePath *path,
214 GtkFileInfoType types,
216 gboolean gtk_file_system_create_folder (GtkFileSystem *file_system,
217 const GtkFilePath *path,
219 GtkFilePath * gtk_file_system_make_path (GtkFileSystem *file_system,
220 const GtkFilePath *base_path,
221 const gchar *display_name,
223 gboolean gtk_file_system_parse (GtkFileSystem *file_system,
224 const GtkFilePath *base_path,
226 GtkFilePath **folder,
230 gchar * gtk_file_system_path_to_uri (GtkFileSystem *file_system,
231 const GtkFilePath *path);
232 gchar * gtk_file_system_path_to_filename (GtkFileSystem *file_system,
233 const GtkFilePath *path);
234 GtkFilePath *gtk_file_system_uri_to_path (GtkFileSystem *file_system,
236 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
237 const gchar *filename);
239 gboolean gtk_file_system_get_supports_bookmarks (GtkFileSystem *file_system);
241 void gtk_file_system_set_bookmarks (GtkFileSystem *file_system,
244 GSList *gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
248 * Detailed information about a particular folder
250 #define GTK_TYPE_FILE_FOLDER (gtk_file_folder_get_type ())
251 #define GTK_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER, GtkFileFolder))
252 #define GTK_IS_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER))
253 #define GTK_FILE_FOLDER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_FOLDER, GtkFileFolderIface))
255 struct _GtkFileFolderIface
257 GTypeInterface base_iface;
261 GtkFileInfo * (*get_info) (GtkFileFolder *folder,
262 const GtkFilePath *path,
264 gboolean (*list_children) (GtkFileFolder *folder,
268 /* ??? refresh() ??? */
272 void (*deleted) (GtkFileFolder *monitor);
273 void (*files_added) (GtkFileFolder *monitor,
275 void (*files_changed) (GtkFileFolder *monitor,
277 void (*files_removed) (GtkFileFolder *monitor,
281 GType gtk_file_folder_get_type (void);
282 gboolean gtk_file_folder_list_children (GtkFileFolder *folder,
285 GtkFileInfo *gtk_file_folder_get_info (GtkFileFolder *folder,
286 const GtkFilePath *path,
290 #define gtk_file_path_new_dup(str) \
291 ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
292 #define gtk_file_path_new_steal(str) \
293 ({ gchar *__s = (str); (GtkFilePath *)__s; })
294 #define gtk_file_path_get_string(path) \
295 ({ const GtkFilePath *__p = (path); (const gchar *)__p; })
296 #define gtk_file_path_free(path) \
297 ({ GtkFilePath *__p = (path); g_free (__p); })
299 #define gtk_file_path_new_dup(str) ((GtkFilePath *)g_strdup(str))
300 #define gtk_file_path_new_steal(str) ((GtkFilePath *)(str))
301 #define gtk_file_path_get_string(path) ((const gchar *)(str))
302 #define gtk_file_path_free(path) g_free (path)
305 #define gtk_file_path_copy(path) gtk_file_path_new_dup (gtk_file_path_get_string(path))
306 #define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
307 gtk_file_path_get_string (path2))
309 GSList *gtk_file_paths_sort (GSList *paths);
310 GSList *gtk_file_paths_copy (GSList *paths);
311 void gtk_file_paths_free (GSList *paths);
315 #endif /* __GTK_FILE_SYSTEM_H__ */