libgnomeui r5561 - in trunk: . file-chooser



Author: hadess
Date: Fri Mar  7 16:53:40 2008
New Revision: 5561
URL: http://svn.gnome.org/viewvc/libgnomeui?rev=5561&view=rev

Log:
2008-03-07  Bastien Nocera  <hadess hadess net>

	* file-chooser/gtkfilesystemgio.c (mount_async_callback),
	(query_info_callback), (gtk_file_system_gio_get_info):
	Try to mount remote locations when getting the file info
	fails with a "Not mounted" error (Closes: #520615)



Modified:
   trunk/ChangeLog
   trunk/file-chooser/gtkfilesystemgio.c

Modified: trunk/file-chooser/gtkfilesystemgio.c
==============================================================================
--- trunk/file-chooser/gtkfilesystemgio.c	(original)
+++ trunk/file-chooser/gtkfilesystemgio.c	Fri Mar  7 16:53:40 2008
@@ -88,6 +88,7 @@
   guint source_id;
   gpointer callback;
   gpointer data;
+  guint tried_mount : 1;
 };
 
 struct GtkFileFolderGioClass
@@ -196,6 +197,9 @@
 static void                  gtk_file_system_gio_set_bookmark_label (GtkFileSystem                *file_system,
 								     const GtkFilePath            *path,
 								     const gchar                  *label);
+static void                  query_info_callback                    (GObject      *source_object,
+								     GAsyncResult *result,
+								     gpointer      user_data);
 
 /* GtkFileFolderGio methods */
 static GType gtk_file_folder_gio_get_type       (void);
@@ -832,6 +836,35 @@
 }
 
 static void
+mount_async_callback (GObject      *source_object,
+		      GAsyncResult *result,
+		      gpointer      user_data)
+{
+  GtkFileSystemHandleGio *handle;
+  GError *error = NULL;
+  GFile *file;
+
+  DEBUG ("mount_async_callback");
+
+  g_message ("tried to mount something");
+
+  file = G_FILE (source_object);
+  handle = GTK_FILE_SYSTEM_HANDLE_GIO (user_data);
+  if (g_file_mount_enclosing_volume_finish (file, result, &error))
+    {
+      g_file_query_info_async (file, "standard,time,thumbnail::*", 0, 0,
+			       handle->cancellable,
+			       query_info_callback,
+			       handle);
+    }
+  else
+    {
+      ((GtkFileSystemGetInfoCallback) handle->callback) (GTK_FILE_SYSTEM_HANDLE (handle),
+							 NULL, error, handle->data);
+    }
+}
+
+static void
 query_info_callback (GObject      *source_object,
 		     GAsyncResult *result,
 		     gpointer      user_data)
@@ -853,6 +886,17 @@
       info = translate_file_info (file_info);
       g_object_unref (file_info);
     }
+  else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTED) && !handle->tried_mount)
+    {
+      /* If it's not mounted, try to mount it ourselves */
+      g_error_free (error);
+      handle->tried_mount = TRUE;
+      g_file_mount_enclosing_volume (file, G_MOUNT_MOUNT_NONE, NULL,
+				     handle->cancellable,
+				     mount_async_callback,
+				     handle);
+      return;
+    }
 
   ((GtkFileSystemGetInfoCallback) handle->callback) (GTK_FILE_SYSTEM_HANDLE (handle),
 						     info, error, handle->data);
@@ -882,6 +926,7 @@
   handle->cancellable = g_cancellable_new ();
   handle->callback = callback;
   handle->data = data;
+  handle->tried_mount = FALSE;
 
   g_file_query_info_async (file, "standard,time,thumbnail::*", 0, 0,
 			   handle->cancellable,



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