Commit ab67b661 authored by Christian Neumair's avatar Christian Neumair Committed by Christian Neumair

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
parent 8107598c
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):
......
......@@ -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 ||
......
......@@ -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
......
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment