]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilesystem.h
When finding a matching non-scalable dir, keep going and look for a closer
[~andy/gtk] / gtk / gtkfilesystem.h
index e3c061870d772b4a27e91e51ea527f6b7c130b00..57c458a028970bb8b9a8f84bf0226b881157ddac 100644 (file)
@@ -36,11 +36,12 @@ 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;
 
@@ -54,27 +55,10 @@ typedef enum {
   GTK_FILE_INFO_MIME_TYPE         = 1 << 3,
   GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
   GTK_FILE_INFO_SIZE              = 1 << 5,
-#if 0
   GTK_FILE_INFO_ICON              = 1 << 6,
-#endif
   GTK_FILE_INFO_ALL               = (1 << 7) - 1
 } GtkFileInfoType;
 
-#if 0
-/* Icon type, supplemented by MIME type
- */
-typedef enum {
-  GTK_FILE_ICON_REGULAR,       /* Use mime type for icon */
-  GTK_FILE_ICON_BLOCK_DEVICE,
-  GTK_FILE_ICON_BROKEN_SYMBOLIC_LINK,
-  GTK_FILE_ICON_CHARACTER_DEVICE,
-  GTK_FILE_ICON_DIRECTORY,
-  GTK_FILE_ICON_EXECUTABLE,
-  GTK_FILE_ICON_FIFO,
-  GTK_FILE_ICON_SOCKET
-} GtkFileIconType;
-#endif
-
 /* GError enumeration for GtkFileSystem
  */
 
@@ -87,6 +71,7 @@ typedef enum
   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);
@@ -95,7 +80,7 @@ GQuark     gtk_file_system_error_quark      (void);
  */
 #define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ())
 
-GType       gtk_file_info_get_type (void);
+GType       gtk_file_info_get_type (void) G_GNUC_CONST; 
 
 GtkFileInfo *gtk_file_info_new  (void);
 GtkFileInfo *gtk_file_info_copy (GtkFileInfo *info);
@@ -121,14 +106,43 @@ 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);
-#if 0
-void                  gtk_file_info_set_icon_type         (GtkFileInfo       *info,
-                                                          GtkFileIconType    icon_type);
-GtkFileIconType       gtk_file_info_get_icon_type         (const GtkFileInfo *info);
-GdkPixbuf *           gtk_file_info_render_icon           (const GtkFileInfo *info,
+
+void                  gtk_file_info_set_icon_name         (GtkFileInfo       *info,
+                                                          const gchar       *con_name);
+G_CONST_RETURN gchar *gtk_file_info_get_icon_name         (const GtkFileInfo *info);
+GdkPixbuf            *gtk_file_info_render_icon           (const GtkFileInfo *info,
                                                           GtkWidget         *widget,
-                                                          gint               pixel_size);
-#endif
+                                                          gint               pixel_size,
+                                                          GError           **error);
+
+/* GtkFileSystemHandle
+ */
+
+#define GTK_TYPE_FILE_SYSTEM_HANDLE            (gtk_file_system_handle_get_type ())
+#define GTK_FILE_SYSTEM_HANDLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandle))
+#define GTK_IS_FILE_SYSTEM_HANDLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE))
+#define GTK_FILE_SYSTEM_HANDLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandleUnixClass))
+#define GTK_IS_FILE_SYSTEM_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_SYSTEM_HANDLE))
+#define GTK_FILE_SYSTEM_HANDLE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandleClass))
+
+typedef struct _GtkFileSystemHandle       GtkFileSystemHandle;
+typedef struct _GtkFileSystemHandleClass  GtkFileSystemHandleClass;
+
+struct _GtkFileSystemHandle
+{
+  GObject parent_instance;
+
+  GtkFileSystem *file_system;
+
+  guint cancelled : 1;
+};
+
+struct _GtkFileSystemHandleClass
+{
+  GObjectClass parent_class;
+};
+
+GType gtk_file_system_handle_get_type (void);
 
 /* The base GtkFileSystem interface
  */
