summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neumair <cneumair@gnome.org>2008-07-20 12:45:12 +0000
committerChristian Neumair <cneumair@src.gnome.org>2008-07-20 12:45:12 +0000
commitab67b66116b204cfdbada6786e45ec8dc64305a3 (patch)
tree410bac876d8fc4a98a1bc49414a0561f6ac269a3
parent8107598c77d88be88cded2612a363731d9156709 (diff)
downloadnautilus-ab67b66116b204cfdbada6786e45ec8dc64305a3.tar.gz
Query filesystem ID, as referenced string. Use it to determine whether two
2008-07-20 Christian Neumair <cneumair@gnome.org> * libnautilus-private/nautilus-dnd.c (check_same_fs), (nautilus_drag_default_drop_action_for_icons): * libnautilus-private/nautilus-file-private.h: * libnautilus-private/nautilus-file.c (nautilus_file_clear_info), (finalize), (update_info_internal), (nautilus_file_get_filesystem_id): * libnautilus-private/nautilus-file.h: Query filesystem ID, as referenced string. Use it to determine whether two files are on the same FS during DND. Gets rid of synchronous I/O. svn path=/trunk/; revision=14376
-rw-r--r--ChangeLog12
-rw-r--r--libnautilus-private/nautilus-dnd.c53
-rw-r--r--libnautilus-private/nautilus-file-private.h7
-rw-r--r--libnautilus-private/nautilus-file.c19
-rw-r--r--libnautilus-private/nautilus-file.h2
5 files changed, 56 insertions, 37 deletions
diff --git a/ChangeLog b/ChangeLog
index e6234fb8a..03f0aad2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2008-07-20 Christian Neumair <cneumair@gnome.org>
+ * libnautilus-private/nautilus-dnd.c (check_same_fs),
+ (nautilus_drag_default_drop_action_for_icons):
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c (nautilus_file_clear_info),
+ (finalize), (update_info_internal),
+ (nautilus_file_get_filesystem_id):
+ * libnautilus-private/nautilus-file.h:
+ Query filesystem ID, as referenced string. Use it to determine whether
+ two files are on the same FS during DND. Gets rid of synchronous I/O.
+
+2008-07-20 Christian Neumair <cneumair@gnome.org>
+
* src/nautilus-notebook.c (nautilus_notebook_sync_tab_label):
Use full location name as tab tooltip.
diff --git a/libnautilus-private/nautilus-dnd.c b/libnautilus-private/nautilus-dnd.c
index fe7cbf84c..5120bfda1 100644
--- a/libnautilus-private/nautilus-dnd.c
+++ b/libnautilus-private/nautilus-dnd.c
@@ -388,47 +388,27 @@ nautilus_drag_default_drop_action_for_netscape_url (GdkDragContext *context)
}
static gboolean
-check_same_fs (GFile *file1, GFile *file2)
+check_same_fs (NautilusFile *file1,
+ NautilusFile *file2)
{
- GFileInfo *info1, *info2;
- const char *id1, *id2;
- gboolean res;
-
- info1 = g_file_query_info (file1,
- G_FILE_ATTRIBUTE_ID_FILESYSTEM,
- 0, NULL, NULL);
+ char *id1, *id2;
+ gboolean result;
- if (info1 == NULL) {
- return FALSE;
- }
+ result = FALSE;
- id1 = g_file_info_get_attribute_string (info1, G_FILE_ATTRIBUTE_ID_FILESYSTEM);
- if (id1 == NULL) {
- g_object_unref (info1);
- return FALSE;
- }
-
- info2 = g_file_query_info (file2,
- G_FILE_ATTRIBUTE_ID_FILESYSTEM,
- 0, NULL, NULL);
- if (info2 == NULL) {
- g_object_unref (info1);
- return FALSE;
- }
+ if (file1 != NULL && file2 != NULL) {
+ id1 = nautilus_file_get_filesystem_id (file1);
+ id2 = nautilus_file_get_filesystem_id (file2);
- id2 = g_file_info_get_attribute_string (info2, G_FILE_ATTRIBUTE_ID_FILESYSTEM);
- if (id2 == NULL) {
- g_object_unref (info1);
- g_object_unref (info2);
- return FALSE;
+ if (id1 != NULL && id2 != NULL) {
+ result = (strcmp (id1, id2) == 0);
+ }
+
+ g_free (id1);
+ g_free (id2);
}
- res = strcmp (id1, id2) == 0;
-
- g_object_unref (info1);
- g_object_unref (info2);
-
- return res;
+ return result;
}
void
@@ -510,12 +490,13 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
target = g_file_new_for_uri (target_uri_string);
}
+ same_fs = check_same_fs (target_file, dropped_file);
+
nautilus_file_unref (dropped_file);
nautilus_file_unref (target_file);
/* Compare the first dropped uri with the target uri for same fs match. */
dropped = g_file_new_for_uri (dropped_uri);
- same_fs = check_same_fs (target, dropped);
target_is_source_parent = g_file_has_prefix (dropped, target);
if (same_fs || target_is_source_parent ||
diff --git a/libnautilus-private/nautilus-file-private.h b/libnautilus-private/nautilus-file-private.h
index 08e836850..fb4e7e3e6 100644
--- a/libnautilus-private/nautilus-file-private.h
+++ b/libnautilus-private/nautilus-file-private.h
@@ -46,7 +46,7 @@
GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS)
#define NAUTILUS_FILE_DEFAULT_ATTRIBUTES \
- "standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*"
+ "standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*,id::filesystem"
/* These are in the typical sort order. Known things come first, then
* things where we can't know, finally things where we don't yet know.
@@ -115,6 +115,11 @@ struct NautilusFileDetails
char *custom_icon;
GFile *activation_location;
+ /* used during DND, for checking whether source and destination are on
+ * the same file system.
+ */
+ eel_ref_str filesystem_id;
+
/* The following is for file operations in progress. Since
* there are normally only a few of these, we can move them to
* a separate hash table or something if required to keep the
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index e74e8540b..fe69391db 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -353,6 +353,9 @@ nautilus_file_clear_info (NautilusFile *file)
file->details->mime_type = NULL;
g_free (file->details->selinux_context);
file->details->selinux_context = NULL;
+
+ eel_ref_str_unref (file->details->filesystem_id);
+ file->details->filesystem_id = NULL;
}
static NautilusFile *
@@ -674,6 +677,8 @@ finalize (GObject *object)
if (file->details->mount) {
g_object_unref (file->details->mount);
}
+
+ eel_ref_str_unref (file->details->filesystem_id);
eel_g_list_free_deep (file->details->mime_list);
@@ -1555,6 +1560,7 @@ update_info_internal (NautilusFile *file,
GFile *old_activation_location;
const char *activation_uri;
const char *description;
+ const char *filesystem_id;
if (file->details->is_gone) {
return FALSE;
@@ -1819,6 +1825,13 @@ update_info_internal (NautilusFile *file,
g_free (file->details->description);
file->details->description = g_strdup (description);
}
+
+ filesystem_id = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_ID_FILESYSTEM);
+ if (eel_strcmp (file->details->filesystem_id, filesystem_id) != 0) {
+ changed = TRUE;
+ eel_ref_str_unref (file->details->filesystem_id);
+ file->details->filesystem_id = eel_ref_str_get_unique (filesystem_id);
+ }
if (update_name) {
name = g_file_info_get_name (info);
@@ -6125,6 +6138,12 @@ nautilus_file_get_top_left_text (NautilusFile *file)
return g_strdup (nautilus_file_peek_top_left_text (file, FALSE, NULL));
}
+char *
+nautilus_file_get_filesystem_id (NautilusFile *file)
+{
+ return g_strdup (eel_ref_str_peek (file->details->filesystem_id));
+}
+
void
nautilus_file_mark_gone (NautilusFile *file)
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index f09a68414..f52a4222b 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -225,6 +225,8 @@ void nautilus_file_set_attributes (Nautilu
gpointer callback_data);
GFilesystemPreviewType nautilus_file_get_filesystem_use_preview (NautilusFile *file);
+char * nautilus_file_get_filesystem_id (NautilusFile *file);
+
/* Permissions. */
gboolean nautilus_file_can_get_permissions (NautilusFile *file);
gboolean nautilus_file_can_set_permissions (NautilusFile *file);