Re: GtkFileSystemGnomeVFS



On Tue, 2004-02-17 at 19:12, Owen Taylor wrote:
> On Mon, 2004-02-16 at 17:47, Alexander Larsson wrote:
> > On Mon, 2004-02-16 at 16:34, Owen Taylor wrote:
> > > On Mon, 2004-02-16 at 10:30, Alexander Larsson wrote:
> > > 
> > > > How about this patch? It changes the old "file-system" property into a
> > > > string, and does named lookups for filesystem backends. It also adds
> > > > gtk_file_chooser_dialog_new_with_backend and fixes an issue with the
> > > > folder mode and volumes in gtkfilechooserdefault.
> > > 
> > > I'd like to see this done using GTypeModule, like themes, Pango modules,
> > > input method modules, etc; with G_DEFINE_TYPE it shouldn't be more
> > > than 30-40 extra lines of code.
> > 
> > Like this?
> 
> Generally, looks right. Detailed comments:
> 
> * "File System backend" property name should be "File System Backend"
> 
> * The gtkfilechooserdefault code for PROP_FILE_SYSTEM should be split
>   out into a separate static function... it's too long to be inline  
>   now.
> 
> * The gtkfilechooserdefault code for PROP_FILE_SYSTEM mixes
>   if (file_system) with if (file_system == NULL), no fixed rule
>   on this in GTK+ other than consistency in adjacent code
>   but we generally use if (!file_system).
> 
> * gtk_file_chooser_dialog_new() and new_with_backend() IMO should
>   be made wrappers around an internal function that takes a va_list,
>   there's not a lot of duplicated code, but enough.
> 
> * Some typos in the new_with_backend() docs "especially useful if use"
>   set_local_only should be set_local_only() to get the right markup.

