]> git.pld-linux.org Git - packages/nautilus.git/blame - nautilus-dnd-user-owned.patch
- 2.20.0
[packages/nautilus.git] / nautilus-dnd-user-owned.patch
CommitLineData
b1fc7992 1Index: libnautilus-private/nautilus-dnd.c
2===================================================================
3RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-dnd.c,v
4retrieving revision 1.24
5diff -u -p -r1.24 nautilus-dnd.c
6--- libnautilus-private/nautilus-dnd.c 18 Mar 2006 07:13:49 -0000 1.24
7+++ libnautilus-private/nautilus-dnd.c 20 Apr 2006 11:19:18 -0000
8@@ -302,6 +302,26 @@ nautilus_drag_default_drop_action_for_ur
9 return context->suggested_action;
10 }
11
12+static gboolean
13+uri_is_user_owned (GnomeVFSURI *uri)
14+{
15+ gboolean user_owned;
16+
17+ user_owned = FALSE;
18+
19+ if (uri != NULL && !strcmp (gnome_vfs_uri_get_scheme (uri), "file")) {
20+ GnomeVFSFileInfo *info;
21+
22+ info = gnome_vfs_file_info_new ();
23+ if (gnome_vfs_get_file_info_uri (uri, info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS) == GNOME_VFS_OK) {
24+ user_owned = (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_IDS) &&
25+ geteuid () == info->uid;
26+ }
27+ gnome_vfs_file_info_unref (info);
28+ }
29+
30+ return user_owned;
31+}
32
33 void
34 nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
35@@ -385,11 +405,12 @@ nautilus_drag_default_drop_action_for_ic
36 if (dropped_uri != NULL) {
37 gnome_vfs_check_same_fs_uris (dropped_uri, target_uri, &same_fs);
38 target_is_source_parent = gnome_vfs_uri_is_parent (target_uri, dropped_uri, FALSE);
39- gnome_vfs_uri_unref (dropped_uri);
40 }
41- gnome_vfs_uri_unref (target_uri);
42-
43- if (same_fs || target_is_source_parent) {
44+
45+ if ((same_fs || target_is_source_parent) &&
46+ /* use copy by default when dragging from user-owned location
47+ * to location owned by somebody else */
48+ !(uri_is_user_owned (dropped_uri) && !uri_is_user_owned (target_uri))) {
49 if (actions & GDK_ACTION_MOVE) {
50 *action = GDK_ACTION_MOVE;
51 } else {
52@@ -402,6 +423,15 @@ nautilus_drag_default_drop_action_for_ic
53 *action = context->suggested_action;
54 }
55 }
56+
57+ if (dropped_uri != NULL) {
58+ gnome_vfs_uri_unref (dropped_uri);
59+ }
60+
61+ if (target_uri != NULL) {
62+ gnome_vfs_uri_unref (target_uri);
63+ }
64+
65 }
66
67 /* Encode a "x-special/gnome-icon-list" selection.
This page took 0.103664 seconds and 4 git commands to generate.