]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilesystem.h
Revert the patch to #137520, as 2.4.1 is for conservative bug fixes only.
[~andy/gtk] / gtk / gtkfilesystem.h
index 055b9d9bf5a775ae7c77c5b1155aaa2902ea6fad..1124fc9f52f1587c761f4cdab701f03962624c2a 100644 (file)
 #ifndef __GTK_FILE_SYSTEM_H__
 #define __GTK_FILE_SYSTEM_H__
 
+/* This is a "semi-private" header; it is meant only for
+ * alternate GtkFileChooser backend modules; no stability guarantees 
+ * are made at this point
+ */
+#ifndef GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED
+#error "GtkFileSystem is not supported API for general use"
+#endif
+
 #include <glib-object.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gtk/gtkwidget.h>     /* For icon handling */
 
 G_BEGIN_DECLS
 
 typedef gint64 GtkFileTime;
 
-typedef struct _GtkFileFolder      GtkFileFolder;
-typedef struct _GtkFileFolderIface GtkFileFolderIface;
-typedef struct _GtkFileInfo        GtkFileInfo;
-typedef struct _GtkFileSystem      GtkFileSystem;
-typedef struct _GtkFileSystemIface GtkFileSystemIface;
+typedef struct _GtkFileFolder       GtkFileFolder;
+typedef struct _GtkFileFolderIface  GtkFileFolderIface;
+typedef struct _GtkFileInfo         GtkFileInfo;
+typedef struct _GtkFileSystem       GtkFileSystem;
+typedef struct _GtkFileSystemIface  GtkFileSystemIface;
+typedef struct _GtkFileSystemVolume GtkFileSystemVolume;
 
 typedef struct _GtkFilePath        GtkFilePath;
 
@@ -46,8 +55,7 @@ typedef enum {
   GTK_FILE_INFO_MIME_TYPE         = 1 << 3,
   GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
   GTK_FILE_INFO_SIZE              = 1 << 5,
-  GTK_FILE_INFO_ICON              = 1 << 6,
-  GTK_FILE_INFO_ALL               = (1 << 7) - 1
+  GTK_FILE_INFO_ALL               = (1 << 6) - 1
 } GtkFileInfoType;
 
 /* GError enumeration for GtkFileSystem
@@ -57,11 +65,12 @@ typedef enum {
 
 typedef enum
 {
-  GTK_FILE_SYSTEM_ERROR_NONEXISTANT,
+  GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
   GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
   GTK_FILE_SYSTEM_ERROR_INVALID_URI,
   GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
   GTK_FILE_SYSTEM_ERROR_FAILED,
+  GTK_FILE_SYSTEM_ERROR_ALREADY_EXISTS
 } GtkFileSystemError;
 
 GQuark     gtk_file_system_error_quark      (void);
@@ -96,9 +105,6 @@ void                  gtk_file_info_set_modification_time (GtkFileInfo       *in
 gint64                gtk_file_info_get_size              (const GtkFileInfo *info);
 void                  gtk_file_info_set_size              (GtkFileInfo       *info,
                                                           gint64             size);
-GdkPixbuf *           gtk_file_info_get_icon              (const GtkFileInfo *info);
-void                  gtk_file_info_set_icon              (GtkFileInfo       *info,
-                                                          GdkPixbuf         *icon);
 
 /* The base GtkFileSystem interface
  */
@@ -113,13 +119,10 @@ struct _GtkFileSystemIface
 
   /* Methods
    */
-  GSList *           (*list_roots)     (GtkFileSystem     *file_system);
+  GSList *              (*list_volumes)        (GtkFileSystem     *file_system);
+  GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem     *file_system,
+                                               const GtkFilePath *path);
 
-  GtkFileInfo *      (*get_root_info)  (GtkFileSystem     *file_system,
-                                       const GtkFilePath *path,
-                                       GtkFileInfoType    types,
-                                       GError           **error);
-  
   GtkFileFolder *    (*get_folder)     (GtkFileSystem     *file_system,
                                        const GtkFilePath *path,
                                        GtkFileInfoType    types,
@@ -128,6 +131,26 @@ struct _GtkFileSystemIface
                                        const GtkFilePath *path,
                                        GError           **error);
 
+  /* Volumes
+   */
+
+  void          (*volume_free)             (GtkFileSystem        *file_system,
+                                           GtkFileSystemVolume  *volume);
+  GtkFilePath * (*volume_get_base_path)    (GtkFileSystem        *file_system,
+                                           GtkFileSystemVolume  *volume);
+  gboolean      (*volume_get_is_mounted)   (GtkFileSystem        *file_system,
+                                           GtkFileSystemVolume  *volume);
+  gboolean      (*volume_mount)            (GtkFileSystem        *file_system, 
+                                           GtkFileSystemVolume  *volume,
+                                           GError              **error);
+  char *        (*volume_get_display_name) (GtkFileSystem        *file_system, 
+                                           GtkFileSystemVolume  *volume);
+  GdkPixbuf *   (*volume_render_icon)      (GtkFileSystem        *file_system,
+                                           GtkFileSystemVolume  *volume,
+                                           GtkWidget            *widget,
+                                           gint                  pixel_size,
+                                           GError              **error);
+
   /* Path Manipulation
    */
   gboolean      (*get_parent)      (GtkFileSystem      *file_system,
@@ -137,7 +160,7 @@ struct _GtkFileSystemIface
   GtkFilePath * (*make_path)        (GtkFileSystem     *file_system,
                                     const GtkFilePath *base_path,
                                     const gchar       *display_name,
-                                    GError           **error);                                 
+                                    GError           **error);
   gboolean      (*parse)            (GtkFileSystem     *file_system,
                                     const GtkFilePath *base_path,
                                     const gchar       *str,
@@ -153,19 +176,55 @@ struct _GtkFileSystemIface
   GtkFilePath *(*filename_to_path) (GtkFileSystem      *file_system,
                                    const gchar        *path);
 
+  /* Icons */
+
+  GdkPixbuf *  (*render_icon)    (GtkFileSystem     *file_system,
+                                 const GtkFilePath *path,
+                                 GtkWidget         *widget,
+                                 gint               pixel_size,
+                                 GError           **error);
+
+  /* Bookmarks */
+
+  gboolean       (*insert_bookmark)        (GtkFileSystem     *file_system,
+                                           const GtkFilePath *path,
+                                           gint               position,
+                                           GError           **error);
+  gboolean       (*remove_bookmark)        (GtkFileSystem     *file_system,
+                                           const GtkFilePath *path,
+                                           GError           **error);
+  GSList *       (*list_bookmarks)         (GtkFileSystem *file_system);
+
   /* Signals
    */
-  void (*roots_changed) (GtkFileSystem *file_system);
+  void (*volumes_changed)   (GtkFileSystem *file_system);
+  void (*bookmarks_changed) (GtkFileSystem *file_system);
 };
 
 GType             gtk_file_system_get_type       (void);
 
