Author: jannis
Date: 2009-06-17 00:13:08 +0000 (Wed, 17 Jun 2009)
New Revision: 30038

Modified:
   thunar/branches/migration-to-gio/ChangeLog
   thunar/branches/migration-to-gio/thunar/thunar-file.c
   thunar/branches/migration-to-gio/thunar/thunar-file.h
Log:
        * thunar/thunar-file.c: Refactor thunar_file_load() and
          thunar_file_get() a bit. For now, thunar_file_load() will always
          return successful, even if the GFileInfo cannot be loaded. This is
          because we want ThunarFiles for remote URIs that are not yet
          mounted. To compensate for that, there's a new method
          thunar_file_exists() which returns TRUE iff the ThunarFile exists.

Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog  2009-06-16 23:28:53 UTC (rev 
30037)
+++ thunar/branches/migration-to-gio/ChangeLog  2009-06-17 00:13:08 UTC (rev 
30038)
@@ -1,5 +1,14 @@
 2009-06-17     Jannis Pohlmann <jan...@xfce.org>
 
+       * thunar/thunar-file.c: Refactor thunar_file_load() and
+         thunar_file_get() a bit. For now, thunar_file_load() will always
+         return successful, even if the GFileInfo cannot be loaded. This is
+         because we want ThunarFiles for remote URIs that are not yet
+         mounted. To compensate for that, there's a new method
+         thunar_file_exists() which returns TRUE iff the ThunarFile exists.
+
+2009-06-17     Jannis Pohlmann <jan...@xfce.org>
+
        * thunar/main.c, thunar/thunar-application.{c,h}: 
          thunar_application_process_filenames() now works asynchronously
          because it might have to mount the enclosing volumes of one of the

Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c       2009-06-16 
23:28:53 UTC (rev 30037)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c       2009-06-17 
00:13:08 UTC (rev 30038)
@@ -631,7 +631,9 @@
  * @file  : a #GFile.
  * @error : return location for errors.
  *
- * Looks up the #ThunarFile referred to by @file.
+ * Looks up the #ThunarFile referred to by @file. This function may return a
+ * ThunarFile even though the file doesn't actually exist. This is the case
+ * with remote URIs (like SFTP) for instance, if they are not mounted.
  *
  * The caller is responsible to call g_object_unref()
  * when done with the returned object.
@@ -665,12 +667,21 @@
       file->display_name = NULL;
       file->basename = NULL;
 
-      thunar_file_load (file, NULL, error);
+      if (thunar_file_load (file, NULL, error))
+        {
+          /* insert the file into the cache */
+          G_LOCK (file_cache_mutex);
+          g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
+          G_UNLOCK (file_cache_mutex);
+        }
+      else
+        {
+          /* failed loading, destroy the file */
+          g_object_unref (file);
 
-      /* insert the file into the cache */
-      G_LOCK (file_cache_mutex);
-      g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
-      G_UNLOCK (file_cache_mutex);
+          /* make sure we return NULL */
+          file = NULL;
+        }
     }
 
   return file;
@@ -774,10 +785,10 @@
 
   /* query a new file info */
   file->info = g_file_query_info (file->gfile,
-                                   THUNAR_FILE_G_FILE_INFO_NAMESPACE,
-                                   G_FILE_QUERY_INFO_NONE,
-                                   cancellable,
-                                   error);
+                                  THUNAR_FILE_G_FILE_INFO_NAMESPACE,
+                                  G_FILE_QUERY_INFO_NONE,
+                                  cancellable,
+                                  NULL);
 
   /* query a new filesystem info */
   file->filesystem_info = g_file_query_filesystem_info (file->gfile,
@@ -880,7 +891,7 @@
   g_free (md5_hash);
   g_free (uri);
 
-  return (file->info != NULL);
+  return TRUE;
 }
 
 /**
@@ -1864,6 +1875,15 @@
 
 
 
+gboolean
+thunar_file_exists (const ThunarFile *file)
+{
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+  return (file->info != NULL);
+}
+
+
+
 /**
  * thunar_file_is_directory:
  * @file : a #ThunarFile instance.

Modified: thunar/branches/migration-to-gio/thunar/thunar-file.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.h       2009-06-16 
23:28:53 UTC (rev 30037)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.h       2009-06-17 
00:13:08 UTC (rev 30038)
@@ -187,6 +187,7 @@
 ThunarFileMode    thunar_file_get_mode             (const ThunarFile       
*file);
 gboolean          thunar_file_get_free_space       (const ThunarFile       
*file, 
                                                     guint64                
*free_space_return);
+gboolean          thunar_file_exists               (const ThunarFile       
*file);
 gboolean          thunar_file_is_directory         (const ThunarFile       
*file);
 gboolean          thunar_file_is_local             (const ThunarFile       
*file);
 gboolean          thunar_file_is_ancestor          (const ThunarFile       
*file, 

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to