summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcaja-private/caja-dnd.c42
-rw-r--r--libcaja-private/caja-file-utilities.c36
-rw-r--r--libcaja-private/caja-file-utilities.h2
3 files changed, 66 insertions, 14 deletions
diff --git a/libcaja-private/caja-dnd.c b/libcaja-private/caja-dnd.c
index 7a16a8f5..08b11719 100644
--- a/libcaja-private/caja-dnd.c
+++ b/libcaja-private/caja-dnd.c
@@ -374,29 +374,43 @@ caja_drag_default_drop_action_for_netscape_url (GdkDragContext *context)
}
static gboolean
-check_same_fs (CajaFile *file1,
- CajaFile *file2)
+check_same_fs (const char *target_uri,
+ CajaFile *target_file,
+ const char *dropped_uri,
+ CajaFile *dropped_file)
{
gboolean result;
result = FALSE;
- if (file1 != NULL && file2 != NULL)
- {
- char *id1, *id2;
+ char *target_fs = NULL, *dropped_fs = NULL;
- id1 = caja_file_get_filesystem_id (file1);
- id2 = caja_file_get_filesystem_id (file2);
+ if (target_file != NULL)
+ {
+ target_fs = caja_file_get_filesystem_id (target_file);
+ }
+ if (target_fs == NULL)
+ {
+ target_fs = caja_get_filesystem_id_by_uri (target_uri, TRUE);
+ }
- if (id1 != NULL && id2 != NULL)
- {
- result = (strcmp (id1, id2) == 0);
- }
+ if (dropped_file != NULL && !caja_file_is_symbolic_link (dropped_file))
+ {
+ dropped_fs = caja_file_get_filesystem_id (dropped_file);
+ }
+ if (dropped_fs == NULL)
+ {
+ dropped_fs = caja_get_filesystem_id_by_uri (dropped_uri, FALSE);
+ }
- g_free (id1);
- g_free (id2);
+ if (target_fs != NULL && dropped_fs != NULL)
+ {
+ result = (strcmp (target_fs, dropped_fs) == 0);
}
+ g_free (target_fs);
+ g_free (dropped_fs);
+
return result;
}
@@ -519,7 +533,7 @@ caja_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);
+ same_fs = check_same_fs (target_uri_string, target_file, dropped_uri, dropped_file);
caja_file_unref (dropped_file);
caja_file_unref (target_file);
diff --git a/libcaja-private/caja-file-utilities.c b/libcaja-private/caja-file-utilities.c
index 2dae9794..688d7724 100644
--- a/libcaja-private/caja-file-utilities.c
+++ b/libcaja-private/caja-file-utilities.c
@@ -1299,6 +1299,42 @@ caja_restore_files_from_trash (GList *files,
caja_file_list_unref (unhandled_files);
}
+char *
+caja_get_filesystem_id_by_location (GFile *location, gboolean follow)
+{
+ GFileInfo *info;
+ GFileQueryInfoFlags flags;
+ char *filesystem_id = NULL;
+
+ if (follow) {
+ flags = G_FILE_QUERY_INFO_NONE;
+ } else {
+ flags = G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
+ }
+
+ info = g_file_query_info (location, G_FILE_ATTRIBUTE_ID_FILESYSTEM, flags, NULL, NULL);
+ if (info) {
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ID_FILESYSTEM)) {
+ filesystem_id = g_strdup (
+ g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_ID_FILESYSTEM));
+ }
+ g_object_unref (info);
+ }
+ return filesystem_id;
+}
+
+char *
+caja_get_filesystem_id_by_uri (const char *uri, gboolean follow)
+{
+ GFile *location;
+ char *filesystem_id;
+
+ location = g_file_new_for_uri (uri);
+ filesystem_id = caja_get_filesystem_id_by_location (location, follow);
+ g_object_unref (location);
+ return filesystem_id;
+}
+
#if !defined (CAJA_OMIT_SELF_CHECK)
void
diff --git a/libcaja-private/caja-file-utilities.h b/libcaja-private/caja-file-utilities.h
index 1a65fcb9..c29b527a 100644
--- a/libcaja-private/caja-file-utilities.h
+++ b/libcaja-private/caja-file-utilities.h
@@ -94,5 +94,7 @@ GHashTable * caja_trashed_files_get_original_directories (GList *files,
GList **unhandled_files);
void caja_restore_files_from_trash (GList *files,
GtkWindow *parent_window);
+char * caja_get_filesystem_id_by_location (GFile *location, gboolean follow);
+char * caja_get_filesystem_id_by_uri (const char *uri, gboolean follow);
#endif /* CAJA_FILE_UTILITIES_H */