All right. New version.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a witless flyboy dwarf with a robot buddy named Sparky. She's a 
bloodthirsty out-of-work mercenary who hides her beauty behind a pair of 
thick-framed spectacles. They fight crime! 
Index: gtk/gtkfilechooser.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooser.c,v
retrieving revision 1.23
diff -u -p -r1.23 gtkfilechooser.c
--- gtk/gtkfilechooser.c	16 Jan 2004 23:09:24 -0000	1.23
+++ gtk/gtkfilechooser.c	18 Feb 2004 10:26:34 -0000
@@ -95,10 +95,10 @@ gtk_file_chooser_class_init (gpointer g_
 							  GTK_FILE_CHOOSER_ACTION_OPEN,
 							  G_PARAM_READWRITE));
   g_object_interface_install_property (g_iface,
-				       g_param_spec_object ("file-system",
-							    P_("File System"),
-							    P_("File system object to use"),
-							    GTK_TYPE_FILE_SYSTEM,
+				       g_param_spec_string ("file-system",
+							    P_("File System Backend"),
+							    P_("Name of file system backend to use"),
+							    NULL, 
 							    G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
   g_object_interface_install_property (g_iface,
 				       g_param_spec_object ("filter",
Index: gtk/gtkfilechooserdefault.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserdefault.c,v
retrieving revision 1.65
diff -u -p -r1.65 gtkfilechooserdefault.c
--- gtk/gtkfilechooserdefault.c	10 Feb 2004 19:48:38 -0000	1.65
+++ gtk/gtkfilechooserdefault.c	18 Feb 2004 10:26:35 -0000
@@ -51,6 +51,12 @@
 #include "gtktypebuiltins.h"
 #include "gtkvbox.h"
 
+#if defined (G_OS_UNIX)
+#include "gtkfilesystemunix.h"
+#elif defined (G_OS_WIN32)
+#include "gtkfilesystemwin32.h"
+#endif
+
 #include <string.h>
 #include <time.h>
 
@@ -1696,6 +1702,45 @@ set_select_multiple (GtkFileChooserDefau
 }
 
 static void
+set_file_system (GtkFileChooserDefault *impl,
+		 const char *file_system)
+{
+  if (impl->file_system)
+    {
+      g_signal_handler_disconnect (impl->file_system, impl->volumes_changed_id);
+      impl->volumes_changed_id = 0;
+      g_signal_handler_disconnect (impl->file_system, impl->bookmarks_changed_id);
+      impl->bookmarks_changed_id = 0;
+      g_object_unref (impl->file_system);
+    }
+  
+  impl->file_system = NULL;
+  if (file_system)
+    impl->file_system = _gtk_file_system_create (file_system);
+  
+  if (!impl->file_system)
+    {
+#if defined (G_OS_UNIX)
+      impl->file_system = gtk_file_system_unix_new ();
+#elif defined (G_OS_WIN32)
+      impl->file_system = gtk_file_system_win32_new ();
+#else
+#error "No default filesystem implementation on the platform"
+#endif
+    }
+  
+  if (impl->file_system)
+    {
+      impl->volumes_changed_id = g_signal_connect (impl->file_system, "volumes-changed",
+						   G_CALLBACK (volumes_changed_cb),
+						   impl);
+      impl->bookmarks_changed_id = g_signal_connect (impl->file_system, "bookmarks-changed",
+						     G_CALLBACK (bookmarks_changed_cb),
+						     impl);
+    }
+}
+
+static void
 gtk_file_chooser_default_set_property (GObject      *object,
 				       guint         prop_id,
 				       const GValue *value,
@@ -1724,31 +1769,7 @@ gtk_file_chooser_default_set_property (G
 
       break;
     case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM:
-      {
-	GtkFileSystem *file_system = g_value_get_object (value);
-	if (impl->file_system != file_system)
-	  {
-	    if (impl->file_system)
-	      {
-		g_signal_handler_disconnect (impl->file_system, impl->volumes_changed_id);
-		impl->volumes_changed_id = 0;
-		g_signal_handler_disconnect (impl->file_system, impl->bookmarks_changed_id);
-		impl->bookmarks_changed_id = 0;
-		g_object_unref (impl->file_system);
-	      }
-	    impl->file_system = file_system;
-	    if (impl->file_system)
-	      {
-		g_object_ref (impl->file_system);
-		impl->volumes_changed_id = g_signal_connect (impl->file_system, "volumes-changed",
-							     G_CALLBACK (volumes_changed_cb),
-							     impl);
-		impl->bookmarks_changed_id = g_signal_connect (impl->file_system, "bookmarks-changed",
-							       G_CALLBACK (bookmarks_changed_cb),
-							       impl);
-	      }
-	  }
-      }
+      set_file_system (impl, g_value_get_string (value));
       break;
     case GTK_FILE_CHOOSER_PROP_FILTER:
       set_current_filter (impl, g_value_get_object (value));
@@ -3199,7 +3220,7 @@ list_mtime_data_func (GtkTreeViewColumn 
 }
 
 GtkWidget *
-_gtk_file_chooser_default_new (GtkFileSystem *file_system)
+_gtk_file_chooser_default_new (const char *file_system)
 {
   return  g_object_new (GTK_TYPE_FILE_CHOOSER_DEFAULT,
 			"file-system", file_system,
Index: gtk/gtkfilechooserdefault.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserdefault.h,v
retrieving revision 1.3
diff -u -p -r1.3 gtkfilechooserdefault.h
--- gtk/gtkfilechooserdefault.h	23 Oct 2003 00:26:15 -0000	1.3
+++ gtk/gtkfilechooserdefault.h	18 Feb 2004 10:26:35 -0000
@@ -33,7 +33,7 @@ G_BEGIN_DECLS
 typedef struct _GtkFileChooserDefault      GtkFileChooserDefault;
 
 GType      _gtk_file_chooser_default_get_type (void);
-GtkWidget *_gtk_file_chooser_default_new      (GtkFileSystem *file_system);
+GtkWidget *_gtk_file_chooser_default_new      (const char *file_system);
 
 G_END_DECLS
 
Index: gtk/gtkfilechooserdialog.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserdialog.c,v
retrieving revision 1.11
diff -u -p -r1.11 gtkfilechooserdialog.c
--- gtk/gtkfilechooserdialog.c	14 Feb 2004 01:23:58 -0000	1.11
+++ gtk/gtkfilechooserdialog.c	18 Feb 2004 10:26:35 -0000
@@ -33,13 +33,14 @@ struct _GtkFileChooserDialogPrivate
 {
   GtkWidget *widget;
 
-  GtkFileSystem *file_system;
+  char *file_system;
 };
 
 #define GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE(o)  (GTK_FILE_CHOOSER_DIALOG (o)->priv)
 
 static void gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class);
 static void gtk_file_chooser_dialog_init       (GtkFileChooserDialog      *dialog);
+static void gtk_file_chooser_dialog_finalize   (GObject                   *object);
 
 static GObject* gtk_file_chooser_dialog_constructor  (GType                  type,
 						      guint                  n_construct_properties,
@@ -109,6 +110,7 @@ gtk_file_chooser_dialog_class_init (GtkF
   gobject_class->constructor = gtk_file_chooser_dialog_constructor;
   gobject_class->set_property = gtk_file_chooser_dialog_set_property;
   gobject_class->get_property = gtk_file_chooser_dialog_get_property;
+  gobject_class->finalize = gtk_file_chooser_dialog_finalize;
 
   widget_class->realize = gtk_file_chooser_dialog_realize;
   widget_class->style_set = gtk_file_chooser_dialog_style_set;
@@ -130,6 +132,14 @@ gtk_file_chooser_dialog_init (GtkFileCho
   gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 }
 
+static void
+gtk_file_chooser_dialog_finalize (GObject *object)
+{
+  GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (object);
+
+  g_free (dialog->priv->file_system);
+}
+
 /* Callback used when the user activates a file in the file chooser widget */
 static void
 file_chooser_widget_file_activated (GtkFileChooser       *chooser,
@@ -186,17 +196,8 @@ gtk_file_chooser_dialog_set_property (GO
   switch (prop_id)
     {
     case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM:
-      {
-	GtkFileSystem *file_system = g_value_get_object (value);
-	if (priv->file_system != file_system)
-	  {
-	    if (priv->file_system)
-	      g_object_unref (priv->file_system);
-	    priv->file_system = file_system;
-	    if (priv->file_system)
-	      g_object_ref (priv->file_system);
-	  }
-      }
+      g_free (priv->file_system);
+      priv->file_system = g_value_dup_string (value);
       break;
     default:
       g_object_set_property (G_OBJECT (priv->widget), pspec->name, value);
@@ -293,6 +294,37 @@ gtk_file_chooser_dialog_screen_changed (
     set_default_size (GTK_FILE_CHOOSER_DIALOG (widget));
 }
 
+static GtkWidget *
+gtk_file_chooser_dialog_new_valist (const gchar          *title,
+				    GtkWindow            *parent,
+				    GtkFileChooserAction  action,
+				    const gchar          *backend,
+				    const gchar          *first_button_text,
+				    va_list               varargs)
+{
+  GtkWidget *result;
+  const char *button_text = first_button_text;
+  gint response_id;
+
+  result = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
+			 "title", title,
+			 "action", action,
+			 "file-system", backend,
+			 NULL);
+
+  if (parent)
+    gtk_window_set_transient_for (GTK_WINDOW (result), parent);
+
+  while (button_text)
+    {
+      response_id = va_arg (varargs, gint);
+      gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
+      button_text = va_arg (varargs, const gchar *);
+    }
+
+  return result;
+}
+
 /**
  * gtk_file_chooser_dialog_new:
  * @title: Title of the dialog, or %NULL
@@ -317,26 +349,49 @@ gtk_file_chooser_dialog_new (const gchar
 {
   GtkWidget *result;
   va_list varargs;
-  const char *button_text = first_button_text;
-  gint response_id;
-
-  result = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
-			 "title", title,
-			 "action", action,
-			 NULL);
-
-  if (parent)
-    gtk_window_set_transient_for (GTK_WINDOW (result), parent);
-
+  
   va_start (varargs, first_button_text);
+  result = gtk_file_chooser_dialog_new_valist (title, parent, action,
+					       NULL, first_button_text,
+					       varargs);
+  va_end (varargs);
 
-  while (button_text)
-    {
-      response_id = va_arg (varargs, gint);
-      gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
-      button_text = va_arg (varargs, const gchar *);
-    }
+  return result;
+}
 
+/**
+ * gtk_file_chooser_dialog_new_with_backend:
+ * @title: Title of the dialog, or %NULL
+ * @parent: Transient parent of the dialog, or %NULL
+ * @backend: The name of the specific filesystem backend to use.
+ * @action: Open or save mode for the dialog
+ * @first_button_text: stock ID or text to go in the first button, or %NULL
+ * @Varargs: response ID for the first button, then additional (button, id) pairs, ending with %NULL
+ *
+ * Creates a new #GtkFileChooserDialog with a specified backend. This is
+ * especially useful if you use gtk_file_chooser_set_local_only() to allow
+ * non-local files and you use a more expressive vfs, such as gnome-vfs,
+ * to load files.
+ *
+ * Return value: a new #GtkFileChooserDialog
+ *
+ * Since: 2.4
+ **/
+GtkWidget *
+gtk_file_chooser_dialog_new_with_backend (const gchar          *title,
+					  GtkWindow            *parent,
+					  GtkFileChooserAction  action,
+					  const gchar          *backend,
+					  const gchar          *first_button_text,
+					  ...)
+{
+  GtkWidget *result;
+  va_list varargs;
+  
+  va_start (varargs, first_button_text);
+  result = gtk_file_chooser_dialog_new_valist (title, parent, action,
+					       backend, first_button_text,
+					       varargs);
   va_end (varargs);
 
   return result;
Index: gtk/gtkfilechooserdialog.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserdialog.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 gtkfilechooserdialog.h
--- gtk/gtkfilechooserdialog.h	21 Mar 2003 20:34:02 -0000	1.1.1.1
+++ gtk/gtkfilechooserdialog.h	18 Feb 2004 10:26:35 -0000
@@ -50,12 +50,18 @@ struct _GtkFileChooserDialog
   GtkFileChooserDialogPrivate *priv;
 };
 
-GType      gtk_file_chooser_dialog_get_type (void);
-GtkWidget *gtk_file_chooser_dialog_new      (const gchar         *title,
-					     GtkWindow           *parent,
-					     GtkFileChooserAction action,
-					     const gchar         *first_button_text,
-					     ...);
+GType      gtk_file_chooser_dialog_get_type         (void);
+GtkWidget *gtk_file_chooser_dialog_new              (const gchar          *title,
+						     GtkWindow            *parent,
+						     GtkFileChooserAction  action,
+						     const gchar          *first_button_text,
+						     ...);
+GtkWidget *gtk_file_chooser_dialog_new_with_backend (const gchar          *title,
+						     GtkWindow            *parent,
+						     GtkFileChooserAction  action,
+						     const gchar          *backend,
+						     const gchar          *first_button_text,
+						     ...);
 
 G_END_DECLS
 
Index: gtk/gtkfilechooserwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserwidget.c,v
retrieving revision 1.12
diff -u -p -r1.12 gtkfilechooserwidget.c
--- gtk/gtkfilechooserwidget.c	16 Dec 2003 22:58:58 -0000	1.12
+++ gtk/gtkfilechooserwidget.c	18 Feb 2004 10:26:35 -0000
@@ -23,23 +23,18 @@
 #include "gtkfilechooserutils.h"
 #include "gtktypebuiltins.h"
 
-#if defined (G_OS_UNIX)
-#include "gtkfilesystemunix.h"
-#elif defined (G_OS_WIN32)
-#include "gtkfilesystemwin32.h"
-#endif
-
 struct _GtkFileChooserWidgetPrivate
 {
   GtkWidget *impl;
 
-  GtkFileSystem *file_system;
+  char *file_system;
 };
 
 #define GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE(o)  (GTK_FILE_CHOOSER_WIDGET (o)->priv)
 
 static void gtk_file_chooser_widget_class_init   (GtkFileChooserWidgetClass *class);
 static void gtk_file_chooser_widget_init         (GtkFileChooserWidget      *chooser_widget);
+static void gtk_file_chooser_widget_finalize     (GObject                   *object);
 
 static GObject* gtk_file_chooser_widget_constructor  (GType                  type,
 						      guint                  n_construct_properties,
@@ -102,6 +97,7 @@ gtk_file_chooser_widget_class_init (GtkF
   gobject_class->constructor = gtk_file_chooser_widget_constructor;
   gobject_class->set_property = gtk_file_chooser_widget_set_property;
   gobject_class->get_property = gtk_file_chooser_widget_get_property;
+  gobject_class->finalize = gtk_file_chooser_widget_finalize;
 
   _gtk_file_chooser_install_properties (gobject_class);
 
@@ -117,6 +113,14 @@ gtk_file_chooser_widget_init (GtkFileCho
   chooser_widget->priv = priv;
 }
 
+static void
+gtk_file_chooser_widget_finalize (GObject *object)
+{
+  GtkFileChooserWidget *chooser = GTK_FILE_CHOOSER_WIDGET (object);
+
+  g_free (chooser->priv->file_system);
+}
+
 static GObject*
 gtk_file_chooser_widget_constructor (GType                  type,
 				     guint                  n_construct_properties,
@@ -134,16 +138,8 @@ gtk_file_chooser_widget_constructor (GTy
 
   gtk_widget_push_composite_child ();
 
-  if (!priv->file_system)
-    {
-#if defined (G_OS_UNIX)
-      priv->file_system = gtk_file_system_unix_new ();
-#elif defined (G_OS_WIN32)
-      priv->file_system = gtk_file_system_win32_new ();
-#endif
-    }
-      
   priv->impl = _gtk_file_chooser_default_new (priv->file_system);
+  
   gtk_box_pack_start (GTK_BOX (object), priv->impl, TRUE, TRUE, 0);
   gtk_widget_show (priv->impl);
 
@@ -175,17 +171,8 @@ gtk_file_chooser_widget_set_property (GO
   switch (prop_id)
     {
     case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM:
-      {
-	GtkFileSystem *file_system = g_value_get_object (value);
-	if (priv->file_system != file_system)
-	  {
-	    if (priv->file_system)
-	      g_object_unref (priv->file_system);
-	    priv->file_system = file_system;
-	    if (priv->file_system)
-	      g_object_ref (priv->file_system);
-	  }
-      }
+      g_free (priv->file_system);
+      priv->file_system = g_value_dup_string (value);
       break;
     default:
       g_object_set_property (G_OBJECT (priv->impl), pspec->name, value);
Index: gtk/gtkfilesystem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilesystem.c,v
retrieving revision 1.21
diff -u -p -r1.21 gtkfilesystem.c
--- gtk/gtkfilesystem.c	30 Jan 2004 19:49:36 -0000	1.21
+++ gtk/gtkfilesystem.c	18 Feb 2004 10:26:35 -0000
@@ -18,9 +18,10 @@
  * Boston, MA 02111-1307, USA.
  */
 
-
+#include <gmodule.h>
 #include "gtkfilesystem.h"
 #include "gtkicontheme.h"
+#include "gtkmain.h"
 
 #include <string.h>
 
@@ -886,3 +887,170 @@ 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)
+{
+  struct FileSystemInfo *file_system_info;
+  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;
+}
Index: gtk/gtkfilesystem.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilesystem.h,v
retrieving revision 1.17
diff -u -p -r1.17 gtkfilesystem.h
--- gtk/gtkfilesystem.h	27 Jan 2004 23:20:01 -0000	1.17
+++ gtk/gtkfilesystem.h	18 Feb 2004 10:26:35 -0000
@@ -335,6 +335,10 @@ GSList *gtk_file_paths_sort (GSList *pat
 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__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]