]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilesystem.h
Fix file chooser refcounting issues
[~andy/gtk] / gtk / gtkfilesystem.h
1 /* GTK - The GIMP Toolkit
2  * gtkfilesystem.h: Filesystem abstraction functions.
3  * Copyright (C) 2003, Red Hat, Inc.
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #ifndef __GTK_FILE_SYSTEM_H__
22 #define __GTK_FILE_SYSTEM_H__
23
24 #include <gio/gio.h>
25 #include <gtk/gtkwidget.h>      /* For icon handling */
26
27 G_BEGIN_DECLS
28
29 #define GTK_TYPE_FILE_SYSTEM         (_gtk_file_system_get_type ())
30 #define GTK_FILE_SYSTEM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
31 #define GTK_FILE_SYSTEM_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST    ((c), GTK_TYPE_FILE_SYSTEM, GtkFileSystemClass))
32 #define GTK_IS_FILE_SYSTEM(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FILE_SYSTEM))
33 #define GTK_IS_FILE_SYSTEM_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE    ((c), GTK_TYPE_FILE_SYSTEM))
34 #define GTK_FILE_SYSTEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS  ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystemClass))
35
36 #define GTK_TYPE_FOLDER         (_gtk_folder_get_type ())
37 #define GTK_FOLDER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FOLDER, GtkFolder))
38 #define GTK_FOLDER_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST    ((c), GTK_TYPE_FOLDER, GtkFolderClass))
39 #define GTK_IS_FOLDER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FOLDER))
40 #define GTK_IS_FOLDER_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE    ((c), GTK_TYPE_FOLDER))
41 #define GTK_FOLDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS  ((o), GTK_TYPE_FOLDER, GtkFolderClass))
42
43 typedef struct GtkFileSystemClass GtkFileSystemClass;
44 typedef struct GtkFileSystem GtkFileSystem;
45 typedef struct GtkFolderClass GtkFolderClass;
46 typedef struct GtkFolder GtkFolder;
47 typedef struct GtkFileSystemVolume GtkFileSystemVolume; /* opaque struct */
48 typedef struct GtkFileSystemBookmark GtkFileSystemBookmark; /* opaque struct */
49
50 struct GtkFileSystemClass
51 {
52   GObjectClass parent_class;
53
54   void (*bookmarks_changed) (GtkFileSystem *file_system);
55   void (*volumes_changed)   (GtkFileSystem *file_system);
56 };
57
58 struct GtkFileSystem
59 {
60   GObject parent_object;
61 };
62
63 struct GtkFolderClass
64 {
65   GObjectClass parent_class;
66
67   void (*files_added)      (GtkFolder *folder,
68                             GList     *paths);
69   void (*files_removed)    (GtkFolder *folder,
70                             GList     *paths);
71   void (*files_changed)    (GtkFolder *folder,
72                             GList     *paths);
73   void (*finished_loading) (GtkFolder *folder);
74   void (*deleted)          (GtkFolder *folder);
75 };
76
77 struct GtkFolder
78 {
79   GObject parent_object;
80 };
81
82 typedef void (* GtkFileSystemGetFolderCallback)    (GCancellable        *cancellable,
83                                                     GtkFolder           *folder,
84                                                     const GError        *error,
85                                                     gpointer             data);
86 typedef void (* GtkFileSystemGetInfoCallback)      (GCancellable        *cancellable,
87                                                     GFileInfo           *file_info,
88                                                     const GError        *error,
89                                                     gpointer             data);
90 typedef void (* GtkFileSystemVolumeMountCallback)  (GCancellable        *cancellable,
91                                                     GtkFileSystemVolume *volume,
92                                                     const GError        *error,
93                                                     gpointer             data);
94
95 /* GtkFileSystem methods */
96 GType           _gtk_file_system_get_type     (void) G_GNUC_CONST;
97
98 GtkFileSystem * _gtk_file_system_new          (void);
99
100 GSList *        _gtk_file_system_list_volumes   (GtkFileSystem *file_system);
101 GSList *        _gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
102
103 gboolean        _gtk_file_system_parse          (GtkFileSystem     *file_system,
104                                                  GFile             *base_file,
105                                                  const gchar       *str,
106                                                  GFile            **folder,
107                                                  gchar            **file_part,
108                                                  GError           **error);
109
110 GCancellable *  _gtk_file_system_get_folder             (GtkFileSystem                     *file_system,
111                                                          GFile                             *file,
112                                                          const gchar                       *attributes,
113                                                          GtkFileSystemGetFolderCallback     callback,
114                                                          gpointer                           data);
115 GCancellable *  _gtk_file_system_get_info               (GtkFileSystem                     *file_system,
116                                                          GFile                             *file,
117                                                          const gchar                       *attributes,
118                                                          GtkFileSystemGetInfoCallback       callback,
119                                                          gpointer                           data);
120 GCancellable *  _gtk_file_system_mount_volume           (GtkFileSystem                     *file_system,
121                                                          GtkFileSystemVolume               *volume,
122                                                          GMountOperation                   *mount_operation,
123                                                          GtkFileSystemVolumeMountCallback   callback,
124                                                          gpointer                           data);
125 GCancellable *  _gtk_file_system_mount_enclosing_volume (GtkFileSystem                     *file_system,
126                                                          GFile                             *file,
127                                                          GMountOperation                   *mount_operation,
128                                                          GtkFileSystemVolumeMountCallback   callback,
129                                                          gpointer                           data);
130
131 gboolean        _gtk_file_system_insert_bookmark    (GtkFileSystem      *file_system,
132                                                      GFile              *file,
133                                                      gint                position,
134                                                      GError            **error);
135 gboolean        _gtk_file_system_remove_bookmark    (GtkFileSystem      *file_system,
136                                                      GFile              *file,
137                                                      GError            **error);
138
139 gchar *         _gtk_file_system_get_bookmark_label (GtkFileSystem *file_system,
140                                                      GFile         *file);
141 void            _gtk_file_system_set_bookmark_label (GtkFileSystem *file_system,
142                                                      GFile         *file,
143                                                      const gchar   *label);
144
145 GtkFileSystemVolume * _gtk_file_system_get_volume_for_file (GtkFileSystem       *file_system,
146                                                             GFile               *file);
147
148 /* GtkFolder functions */
149 GSList *     _gtk_folder_list_children (GtkFolder  *folder);
150 GFileInfo *  _gtk_folder_get_info      (GtkFolder  *folder,
151                                         GFile      *file);
152
153 gboolean     _gtk_folder_is_finished_loading (GtkFolder *folder);
154
155
156 /* GtkFileSystemVolume methods */
157 gchar *               _gtk_file_system_volume_get_display_name (GtkFileSystemVolume *volume);
158 gboolean              _gtk_file_system_volume_is_mounted       (GtkFileSystemVolume *volume);
159 GFile *               _gtk_file_system_volume_get_root         (GtkFileSystemVolume *volume);
160 GdkPixbuf *           _gtk_file_system_volume_render_icon      (GtkFileSystemVolume  *volume,
161                                                                 GtkWidget            *widget,
162                                                                 gint                  icon_size,
163                                                                 GError              **error);
164
165 GtkFileSystemVolume  *_gtk_file_system_volume_ref              (GtkFileSystemVolume *volume);
166 void                  _gtk_file_system_volume_unref            (GtkFileSystemVolume *volume);
167
168 /* GtkFileSystemBookmark methods */
169 void                   _gtk_file_system_bookmark_free          (GtkFileSystemBookmark *bookmark);
170
171 /* GFileInfo helper functions */
172 GdkPixbuf *     _gtk_file_info_render_icon (GFileInfo *info,
173                                             GtkWidget *widget,
174                                             gint       icon_size);
175
176 gboolean        _gtk_file_info_consider_as_directory (GFileInfo *info);
177
178 G_END_DECLS
179
180 #endif /* __GTK_FILE_SYSTEM_H__ */