[nautilus] list-base: Only allow MOVE on drag source when file can be deleted
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] list-base: Only allow MOVE on drag source when file can be deleted
- Date: Sat, 9 Jul 2022 17:55:17 +0000 (UTC)
commit be6145a89710e88eb9a5f8bbc02f9892a9da6efb
Author: Corey Berla <corey berla me>
Date: Thu Jul 7 12:59:22 2022 -0700
list-base: Only allow MOVE on drag source when file can be deleted
We are arbitrarily allowing all actions on the list-base DragSource.
The GDK_ACTION_MOVE should only be allowed if we can delete the file.
While iterating through the NautilusFile selection list, check
if any of the files cannot be deleted, and if so don't allow
GDK_ACTION_MOVE
src/nautilus-list-base.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index 152bb1455..6f48d0e25 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -519,14 +519,20 @@ on_item_drag_prepare (GtkDragSource *source,
gtk_gesture_set_state (GTK_GESTURE (source), GTK_EVENT_SEQUENCE_CLAIMED);
- /* Convert to GTK_TYPE_FILE_LIST, which is assumed to be a GSList<GFile>. */
+ actions = GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK | GDK_ACTION_MOVE;
+
for (GList *l = selection; l != NULL; l = l->next)
{
+ /* Convert to GTK_TYPE_FILE_LIST, which is assumed to be a GSList<GFile>. */
file_list = g_slist_prepend (file_list, nautilus_file_get_location (l->data));
+
+ if (!nautilus_file_can_delete (l->data))
+ {
+ actions &= ~GDK_ACTION_MOVE;
+ }
}
file_list = g_slist_reverse (file_list);
- actions = GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK | GDK_ACTION_MOVE;
gtk_drag_source_set_actions (source, actions);
scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]