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 <gdk-pixbuf/gdk-pixbuf.h>
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
52 /* GError enumeration for GtkFileSystem
55 #define GTK_FILE_SYSTEM_ERROR (gtk_file_system_error_quark ())
59 GTK_FILE_SYSTEM_ERROR_NONEXISTANT,
60 GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
61 GTK_FILE_SYSTEM_ERROR_INVALID_URI,
62 GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
63 GTK_FILE_SYSTEM_ERROR_FAILED,
66 GQuark gtk_file_system_error_quark (void);
68 /* Boxed-type for gtk_file_folder_get_info() results
70 #define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ())
72 GType gtk_file_info_get_type (void);
74 GtkFileInfo *gtk_file_info_new (void);
75 GtkFileInfo *gtk_file_info_copy (GtkFileInfo *info);
76 void gtk_file_info_free (GtkFileInfo *info);
79 G_CONST_RETURN gchar *gtk_file_info_get_display_name (const GtkFileInfo *info);
80 G_CONST_RETURN gchar *gtk_file_info_get_display_key (const GtkFileInfo *info);
81 void gtk_file_info_set_display_name (GtkFileInfo *info,
82 const gchar *display_name);
83 gboolean gtk_file_info_get_is_folder (const GtkFileInfo *info);
84 void gtk_file_info_set_is_folder (GtkFileInfo *info,
86 gboolean gtk_file_info_get_is_hidden (const GtkFileInfo *info);
87 void gtk_file_info_set_is_hidden (GtkFileInfo *info,
89 G_CONST_RETURN gchar *gtk_file_info_get_mime_type (const GtkFileInfo *info);
90 void gtk_file_info_set_mime_type (GtkFileInfo *info,
91 const gchar *mime_type);
92 GtkFileTime gtk_file_info_get_modification_time (const GtkFileInfo *info);
93 void gtk_file_info_set_modification_time (GtkFileInfo *info,
94 GtkFileTime modification_time);
95 gint64 gtk_file_info_get_size (const GtkFileInfo *info);
96 void gtk_file_info_set_size (GtkFileInfo *info,
98 GdkPixbuf * gtk_file_info_get_icon (const GtkFileInfo *info);
99 void gtk_file_info_set_icon (GtkFileInfo *info,
102 /* The base GtkFileSystem interface
104 #define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ())
105 #define GTK_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
106 #define GTK_IS_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
107 #define GTK_FILE_SYSTEM_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
109 struct _GtkFileSystemIface
111 GTypeInterface base_iface;
115 GSList * (*list_roots) (GtkFileSystem *file_system);
117 GtkFileInfo * (*get_root_info) (GtkFileSystem *file_system,
118 const GtkFilePath *path,
119 GtkFileInfoType types,
122 GtkFileFolder * (*get_folder) (GtkFileSystem *file_system,
123 const GtkFilePath *path,
124 GtkFileInfoType types,
126 gboolean (*create_folder) (GtkFileSystem *file_system,
127 const GtkFilePath *path,
132 gboolean (*get_parent) (GtkFileSystem *file_system,
133 const GtkFilePath *path,
134 GtkFilePath **parent,
136 GtkFilePath * (*make_path) (GtkFileSystem *file_system,
137 const GtkFilePath *base_path,
138 const gchar *display_name,
140 gboolean (*parse) (GtkFileSystem *file_system,
141 const GtkFilePath *base_path,
143 GtkFilePath **folder,
146 gchar * (*path_to_uri) (GtkFileSystem *file_system,
147 const GtkFilePath *path);
148 gchar * (*path_to_filename) (GtkFileSystem *file_system,
149 const GtkFilePath *path);
150 GtkFilePath *(*uri_to_path) (GtkFileSystem *file_system,
152 GtkFilePath *(*filename_to_path) (GtkFileSystem *file_system,
157 void (*roots_changed) (GtkFileSystem *file_system);
160 GType gtk_file_system_get_type (void);
162 GSList * gtk_file_system_list_roots (GtkFileSystem *file_system);
163 GtkFileInfo * gtk_file_system_get_root_info (GtkFileSystem *file_system,
164 const GtkFilePath *path,
165 GtkFileInfoType types,
168 gboolean gtk_file_system_get_parent (GtkFileSystem *file_system,
169 const GtkFilePath *path,
170 GtkFilePath **parent,
172 GtkFileFolder *gtk_file_system_get_folder (GtkFileSystem *file_system,
173 const GtkFilePath *path,
174 GtkFileInfoType types,
176 gboolean gtk_file_system_create_folder (GtkFileSystem *file_system,
177 const GtkFilePath *path,
179 GtkFilePath * gtk_file_system_make_path (GtkFileSystem *file_system,
180 const GtkFilePath *base_path,
181 const gchar *display_name,
183 gboolean gtk_file_system_parse (GtkFileSystem *file_system,
184 const GtkFilePath *base_path,
186 GtkFilePath **folder,
190 gchar * gtk_file_system_path_to_uri (GtkFileSystem *file_system,
191 const GtkFilePath *path);
192 gchar * gtk_file_system_path_to_filename (GtkFileSystem *file_system,
193 const GtkFilePath *path);
194 GtkFilePath *gtk_file_system_uri_to_path (GtkFileSystem *file_system,
196 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
197 const gchar *filename);
200 * Detailed information about a particular folder
202 #define GTK_TYPE_FILE_FOLDER (gtk_file_folder_get_type ())
203 #define GTK_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER, GtkFileFolder))
204 #define GTK_IS_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER))
205 #define GTK_FILE_FOLDER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_FOLDER, GtkFileFolderIface))
207 struct _GtkFileFolderIface
209 GTypeInterface base_iface;
213 GtkFileInfo * (*get_info) (GtkFileFolder *folder,
214 const GtkFilePath *path,
216 gboolean (*list_children) (GtkFileFolder *folder,
220 /* ??? refresh() ??? */
224 void (*deleted) (GtkFileFolder *monitor);
225 void (*files_added) (GtkFileFolder *monitor,
227 void (*files_changed) (GtkFileFolder *monitor,
229 void (*files_removed) (GtkFileFolder *monitor,
233 GType gtk_file_folder_get_type (void);
234 gboolean gtk_file_folder_list_children (GtkFileFolder *folder,
237 GtkFileInfo *gtk_file_folder_get_info (GtkFileFolder *folder,
238 const GtkFilePath *path,
242 #define gtk_file_path_new_dup(str) \
243 ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
244 #define gtk_file_path_new_steal(str) \
245 ({ gchar *__s = (str); (GtkFilePath *)__s; })
246 #define gtk_file_path_get_string(path) \
247 ({ const GtkFilePath *__p = (path); (const gchar *)__p; })
248 #define gtk_file_path_free(path) \
249 ({ GtkFilePath *__p = (path); g_free (__p); })
251 #define gtk_file_path_new_dup(str) ((GtkFilePath *)g_strdup(str))
252 #define gtk_file_path_new_steal(str) ((GtkFilePath *)(str))
253 #define gtk_file_path_get_string(path) ((const gchar *)(str))
254 #define gtk_file_path_free(path) g_free (path)
257 #define gtk_file_path_copy(path) gtk_file_path_new_dup (gtk_file_path_get_string(path))
258 #define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
259 gtk_file_path_get_string (path2))
261 GSList *gtk_file_paths_sort (GSList *paths);
262 void gtk_file_paths_free (GSList *paths);
266 #endif /* __GTK_FILE_SYSTEM_H__ */