-GSList *          gtk_file_system_list_roots     (GtkFileSystem     *file_system);
-GtkFileInfo *     gtk_file_system_get_root_info  (GtkFileSystem     *file_system,
-                                                 const GtkFilePath *path,
-                                                 GtkFileInfoType    types,
-                                                 GError           **error);
-  
+GSList *          gtk_file_system_list_volumes   (GtkFileSystem     *file_system);
+
+GtkFileSystemVolume *gtk_file_system_get_volume_for_path (GtkFileSystem     *file_system,
+                                                         const GtkFilePath *path);
+
+void              gtk_file_system_volume_free             (GtkFileSystem        *file_system,
+                                                          GtkFileSystemVolume  *volume);
+GtkFilePath *     gtk_file_system_volume_get_base_path    (GtkFileSystem        *file_system,
+                                                          GtkFileSystemVolume  *volume);
+gboolean          gtk_file_system_volume_get_is_mounted   (GtkFileSystem        *file_system,
+                                                          GtkFileSystemVolume  *volume);
+gboolean          gtk_file_system_volume_mount            (GtkFileSystem        *file_system, 
+                                                          GtkFileSystemVolume  *volume,
+                                                          GError              **error);
+char *            gtk_file_system_volume_get_display_name (GtkFileSystem        *file_system, 
+                                                          GtkFileSystemVolume  *volume);
+GdkPixbuf *       gtk_file_system_volume_render_icon      (GtkFileSystem        *file_system,
+                                                          GtkFileSystemVolume  *volume,
+                                                          GtkWidget            *widget,
+                                                          gint                  pixel_size,
+                                                          GError              **error);
+
 gboolean          gtk_file_system_get_parent     (GtkFileSystem     *file_system,
                                                  const GtkFilePath *path,
                                                  GtkFilePath      **parent,
@@ -197,6 +256,25 @@ GtkFilePath *gtk_file_system_uri_to_path      (GtkFileSystem     *file_system,
 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem     *file_system,
                                               const gchar       *filename);
 
+gboolean     gtk_file_system_path_is_local    (GtkFileSystem     *filesystem,
+                                              const GtkFilePath *path);
+
+GdkPixbuf   *gtk_file_system_render_icon   (GtkFileSystem      *file_system,
+                                           const GtkFilePath  *path,
+                                           GtkWidget          *widget,
+                                           gint                pixel_size,
+                                           GError            **error);
+
+gboolean gtk_file_system_insert_bookmark (GtkFileSystem     *file_system,
+                                         const GtkFilePath *path,
+                                         gint               position,
+                                         GError           **error);
+gboolean gtk_file_system_remove_bookmark (GtkFileSystem     *file_system,
+                                         const GtkFilePath *path,
+                                         GError           **error);
+GSList  *gtk_file_system_list_bookmarks  (GtkFileSystem     *file_system);
+
+
 /*
  * Detailed information about a particular folder
  */
@@ -239,6 +317,13 @@ GtkFileInfo *gtk_file_folder_get_info      (GtkFileFolder      *folder,
                                            const GtkFilePath  *path,
                                            GError            **error);
 
+
+/* GtkFilePath */
+#define GTK_TYPE_FILE_PATH             (gtk_file_path_get_type ())
+#define GTK_FILE_PATH(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_PATH, GtkFilePath))
+#define GTK_IS_FILE_PATH(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_PATH))
+
+GType   gtk_file_path_get_type (void);
 #ifdef __GNUC__
 #define gtk_file_path_new_dup(str) \
  ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
@@ -251,7 +336,7 @@ GtkFileInfo *gtk_file_folder_get_info      (GtkFileFolder      *folder,
 #else /* __GNUC__ */
 #define gtk_file_path_new_dup(str)     ((GtkFilePath *)g_strdup(str))
 #define gtk_file_path_new_steal(str)   ((GtkFilePath *)(str))
-#define gtk_file_path_get_string(path) ((const gchar *)(str))
+#define gtk_file_path_get_string(str) ((const gchar *)(str))
 #define gtk_file_path_free(path)       g_free (path)
 #endif/* __GNUC__ */
 
@@ -260,8 +345,13 @@ GtkFileInfo *gtk_file_folder_get_info      (GtkFileFolder      *folder,
                                                   gtk_file_path_get_string (path2))
 
 GSList *gtk_file_paths_sort (GSList *paths);
+GSList *gtk_file_paths_copy (GSList *paths);
 void    gtk_file_paths_free (GSList *paths);
 
+/* GtkFileSystem modules support */
+
+GtkFileSystem  *_gtk_file_system_create (const char *file_system_name);
+
 G_END_DECLS
 
 #endif /* __GTK_FILE_SYSTEM_H__ */