]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilesystem.c
Revert the patch to #137520, as 2.4.1 is for conservative bug fixes only.
[~andy/gtk] / gtk / gtkfilesystem.c
index dff2aeaeeb74ad613e423f9631e88f576f0054bc..4f176f6fe239125c7c0d0e2ba7eec0917b3a6bb8 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include <gtk/gtkicontheme.h>
-
+#include <config.h>
+#include <gmodule.h>
 #include "gtkfilesystem.h"
+#include "gtkicontheme.h"
+#include "gtkmain.h"
 
 #include <string.h>
 
@@ -31,7 +33,6 @@ struct _GtkFileInfo
   gchar *display_name;
   gchar *display_key;
   gchar *mime_type;
-  GtkFileIconType icon_type : 4;
   guint is_folder : 1;
   guint is_hidden : 1;
 };
@@ -99,6 +100,10 @@ gtk_file_info_free (GtkFileInfo *info)
     g_free (info->display_name);
   if (info->mime_type)
     g_free (info->mime_type);
+  if (info->display_key)
+    g_free (info->display_key);
+
+  g_free (info);
 }
 
 G_CONST_RETURN gchar *
@@ -141,6 +146,9 @@ gtk_file_info_set_display_name (GtkFileInfo *info,
 {
   g_return_if_fail (info != NULL);
 
+  if (display_name == info->display_name)
+    return;
+
   if (info->display_name)
     g_free (info->display_name);
   if (info->display_key)
@@ -241,167 +249,6 @@ gtk_file_info_set_size (GtkFileInfo *info,
   info->size = size;
 }
 
-void
-gtk_file_info_set_icon_type  (GtkFileInfo      *info,
-                             GtkFileIconType   icon_type)
-{
-  g_return_if_fail (info != NULL);
-
-  info->icon_type = icon_type;
-}
-
-GtkFileIconType
-gtk_file_info_get_icon_type (const GtkFileInfo *info)
-{
-  g_return_val_if_fail (info != NULL, GTK_FILE_ICON_REGULAR);
-
-  return info->icon_type;
-}
-
-typedef struct _IconCacheElement IconCacheElement;
-
-struct _IconCacheElement
-{
-  gint size;
-  GdkPixbuf *pixbuf;
-};
-
-static void
-icon_cache_element_free (IconCacheElement *element)
-{
-  if (element->pixbuf)
-    g_object_unref (element->pixbuf);
-  g_free (element);
-}
-
-static void
-icon_theme_changed (GtkIconTheme *icon_theme)
-{
-  GHashTable *cache;
-  
-  /* Difference from the initial creation is that we don't
-   * reconnect the signal
-   */
-  cache = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                (GDestroyNotify)g_free,
-                                (GDestroyNotify)icon_cache_element_free);
-  g_object_set_data_full (G_OBJECT (icon_theme), "gtk-file-icon-cache",
-                         cache, (GDestroyNotify)g_hash_table_destroy);
-}
-
-static GdkPixbuf *
-get_cached_icon (GtkWidget   *widget,
-                const gchar *name,
-                gint         pixel_size)
-{
-  GtkIconTheme *icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
-  GHashTable *cache = g_object_get_data (G_OBJECT (icon_theme), "gtk-file-icon-cache");
-  IconCacheElement *element;
-  
-  if (!cache)
-    {
-      cache = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                    (GDestroyNotify)g_free,
-                                    (GDestroyNotify)icon_cache_element_free);
-      
-      g_object_set_data_full (G_OBJECT (icon_theme), "gtk-file-icon-cache",
-                             cache, (GDestroyNotify)g_hash_table_destroy);
-      g_signal_connect (icon_theme, "changed",
-                       G_CALLBACK (icon_theme_changed), NULL);
-    }
-
-  element = g_hash_table_lookup (cache, name);
-  if (!element)
-    {
-      element = g_new0 (IconCacheElement, 1);
-      g_hash_table_insert (cache, g_strdup (name), element);
-    }
-
-  if (element->size != pixel_size)
-    {
-      if (element->pixbuf)
-       g_object_unref (element->pixbuf);
-      element->size = pixel_size;
-      element->pixbuf = gtk_icon_theme_load_icon (icon_theme, name,
-                                                 pixel_size, 0, NULL);
-    }
-
-  return element->pixbuf ? g_object_ref (element->pixbuf) : NULL;
-}
-                
-
-GdkPixbuf *
-gtk_file_info_render_icon (const GtkFileInfo *info,
-                          GtkWidget         *widget,
-                          gint               pixel_size)
-{
-  const gchar *separator;
-  GdkPixbuf *pixbuf;
-  GString *icon_name;
-
-  g_return_val_if_fail (info != NULL, NULL);
-  g_return_val_if_fail (widget != NULL, NULL);
-  g_return_val_if_fail (pixel_size > 0, NULL);
-
-  if (info->icon_type != GTK_FILE_ICON_REGULAR)
-    {
-      const char *name = NULL; /* Quiet gcc */
-      
-      switch (info->icon_type)
-       {
-       case GTK_FILE_ICON_BLOCK_DEVICE:
-          name ="gnome-fs-blockdev";
-         break;
-       case GTK_FILE_ICON_BROKEN_SYMBOLIC_LINK:
-         name = "gnome-fs-symlink";
-         break;
-       case GTK_FILE_ICON_CHARACTER_DEVICE:
-         name = "gnome-fs-chardev";
-         break;
-       case GTK_FILE_ICON_DIRECTORY:
-         name = "gnome-fs-directory";
-         break;
-       case GTK_FILE_ICON_EXECUTABLE:
-         name ="gnome-fs-executable";
-         break;
-       case GTK_FILE_ICON_FIFO:
-         name = "gnome-fs-fifo";
-         break;
-       case GTK_FILE_ICON_SOCKET:
-         name = "gnome-fs-socket";
-         break;
-       case GTK_FILE_ICON_REGULAR:
-         g_assert_not_reached ();
-       }
-
-      return get_cached_icon (widget, name, pixel_size);
-    }
-  
-  if (!info->mime_type)
-    return NULL;
-
-  separator = strchr (info->mime_type, '/');
-  if (!separator)
-    return NULL;
-
-  icon_name = g_string_new ("gnome-mime-");
-  g_string_append_len (icon_name, info->mime_type, separator - info->mime_type);
-  g_string_append_c (icon_name, '-');
-  g_string_append (icon_name, separator + 1);
-  pixbuf = get_cached_icon (widget, icon_name->str, pixel_size);
-  g_string_free (icon_name, TRUE);
-  if (pixbuf)
-    return pixbuf;
-
-  icon_name = g_string_new ("gnome-mime-");
-  g_string_append_len (icon_name, info->mime_type, separator - info->mime_type);
-  pixbuf = get_cached_icon (widget, icon_name->str, pixel_size);
-  g_string_free (icon_name, TRUE);
-  if (pixbuf)
-    return pixbuf;
-
-  return get_cached_icon (widget, "gnome-fs-regular", pixel_size);
-}
 
 /*****************************************
  *             GtkFileSystem             *
@@ -439,10 +286,17 @@ gtk_file_system_base_init (gpointer g_class)
     {
       GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
 
-      g_signal_new ("roots-changed",
+      g_signal_new ("volumes-changed",
+                   iface_type,
+                   G_SIGNAL_RUN_LAST,
+                   G_STRUCT_OFFSET (GtkFileSystemIface, volumes_changed),
+                   NULL, NULL,
+                   g_cclosure_marshal_VOID__VOID,
+                   G_TYPE_NONE, 0);
+      g_signal_new ("bookmarks-changed",
                    iface_type,
                    G_SIGNAL_RUN_LAST,
-                   G_STRUCT_OFFSET (GtkFileSystemIface, roots_changed),
+                   G_STRUCT_OFFSET (GtkFileSystemIface, bookmarks_changed),
                    NULL, NULL,
                    g_cclosure_marshal_VOID__VOID,
                    G_TYPE_NONE, 0);
@@ -452,24 +306,11 @@ gtk_file_system_base_init (gpointer g_class)
 }
 
 GSList *
-gtk_file_system_list_roots (GtkFileSystem  *file_system)
-{
-  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
-
-  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_roots (file_system);
-}
-
-GtkFileInfo *
-gtk_file_system_get_root_info  (GtkFileSystem     *file_system,
-                               const GtkFilePath *path,
-                               GtkFileInfoType    types,
-                               GError           **error)
+gtk_file_system_list_volumes (GtkFileSystem  *file_system)
 {
   g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
-  g_return_val_if_fail (path != NULL, NULL);
-  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_root_info (file_system, path, types, error);
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_volumes (file_system);
 }
 
 GtkFileFolder *
@@ -497,27 +338,198 @@ gtk_file_system_create_folder(GtkFileSystem     *file_system,
   return GTK_FILE_SYSTEM_GET_IFACE (file_system)->create_folder (file_system, path, error);
 }
 
+/**
+ * gtk_file_system_get_volume_for_path:
+ * @file_system: a #GtkFileSystem
+ * @path: a #GtkFilePath
+ * 
+ * Queries the file system volume that corresponds to a specific path.
+ * There might not be a volume for all paths (consinder for instance remote
+ * shared), so this can return NULL.
+ * 
+ * Return value: the #GtkFileSystemVolume that corresponds to the specified
+ * @path, or NULL if there is no such volume. You should free this value with
+ * gtk_file_system_volume_free().
+ **/
+GtkFileSystemVolume *
+gtk_file_system_get_volume_for_path (GtkFileSystem     *file_system,
+                                    const GtkFilePath *path)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+  g_return_val_if_fail (path != NULL, NULL);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_volume_for_path (file_system, path);
+}
+
+/**
+ * gtk_file_system_volume_free:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ * 
+ * Frees a #GtkFileSystemVolume structure as returned by
+ * gtk_file_system_list_volumes().
+ **/
+void
+gtk_file_system_volume_free (GtkFileSystem       *file_system,
+                            GtkFileSystemVolume *volume)
+{
+  g_return_if_fail (GTK_IS_FILE_SYSTEM (file_system));
+  g_return_if_fail (volume != NULL);
+
+  GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_free (file_system, volume);
+}
+
+/**
+ * gtk_file_system_volume_get_base_path:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ * 
+ * Queries the base path for a volume.  For example, a CD-ROM device may yield a
+ * path of "/mnt/cdrom".
+ * 
+ * Return value: a #GtkFilePath with the base mount path of the specified
+ * @volume.
+ **/
+GtkFilePath *
+gtk_file_system_volume_get_base_path (GtkFileSystem       *file_system,
+                                     GtkFileSystemVolume *volume)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+  g_return_val_if_fail (volume != NULL, NULL);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_get_base_path (file_system, volume);
+}
+
+/**
+ * gtk_file_system_volume_get_is_mounted:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ * 
+ * Queries whether a #GtkFileSystemVolume is mounted or not.  If it is not, it
+ * can be mounted with gtk_file_system_volume_mount().
+ * 
+ * Return value: TRUE if the @volume is mounted, FALSE otherwise.
+ **/
+gboolean
+gtk_file_system_volume_get_is_mounted (GtkFileSystem       *file_system,
+                                      GtkFileSystemVolume *volume)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+  g_return_val_if_fail (volume != NULL, FALSE);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_get_is_mounted (file_system, volume);
+}
+
+/**
+ * gtk_file_system_volume_mount:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ * @error: location to store error, or %NULL
+ * 
+ * Tries to mount an unmounted volume.  This may cause the "volumes-changed"
+ * signal in the @file_system to be emitted.
+ * 
+ * Return value: TRUE if the @volume was mounted successfully, FALSE otherwise.
+ **/
+gboolean
+gtk_file_system_volume_mount (GtkFileSystem        *file_system, 
+                             GtkFileSystemVolume  *volume,
+                             GError              **error)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+  g_return_val_if_fail (volume != NULL, FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_mount (file_system, volume, error);
+}
+
+/**
+ * gtk_file_system_volume_get_display_name:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ * 
+ * Queries the human-readable name for a @volume.  This string can be displayed
+ * in a list of volumes that can be accessed, for example.
+ * 
+ * Return value: A string with the human-readable name for a #GtkFileSystemVolume.
+ **/
+char *
+gtk_file_system_volume_get_display_name (GtkFileSystem        *file_system, 
+                                        GtkFileSystemVolume  *volume)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+  g_return_val_if_fail (volume != NULL, NULL);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_get_display_name (file_system, volume);
+}
+
+/**
+ * gtk_file_system_volume_render_icon:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ * @widget: Reference widget to render icons.
+ * @pixel_size: Size of the icon.
+ * @error: location to store error, or %NULL
+ * 
+ * Renders an icon suitable for a file #GtkFileSystemVolume.
+ * 
+ * Return value: A #GdkPixbuf containing an icon, or NULL if the icon could not
+ * be rendered.  In the latter case, the @error value will be set as
+ * appropriate.
+ **/
+GdkPixbuf *
+gtk_file_system_volume_render_icon (GtkFileSystem        *file_system,
+                                   GtkFileSystemVolume  *volume,
+                                   GtkWidget            *widget,
+                                   gint                  pixel_size,
+                                   GError              **error)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+  g_return_val_if_fail (volume != NULL, NULL);
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+  g_return_val_if_fail (pixel_size > 0, NULL);
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_render_icon (file_system,
+                                                                     volume,
+                                                                     widget,
+                                                                     pixel_size,
+                                                                     error);
+}
+
+/**
+ * gtk_file_system_get_parent:
+ * @file_system: a #GtkFileSystem
+ * @path: base path name
+ * @parent: location to store parent path name
+ * @error: location to store error, or %NULL
+ * 
+ * Gets the name of the parent folder of a path.  If the path has no parent, as when
+ * you request the parent of a file system root, then @parent will be set to %NULL.
+ * 
+ * Return value: %TRUE if the operation was successful:  @parent will be set to
+ * the name of the @path's parent, or to %NULL if @path is already a file system
+ * root.  If the operation fails, this function returns %FALSE, sets @parent to
+ * NULL, and sets the @error value if it is specified.
+ **/
 gboolean
 gtk_file_system_get_parent (GtkFileSystem     *file_system,
                            const GtkFilePath *path,
                            GtkFilePath      **parent,
                            GError           **error)
 {
-  GtkFilePath *tmp_parent = NULL;
   gboolean result;
   
   g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
   g_return_val_if_fail (path != NULL, FALSE);
+  g_return_val_if_fail (parent != NULL, FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-  result = GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_parent (file_system, path, &tmp_parent, error);
-  g_assert (result || tmp_parent == NULL);
+  *parent = NULL;
+
+  result = GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_parent (file_system, path, parent, error);
+  g_assert (result || *parent == NULL);
 
-  if (parent)
-    *parent = tmp_parent;
-  else
-    gtk_file_path_free (tmp_parent);
-  
   return result;
 }
 
@@ -530,7 +542,7 @@ gtk_file_system_make_path (GtkFileSystem    *file_system,
   g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
   g_return_val_if_fail (base_path != NULL, NULL);
   g_return_val_if_fail (display_name != NULL, NULL);
-  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
   return GTK_FILE_SYSTEM_GET_IFACE (file_system)->make_path (file_system, base_path, display_name, error);
 }
@@ -642,6 +654,123 @@ gtk_file_system_filename_to_path (GtkFileSystem *file_system,
   return GTK_FILE_SYSTEM_GET_IFACE (file_system)->filename_to_path (file_system, filename);
 }
 
+/**
+ * gtk_file_system_path_is_local:
+ * @filesystem: a #GtkFileSystem
+ * @path: A #GtkFilePath from that filesystem
+ * 
+ * Checks whether a #GtkFilePath is local; that is whether
+ * gtk_file_system_path_to_filename would return non-%NULL.
+ * 
+ * Return value: %TRUE if the path is loca
+ **/
+gboolean
+gtk_file_system_path_is_local (GtkFileSystem     *file_system,
+                              const GtkFilePath *path)
+{
+  gchar *filename;
+  gboolean result;
+    
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+  g_return_val_if_fail (path != NULL, FALSE);
+
+  filename = gtk_file_system_path_to_filename (file_system, path);
+  result = filename != NULL;
+  g_free (filename);
+
+  return result;
+}
+
+GdkPixbuf *
+gtk_file_system_render_icon (GtkFileSystem      *file_system,
+                            const GtkFilePath  *path,
+                            GtkWidget          *widget,
+                            gint                pixel_size,
+                            GError            **error)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+  g_return_val_if_fail (path != NULL, NULL);
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+  g_return_val_if_fail (pixel_size > 0, NULL);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->render_icon (file_system, path, widget, pixel_size, error);
+}
+
+/**
+ * gtk_file_system_insert_bookmark:
+ * @file_system: a #GtkFileSystem
+ * @path: path of the bookmark to add
+ * @position: index in the bookmarks list at which the @path should be inserted; use 0
+ * for the beginning, and -1 or the number of bookmarks itself for the end of the list.
+ * @error: location to store error, or %NULL
+ * 
+ * Adds a path for a folder to the user's bookmarks list.  If the operation
+ * succeeds, the "bookmarks_changed" signal will be emitted.  Bookmark paths are
+ * unique; if you try to insert a @path that already exists, the operation will
+ * fail and the @error will be set to #GTK_FILE_SYSTEM_ERROR_ALREADY_EXISTS.  To
+ * reorder the list of bookmarks, use gtk_file_system_remove_bookmark() to
+ * remove the path in question, and call gtk_file_system_insert_bookmark() with
+ * the new position for the path.
+ * 
+ * Return value: TRUE if the operation succeeds, FALSE otherwise.  In the latter case,
+ * the @error value will be set.
+ **/
+gboolean
+gtk_file_system_insert_bookmark (GtkFileSystem     *file_system,
+                                const GtkFilePath *path,
+                                gint               position,
+                                GError           **error)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+  g_return_val_if_fail (path != NULL, FALSE);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->insert_bookmark (file_system, path, position, error);
+}
+
+/**
+ * gtk_file_system_remove_bookmark:
+ * @file_system: a #GtkFileSystem
+ * @path: path of the bookmark to remove
+ * @error: location to store error, or %NULL
+ * 
+ * Removes a bookmark folder from the user's bookmarks list.  If the operation
+ * succeeds, the "bookmarks_changed" signal will be emitted.  If you try to remove
+ * a @path which does not exist in the bookmarks list, the operation will fail
+ * and the @error will be set to GTK_FILE_SYSTEM_ERROR_NONEXISTENT.
+ * 
+ * Return value: TRUE if the operation succeeds, FALSE otherwise.  In the latter
+ * case, the @error value will be set.
+ **/
+gboolean
+gtk_file_system_remove_bookmark (GtkFileSystem     *file_system,
+                                const GtkFilePath *path,
+                                GError           **error)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+  g_return_val_if_fail (path != NULL, FALSE);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->remove_bookmark (file_system, path, error);
+}
+
+/**
+ * gtk_file_system_list_bookmarks:
+ * @file_system: a #GtkFileSystem
+ * 
+ * Queries the list of bookmarks in the file system.
+ * 
+ * Return value: A list of #GtkFilePath, or NULL if there are no configured
+ * bookmarks.  You should use gtk_file_paths_free() to free this list.
+ *
+ * See also: gtk_file_system_get_supports_bookmarks()
+ **/
+GSList *
+gtk_file_system_list_bookmarks (GtkFileSystem *file_system)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_bookmarks (file_system);
+}
+
 /*****************************************
  *             GtkFileFolder             *
  *****************************************/
