]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilesystem.h
gtk/gtkfilesystem: Do not use GET_PRIVATE macro all the time
[~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 typedef struct GtkFileSystem          GtkFileSystem;
37 typedef struct GtkFileSystemPriv      GtkFileSystemPriv;
38 typedef struct GtkFileSystemClass     GtkFileSystemClass;
39
40
41 #define GTK_TYPE_FOLDER         (_gtk_folder_get_type ())
42 #define GTK_FOLDER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FOLDER, GtkFolder))
43 #define GTK_FOLDER_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST    ((c), GTK_TYPE_FOLDER, GtkFolderClass))
44 #define GTK_IS_FOLDER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FOLDER))
45 #define GTK_IS_FOLDER_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE    ((c), GTK_TYPE_FOLDER))
46 #define GTK_FOLDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS  ((o), GTK_TYPE_FOLDER, GtkFolderClass))
47
48 typedef struct GtkFolder          GtkFolder;
49 typedef struct GtkFolderPriv      GtkFolderPriv;
50 typedef struct GtkFolderClass     GtkFolderClass;
51
52 typedef struct GtkFileSystemVolume GtkFileSystemVolume; /* opaque struct */
53 typedef struct GtkFileSystemBookmark GtkFileSystemBookmark; /* opaque struct */
54
55
56 struct GtkFileSystem
57 {
58   GObject parent_object;
59
60   GtkFileSystemPriv *priv;
61 };
62
63 struct GtkFileSystemClass
64 {
65   GObjectClass parent_class;
66
67   void (*bookmarks_changed) (GtkFileSystem *file_system);
68   void (*volumes_changed)   (GtkFileSystem *file_system);
69 };
70
71
72 struct GtkFolder
73 {
74   GObject parent_object;
75
76   GtkFolderPriv *priv;
77 };
78
79 struct GtkFolderClass
80 {
81   GObjectClass parent_class;
82
83   void (*files_added)      (GtkFolder *folder,
84                             GList     *paths);
85   void (*files_removed)    (GtkFolder *folder,
86                             GList     *paths);
87   void (*files_changed)    (GtkFolder *folder,
88                             GList     *paths);
89   void (*finished_loading) (GtkFolder *folder);
90   void (*deleted)          (GtkFolder *folder);
91 };
92
93
94 typedef void (* GtkFileSystemGetFolderCallback)    (GCancellable        *cancellable,
95                                                     GtkFolder           *folder,
96                                                     const GError        *error,
97                                                     gpointer             data);
98 typedef void (* GtkFileSystemGetInfoCallback)      (GCancellable        *cancellable,
99                                                     GFileInfo           *file_info,
100                                                     const GError        *error,
101                                                     gpointer             data);
102 typedef void (* GtkFileSystemVolumeMountCallback)  (GCancellable        *cancellable,
103                                                     GtkFileSystemVolume *volume,
104                                                     const GError        *error,
105                                                     gpointer             data);
106
107 /* GtkFileSystem methods */
108 GType           _gtk_file_system_get_type     (void) G_GNUC_CONST;
109
110 GtkFileSystem * _gtk_file_system_new          (void);
111
112 GSList *        _gtk_file_system_list_volumes   (GtkFileSystem *file_system);
113 GSList *        _gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
114
115 gboolean        _gtk_file_system_parse          (GtkFileSystem     *file_system,
116                                                  GFile             *base_file,
117                                                  const gchar       *str,
118                                                  GFile            **folder,
119                                                  gchar            **file_part,
120                                                  GError           **error);
121
122 GCancellable *  _gtk_file_system_get_folder             (GtkFileSystem                     *file_system,
123                                                          GFile                             *file,
124                                                          const gchar                       *attributes,
125                                                          GtkFileSystemGetFolderCallback     callback,
126                                                          gpointer                           data);
127 GCancellable *  _gtk_file_system_get_info               (GtkFileSystem                     *file_system,
128                                                          GFile                             *file,
129                                                          const gchar                       *attributes,
130                                                          GtkFileSystemGetInfoCallback       callback,
131                                                          gpointer                           data);
132 GCancellable *  _gtk_file_system_mount_volume           (GtkFileSystem                     *file_system,
133                                                          GtkFileSystemVolume               *volume,
134                                                          GMountOperation                   *mount_operation,
135                                                          GtkFileSystemVolumeMountCallback   callback,
136                                                          gpointer                           data);
137 GCancellable *  _gtk_file_system_mount_enclosing_volume (GtkFileSystem                     *file_system,
138                                                          GFile                             *file,
139                                                          GMountOperation                   *mount_operation,
140                                                          GtkFileSystemVolumeMountCallback   callback,
141                                                          gpointer                           data);
142
143 gboolean        _gtk_file_system_insert_bookmark    (GtkFileSystem      *file_system,
144                                                      GFile              *file,
145                                                      gint                position,
146                                                      GError            **error);
147 gboolean        _gtk_file_system_remove_bookmark    (GtkFileSystem      *file_system,
148                                                      GFile              *file,
149                                                      GError            **error);
150
151 gchar *         _gtk_file_system_get_bookmark_label (GtkFileSystem *file_system,
152                                                      GFile         *file);
153 void            _gtk_file_system_set_bookmark_label (GtkFileSystem *file_system,
154                                                      GFile         *file,
155                                                      const gchar   *label);
156
157 GtkFileSystemVolume * _gtk_file_system_get_volume_for_file (GtkFileSystem       *file_system,
158                                                             GFile               *file);
159
160 /* GtkFolder functions */
161 GSList *     _gtk_folder_list_children (GtkFolder  *folder);
162 GFileInfo *  _gtk_folder_get_info      (GtkFolder  *folder,
163                                         GFile      *file);
164
165 gboolean     _gtk_folder_is_finished_loading (GtkFolder *folder);
166
167
168 /* GtkFileSystemVolume methods */
169 gchar *               _gtk_file_system_volume_get_display_name (GtkFileSystemVolume *volume);
170 gboolean              _gtk_file_system_volume_is_mounted       (GtkFileSystemVolume *volume);
171 GFile *               _gtk_file_system_volume_get_root         (GtkFileSystemVolume *volume);
172 GdkPixbuf *           _gtk_file_system_volume_render_icon      (GtkFileSystemVolume  *volume,
173                                                                 GtkWidget            *widget,
174                                                                 gint                  icon_size,
175                                                                 GError              **error);
176
177 GtkFileSystemVolume  *_gtk_file_system_volume_ref              (GtkFileSystemVolume *volume);
178 void                  _gtk_file_system_volume_unref            (GtkFileSystemVolume *volume);
179
180 /* GtkFileSystemBookmark methods */
181 void                   _gtk_file_system_bookmark_free          (GtkFileSystemBookmark *bookmark);
182
183 /* GFileInfo helper functions */
184 GdkPixbuf *     _gtk_file_info_render_icon (GFileInfo *info,
185                                             GtkWidget *widget,
186                                             gint       icon_size);
187
188 gboolean        _gtk_file_info_consider_as_directory (GFileInfo *info);
189
190 G_END_DECLS
191
192 #endif /* __GTK_FILE_SYSTEM_H__ */