[PATCH] proxy nautilus_file_is_in_trash to NautilusDirectory
- From: Christian Neumair <chris gnome-de org>
- To: nautilus-list <nautilus-list gnome org>
- Subject: [PATCH] proxy nautilus_file_is_in_trash to NautilusDirectory
- Date: Sun, 24 Sep 2006 14:02:54 +0200
The attached patch proxies nautilus_file_is_in_trash calls to
NautilusDirectory, similar to nautilus_file_is_local. This can IMHO
vastly improve performance for some network mounts, where huge
directories are loaded and each file used to be queried (sync.).
In the long term, it might be nice to introduce an async mechanism for
is_local, is_trash and all blocking calls, and request pre-caching on
NautilusDirectory load (through nautilus-directory-async?). If the async
calls are ready before the value is queried, we'd set the state, if they
are not ready when the value is queried, we'd cancel the async calls and
instead to a sync call, or wait until the async calls are ready.
Caveat: For trash directories (like ~/.Trash), is_in_trash will be FALSE
after the patch is applied, before it was TRUE.
--
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-directory-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-directory-private.h,v
retrieving revision 1.97
diff -u -p -r1.97 nautilus-directory-private.h
--- libnautilus-private/nautilus-directory-private.h 23 Aug 2006 09:07:11 -0000 1.97
+++ libnautilus-private/nautilus-directory-private.h 24 Sep 2006 11:55:22 -0000
@@ -104,6 +104,8 @@ struct NautilusDirectoryDetails
GnomeVFSAsyncHandle *get_info_in_progress;
gboolean get_info_has_slow_mime_type;
+ int is_in_trash_state;
+
NautilusFile *slow_mime_type_file;
GnomeVFSAsyncHandle *slow_mime_type_in_progress;
Index: libnautilus-private/nautilus-directory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-directory.c,v
retrieving revision 1.259
diff -u -p -r1.259 nautilus-directory.c
--- libnautilus-private/nautilus-directory.c 23 Aug 2006 09:07:12 -0000 1.259
+++ libnautilus-private/nautilus-directory.c 24 Sep 2006 11:55:26 -0000
@@ -553,6 +553,25 @@ nautilus_directory_is_local (NautilusDir
}
gboolean
+nautilus_directory_is_in_trash (NautilusDirectory *directory)
+{
+ g_assert (NAUTILUS_IS_DIRECTORY (directory));
+
+ if (directory->details->uri == NULL) {
+ return FALSE;
+ }
+ if (directory->details->is_in_trash_state == 0) {
+ if (eel_uri_is_in_trash (directory->details->uri)) {
+ directory->details->is_in_trash_state = 1;
+ } else {
+ directory->details->is_in_trash_state = -1;
+ }
+ }
+
+ return directory->details->is_in_trash_state > 0;
+}
+
+gboolean
nautilus_directory_are_all_files_seen (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
Index: libnautilus-private/nautilus-directory.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-directory.h,v
retrieving revision 1.68
diff -u -p -r1.68 nautilus-directory.h
--- libnautilus-private/nautilus-directory.h 12 Dec 2005 16:59:10 -0000 1.68
+++ libnautilus-private/nautilus-directory.h 24 Sep 2006 11:55:27 -0000
@@ -216,6 +216,8 @@ gboolean nautilus_directory_ar
/* Return true if the directory is local. */
gboolean nautilus_directory_is_local (NautilusDirectory *directory);
+gboolean nautilus_directory_is_in_trash (NautilusDirectory *directory);
+
/* Return false if directory contains anything besides a Nautilus metafile.
* Only valid if directory is monitored. Used by the Trash monitor.
*/
Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.390
diff -u -p -r1.390 nautilus-file.c
--- libnautilus-private/nautilus-file.c 25 Jul 2006 14:18:03 -0000 1.390
+++ libnautilus-private/nautilus-file.c 24 Sep 2006 11:55:38 -0000
@@ -5228,9 +5221,9 @@ nautilus_file_is_directory (NautilusFile
gboolean
nautilus_file_is_in_trash (NautilusFile *file)
{
- g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+ g_assert (NAUTILUS_IS_FILE (file));
- return eel_uri_is_in_trash (file->details->directory->details->uri);
+ return nautilus_directory_is_in_trash (file->details->directory);
}
GnomeVFSResult
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]