@@ -742,18 +871,86 @@ gtk_file_folder_get_info (GtkFileFolder     *folder,
                          GError           **error)
 {
   g_return_val_if_fail (GTK_IS_FILE_FOLDER (folder), NULL);
-  g_return_val_if_fail (path != NULL, NULL);
   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
   return GTK_FILE_FOLDER_GET_IFACE (folder)->get_info (folder, path, error);
 }
 
+
+/*****************************************
+ *         GtkFilePath modules           *
+ *****************************************/
+
+/* We make these real functions in case either copy or free are implemented as macros
+ */
+static gpointer
+gtk_file_path_real_copy (gpointer boxed)
+{
+  return gtk_file_path_copy ((GtkFilePath *) boxed);
+}
+
+static void
+gtk_file_path_real_free        (gpointer boxed)
+{
+  gtk_file_path_free (boxed);
+}
+
+GType
+gtk_file_path_get_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("GtkFilePath",
+                                            (GBoxedCopyFunc) gtk_file_path_real_copy,
+                                            (GBoxedFreeFunc) gtk_file_path_real_free);
+
+  return our_type;
+}
+
+
 GSList *
 gtk_file_paths_sort (GSList *paths)
 {
   return g_slist_sort (paths, (GCompareFunc)strcmp);
 }
 
