diff options
author | Christian Neumair <cneumair@gnome.org> | 2008-07-20 12:45:12 +0000 |
---|---|---|
committer | Christian Neumair <cneumair@src.gnome.org> | 2008-07-20 12:45:12 +0000 |
commit | ab67b66116b204cfdbada6786e45ec8dc64305a3 (patch) | |
tree | 410bac876d8fc4a98a1bc49414a0561f6ac269a3 /libnautilus-private/nautilus-dnd.c | |
parent | 8107598c77d88be88cded2612a363731d9156709 (diff) | |
download | nautilus-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
Diffstat (limited to 'libnautilus-private/nautilus-dnd.c')
-rw-r--r-- | libnautilus-private/nautilus-dnd.c | 53 |
1 files changed, 17 insertions, 36 deletions
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 || |