@@ -137,26 +151,73 @@ GdkPixbuf *           gtk_file_info_render_icon           (const GtkFileInfo *in
 #define GTK_IS_FILE_SYSTEM(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
 #define GTK_FILE_SYSTEM_GET_IFACE(inst)  (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
 
+/* Callbacks for the asynchronous GtkFileSystem operations
+ */
+
+typedef void (* GtkFileSystemGetInfoCallback) (GtkFileSystemHandle *handle,
+                                              const GtkFileInfo   *file_info,
+                                              const GError        *error,
+                                              gpointer             data);
+typedef void (* GtkFileSystemGetFolderCallback) (GtkFileSystemHandle *handle,
+                                                GtkFileFolder       *folder,
+                                                const GError        *error,
+                                                gpointer             data);
+typedef void (* GtkFileSystemCreateFolderCallback) (GtkFileSystemHandle *handle,
+                                                   const GtkFilePath   *path,
+                                                   const GError        *error,
+                                                   gpointer             data);
+typedef void (* GtkFileSystemVolumeMountCallback) (GtkFileSystemHandle *handle,
+                                                  GtkFileSystemVolume *volume,
+                                                  const GError        *error,
+                                                  gpointer             data);
+
+/*
+ */
+
 struct _GtkFileSystemIface
 {
   GTypeInterface base_iface;
 
   /* Methods
    */
-  GSList *           (*list_roots)     (GtkFileSystem     *file_system);
-
-  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,
-                                       GError           **error);
-  gboolean           (*create_folder)  (GtkFileSystem     *file_system,
-                                       const GtkFilePath *path,
-                                       GError           **error);
+  GSList *              (*list_volumes)        (GtkFileSystem     *file_system);
+  GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem     *file_system,
+                                               const GtkFilePath *path);
+
+  GtkFileSystemHandle * (*get_folder)  (GtkFileSystem                  *file_system,
+                                       const GtkFilePath              *path,
+                                       GtkFileInfoType                 types,
+                                       GtkFileSystemGetFolderCallback  callback,
+                                       gpointer                        data);
+  GtkFileSystemHandle * (*get_info) (GtkFileSystem                *file_system,
+                                    const GtkFilePath            *path,
+                                    GtkFileInfoType               types,
+                                    GtkFileSystemGetInfoCallback  callback,
+                                    gpointer                      data);
+  GtkFileSystemHandle * (*create_folder)  (GtkFileSystem                     *file_system,
+                                          const GtkFilePath                 *path,
+                                          GtkFileSystemCreateFolderCallback  callback,
+                                          gpointer                           data);
+
+  void               (*cancel_operation) (GtkFileSystemHandle *handle);
+
+  /* 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);
+  GtkFileSystemHandle * (*volume_mount)    (GtkFileSystem                    *file_system,
+                                           GtkFileSystemVolume              *volume,
+                                           GtkFileSystemVolumeMountCallback  callback,
+                                           gpointer                          data);
+  char *        (*volume_get_display_name) (GtkFileSystem        *file_system,
+                                           GtkFileSystemVolume  *volume);
+  gchar *       (*volume_get_icon_name)    (GtkFileSystem        *file_system,
+                                           GtkFileSystemVolume  *volume,
+                                           GError              **error);
 
   /* Path Manipulation
    */
@@ -183,49 +244,78 @@ 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       (*add_bookmark)           (GtkFileSystem     *file_system,
+  /* 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);
+  GSList *       (*list_bookmarks)         (GtkFileSystem     *file_system);
 
-  /* Signals
+  /* 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);
+  /* Bookmark labels 
+   */
+  gchar *        (*get_bookmark_label)     (GtkFileSystem     *file_system,
+                                           const GtkFilePath *path);
+  void           (*set_bookmark_label)     (GtkFileSystem     *file_system,
+                                           const GtkFilePath *path,
+                                           const gchar       *label);
+};
 
-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);
+GType             gtk_file_system_get_type       (void) G_GNUC_CONST;
+
+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);
+GtkFileSystemHandle *gtk_file_system_volume_mount         (GtkFileSystem                    *file_system,
+                                                          GtkFileSystemVolume              *volume,
+                                                          GtkFileSystemVolumeMountCallback  callback,
+                                                          gpointer                          data);
+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);
+gchar *           gtk_file_system_volume_get_icon_name    (GtkFileSystem        *file_system,
+                                                          GtkFileSystemVolume  *volume,
+                                                          GError              **error);
 
 gboolean          gtk_file_system_get_parent     (GtkFileSystem     *file_system,
                                                  const GtkFilePath *path,
                                                  GtkFilePath      **parent,
                                                  GError           **error);
