[PATCH] Use copy action by default when dragging from user-owned directory to directory owned by other users
- From: Christian Neumair <chris gnome-de org>
- To: nautilus-list gnome org
- Subject: [PATCH] Use copy action by default when dragging from user-owned directory to directory owned by other users
- Date: Thu, 20 Apr 2006 13:25:31 +0200
As discussed on IRC and under bug 339154 [1]. Proposed patch attached.
[1] http://bugzilla.gnome.org/show_bug.cgi?id=339154
--
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-dnd.c,v
retrieving revision 1.24
diff -u -p -r1.24 nautilus-dnd.c
--- libnautilus-private/nautilus-dnd.c 18 Mar 2006 07:13:49 -0000 1.24
+++ libnautilus-private/nautilus-dnd.c 20 Apr 2006 11:19:18 -0000
@@ -302,6 +302,26 @@ nautilus_drag_default_drop_action_for_ur
return context->suggested_action;
}
+static gboolean
+uri_is_user_owned (GnomeVFSURI *uri)
+{
+ gboolean user_owned;
+
+ user_owned = FALSE;
+
+ if (uri != NULL && !strcmp (gnome_vfs_uri_get_scheme (uri), "file")) {
+ GnomeVFSFileInfo *info;
+
+ info = gnome_vfs_file_info_new ();
+ if (gnome_vfs_get_file_info_uri (uri, info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS) == GNOME_VFS_OK) {
+ user_owned = (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_IDS) &&
+ geteuid () == info->uid;
+ }
+ gnome_vfs_file_info_unref (info);
+ }
+
+ return user_owned;
+}
void
nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
@@ -385,11 +405,12 @@ nautilus_drag_default_drop_action_for_ic
if (dropped_uri != NULL) {
gnome_vfs_check_same_fs_uris (dropped_uri, target_uri, &same_fs);
target_is_source_parent = gnome_vfs_uri_is_parent (target_uri, dropped_uri, FALSE);
- gnome_vfs_uri_unref (dropped_uri);
}
- gnome_vfs_uri_unref (target_uri);
-
- if (same_fs || target_is_source_parent) {
+
+ if ((same_fs || target_is_source_parent) &&
+ /* use copy by default when dragging from user-owned location
+ * to location owned by somebody else */
+ !(uri_is_user_owned (dropped_uri) && !uri_is_user_owned (target_uri))) {
if (actions & GDK_ACTION_MOVE) {
*action = GDK_ACTION_MOVE;
} else {
@@ -402,6 +423,15 @@ nautilus_drag_default_drop_action_for_ic
*action = context->suggested_action;
}
}
+
+ if (dropped_uri != NULL) {
+ gnome_vfs_uri_unref (dropped_uri);
+ }
+
+ if (target_uri != NULL) {
+ gnome_vfs_uri_unref (target_uri);
+ }
+
}
/* Encode a "x-special/gnome-icon-list" selection.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]