+/**
+ * gtk_file_paths_copy:
+ * @paths: A #GSList of #GtkFilePath structures.
+ * 
+ * Copies a list of #GtkFilePath structures.
+ * 
+ * Return value: A copy of @paths.  Since the contents of the list are copied as
+ * well, you should use gtk_file_paths_free() to free the result.
+ **/
+GSList *
+gtk_file_paths_copy (GSList *paths)
+{
+  GSList *head, *tail, *l;
+
+  head = tail = NULL;
+
+  for (l = paths; l; l = l->next)
+    {
+      GtkFilePath *path;
+      GSList *node;
+
+      path = l->data;
+      node = g_slist_alloc ();
+
+      if (tail)
+       tail->next = node;
+      else
+       head = node;
+
+      node->data = gtk_file_path_copy (path);
+      tail = node;
+    }
+
+  return head;
+}
+
 void
 gtk_file_paths_free (GSList *paths)
 {
@@ -764,3 +961,171 @@ gtk_file_paths_free (GSList *paths)
 
   g_slist_free (paths);
 }
+
+/*****************************************
+ *         GtkFileSystem modules         *
+ *****************************************/
+
+typedef struct _GtkFileSystemModule GtkFileSystemModule;
+typedef struct _GtkFileSystemModuleClass GtkFileSystemModuleClass;
+
+struct _GtkFileSystemModule
+{
+  GTypeModule parent_instance;
+  
+  GModule *library;
+
+  void            (*init)     (GTypeModule    *module);
+  void            (*exit)     (void);
+  GtkFileSystem * (*create)   (void);
+
+  gchar *path;
+};
+
+struct _GtkFileSystemModuleClass
+{
+  GTypeModuleClass parent_class;
+};
+
+G_DEFINE_TYPE (GtkFileSystemModule, gtk_file_system_module, G_TYPE_TYPE_MODULE);
+#define GTK_TYPE_FILE_SYSTEM_MODULE       (gtk_file_system_module_get_type ())
+#define GTK_FILE_SYSTEM_MODULE(module)   (G_TYPE_CHECK_INSTANCE_CAST ((module), GTK_TYPE_FILE_SYSTEM_MODULE, GtkFileSystemModule))
+
+
+static GSList *loaded_file_systems;
+
+static gboolean
+gtk_file_system_module_load (GTypeModule *module)
+{
+  GtkFileSystemModule *fs_module = GTK_FILE_SYSTEM_MODULE (module);
+  
+  fs_module->library = g_module_open (fs_module->path, 0);
+  if (!fs_module->library)
+    {
+      g_warning (g_module_error());
+      return FALSE;
+    }
+  
+  /* extract symbols from the lib */
+  if (!g_module_symbol (fs_module->library, "fs_module_init",
+                       (gpointer *)&fs_module->init) ||
+      !g_module_symbol (fs_module->library, "fs_module_exit", 
+                       (gpointer *)&fs_module->exit) ||
+      !g_module_symbol (fs_module->library, "fs_module_create", 
+                       (gpointer *)&fs_module->create))
+    {
+      g_warning (g_module_error());
+      g_module_close (fs_module->library);
+      
+      return FALSE;
+    }
+           
+  /* call the filesystems's init function to let it */
+  /* setup anything it needs to set up. */
+  fs_module->init (module);
+
+  return TRUE;
+}
+
+static void
+gtk_file_system_module_unload (GTypeModule *module)
+{
+  GtkFileSystemModule *fs_module = GTK_FILE_SYSTEM_MODULE (module);
+  
+  fs_module->exit();
+
+  g_module_close (fs_module->library);
+  fs_module->library = NULL;
+
+  fs_module->init = NULL;
+  fs_module->exit = NULL;
+  fs_module->create = NULL;
+}
+
+/* This only will ever be called if an error occurs during
+ * initialization
+ */
+static void
+gtk_file_system_module_finalize (GObject *object)
+{
+  GtkFileSystemModule *module = GTK_FILE_SYSTEM_MODULE (object);
+
+  g_free (module->path);
+
+  G_OBJECT_CLASS (gtk_file_system_module_parent_class)->finalize (object);
+}
+
+static void
+gtk_file_system_module_class_init (GtkFileSystemModuleClass *class)
+{
+  GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
+  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+  
+  module_class->load = gtk_file_system_module_load;
+  module_class->unload = gtk_file_system_module_unload;
+
+  gobject_class->finalize = gtk_file_system_module_finalize;
+}
+
+static void
+gtk_file_system_module_init (GtkFileSystemModule *fs_module)
+{
+}
+
+
+static GtkFileSystem *
+_gtk_file_system_module_create (GtkFileSystemModule *fs_module)
+{
+  GtkFileSystem *fs;
+  
+  if (g_type_module_use (G_TYPE_MODULE (fs_module)))
+    {
+      fs = fs_module->create ();
+      g_type_module_unuse (G_TYPE_MODULE (fs_module));
+      return fs;
+    }
+  return NULL;
+}
+
+
+GtkFileSystem *
+_gtk_file_system_create (const char *file_system_name)
+{
+  GSList *l;
+  char *module_path;
+  GtkFileSystemModule *fs_module;
+  GtkFileSystem *fs;
+
+  for (l = loaded_file_systems; l != NULL; l = l->next)
+    {
+      fs_module = l->data;
+      
+      if (strcmp (G_TYPE_MODULE (fs_module)->name, file_system_name) == 0)
+       return _gtk_file_system_module_create (fs_module);
+    }
+
+  fs = NULL;
+  if (g_module_supported ())
+    {
+      module_path = _gtk_find_module (file_system_name, "filesystems");
+
+      if (module_path)
+       {
+         fs_module = g_object_new (GTK_TYPE_FILE_SYSTEM_MODULE, NULL);
+
+         g_type_module_set_name (G_TYPE_MODULE (fs_module), file_system_name);
+         fs_module->path = g_strdup (module_path);
+
+         loaded_file_systems = g_slist_prepend (loaded_file_systems,
+                                                fs_module);
+
+         fs = _gtk_file_system_module_create (fs_module);
+       }
+      
+      g_free (module_path);
+    }
+  
+  return fs;
+}
+
+