-GtkFileFolder    *gtk_file_system_get_folder     (GtkFileSystem     *file_system,
-                                                 const GtkFilePath *path,
-                                                 GtkFileInfoType    types,
-                                                 GError           **error);
-gboolean          gtk_file_system_create_folder  (GtkFileSystem     *file_system,
-                                                 const GtkFilePath *path,
-                                                 GError           **error);
+GtkFileSystemHandle *gtk_file_system_get_folder  (GtkFileSystem                  *file_system,
+                                                 const GtkFilePath              *path,
+                                                 GtkFileInfoType                 types,
+                                                 GtkFileSystemGetFolderCallback  callback,
+                                                 gpointer                        data);
+GtkFileSystemHandle *gtk_file_system_get_info    (GtkFileSystem                  *file_system,
+                                                 const GtkFilePath              *path,
+                                                 GtkFileInfoType                 types,
+                                                 GtkFileSystemGetInfoCallback    callback,
+                                                 gpointer                        data);
+GtkFileSystemHandle *gtk_file_system_create_folder (GtkFileSystem                     *file_system,
+                                                   const GtkFilePath                 *path,
+                                                   GtkFileSystemCreateFolderCallback  callback,
+                                                   gpointer                           data);
+void              gtk_file_system_cancel_operation (GtkFileSystemHandle *handle);
 GtkFilePath *     gtk_file_system_make_path      (GtkFileSystem     *file_system,
                                                  const GtkFilePath *base_path,
                                                  const gchar       *display_name,
@@ -246,20 +336,23 @@ GtkFilePath *gtk_file_system_uri_to_path      (GtkFileSystem     *file_system,
 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem     *file_system,
                                               const gchar       *filename);
 
-GdkPixbuf   *gtk_file_system_render_icon   (GtkFileSystem      *file_system,
-                                           const GtkFilePath  *path,
-                                           GtkWidget          *widget,
-                                           gint                pixel_size,
-                                           GError            **error);
+gboolean     gtk_file_system_path_is_local    (GtkFileSystem     *filesystem,
+                                              const GtkFilePath *path);
 
-gboolean gtk_file_system_add_bookmark    (GtkFileSystem     *file_system,
+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);
 
+gchar   *gtk_file_system_get_bookmark_label (GtkFileSystem     *file_system,
+                                            const GtkFilePath *path);
+void     gtk_file_system_set_bookmark_label (GtkFileSystem     *file_system,
+                                            const GtkFilePath *path,
+                                            const gchar       *label);
 
 /*
  * Detailed information about a particular folder
@@ -293,9 +386,13 @@ struct _GtkFileFolderIface
                         GSList        *paths);
   void (*files_removed) (GtkFileFolder *monitor,
                         GSList        *paths);
+
+  /* Method / signal */
+  gboolean (*is_finished_loading) (GtkFileFolder *folder);
+  void     (*finished_loading)    (GtkFileFolder *folder);
 };
 
-GType        gtk_file_folder_get_type      (void);
+GType        gtk_file_folder_get_type      (void) G_GNUC_CONST;
 gboolean     gtk_file_folder_list_children (GtkFileFolder      *folder,
                                            GSList            **children,
                                            GError            **error);
@@ -303,6 +400,13 @@ GtkFileInfo *gtk_file_folder_get_info      (GtkFileFolder      *folder,
                                            const GtkFilePath  *path,
                                            GError            **error);
 
+gboolean     gtk_file_folder_is_finished_loading (GtkFileFolder *folder);
+
+
+/* GtkFilePath */
+#define GTK_TYPE_FILE_PATH             (gtk_file_path_get_type ())
+
+GType   gtk_file_path_get_type (void) G_GNUC_CONST;
 #ifdef __GNUC__
 #define gtk_file_path_new_dup(str) \
  ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
@@ -320,13 +424,25 @@ GtkFileInfo *gtk_file_folder_get_info      (GtkFileFolder      *folder,
 #endif/* __GNUC__ */
 
 #define gtk_file_path_copy(path)       gtk_file_path_new_dup (gtk_file_path_get_string(path))
+#ifdef G_OS_WIN32
+int _gtk_file_system_win32_path_compare (const gchar *path1,
+                                        const gchar *path2);
+#define gtk_file_path_compare(path1,path2) \
+  _gtk_file_system_win32_path_compare (gtk_file_path_get_string (path1), \
+                                      gtk_file_path_get_string (path2))
+#else
 #define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
                                                   gtk_file_path_get_string (path2))
+#endif
 
 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__ */