From 3fab5a881a6cc7f05f509d0969900aabb68b9c5f Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sun, 1 Mar 2026 10:37:20 +0000 Subject: [PATCH 1/2] Add warnings during check file actions --- libcore/DndHandler.vala | 16 ++++++++++++++++ src/View/AbstractDirectoryView.vala | 10 +++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libcore/DndHandler.vala b/libcore/DndHandler.vala index 7b974887a..32b3cea8b 100644 --- a/libcore/DndHandler.vala +++ b/libcore/DndHandler.vala @@ -355,36 +355,44 @@ namespace Files { Gdk.DragAction possible_actions, out Gdk.DragAction suggested_action_return) { + warning ("checking file accepts drop"); var actions = possible_actions; var suggested_action = selected_action; var target_location = dest.get_target_location (); suggested_action_return = Gdk.DragAction.PRIVATE; if (drop_file_list == null || drop_file_list.data == null) { + warning ("drop file list empty - return DEFAULT"); return Gdk.DragAction.DEFAULT; } if (dest.is_folder ()) { if (!dest.is_writable ()) { + warning ("Folder not writable - return DEFAULT"); actions = Gdk.DragAction.DEFAULT; } else { + warning ("target is writable folder - check valid actions"); /* Modify actions and suggested_action according to source files */ actions &= valid_actions_for_file_list (target_location, drop_file_list, ref suggested_action); } } else if (dest.is_executable ()) { + warning ("target is executable file - actions |= COPY|MOVE|LINK|PRIVATE"); actions |= (Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK | Gdk.DragAction.PRIVATE); } else { + warning ("target is not a valid DnD target - not folder and not executable"); actions = Gdk.DragAction.DEFAULT; } if (actions == Gdk.DragAction.DEFAULT) { // No point asking if no other valid actions + warning ("Cannot accept drop - return now"); return Gdk.DragAction.DEFAULT; } else if (FileUtils.location_is_in_trash (target_location)) { // cannot copy or link to trash + warning ("target is trash - cannot copy or link"); actions &= ~(Gdk.DragAction.COPY | Gdk.DragAction.LINK); } @@ -400,6 +408,7 @@ namespace Files { suggested_action_return = Gdk.DragAction.MOVE; } + warning ("actions - %s, suggested - %s", actions.to_string (), suggested_action_return.to_string ()); return actions; } @@ -408,6 +417,7 @@ namespace Files { GLib.List drop_file_list, ref Gdk.DragAction suggested_action) { + warning ("checking valid actions for file list"); var valid_actions = Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY | Gdk.DragAction.MOVE | @@ -427,6 +437,7 @@ namespace Files { from_trash = true; if (FileUtils.location_is_in_trash (target_location)) { + warning ("file in trash - cannot DnD"); valid_actions = Gdk.DragAction.DEFAULT; // No DnD within trash } } @@ -434,17 +445,20 @@ namespace Files { var parent = drop_file.get_parent (); if (parent != null && parent.equal (target_location)) { + warning ("file in destination - only LINK"); valid_actions &= Gdk.DragAction.LINK; // Only LINK is valid } var scheme = drop_file.get_uri_scheme (); if (scheme == null || !scheme.has_prefix ("file")) { + warning ("file not local - cannot LINK"); valid_actions &= ~(Gdk.DragAction.LINK); // Can only LINK local files } if (++count > MAX_FILES_CHECKED || valid_actions == Gdk.DragAction.DEFAULT) { + warning ("No valid action for file - stop checking files"); break; } } @@ -457,6 +471,7 @@ namespace Files { suggested_action == Gdk.DragAction.COPY && (from_trash || FileUtils.same_file_system (drop_file_list.first ().data, target_location))) { + warning ("Same filesystem - suggesting MOVE"); suggested_action = Gdk.DragAction.MOVE; } @@ -464,6 +479,7 @@ namespace Files { valid_actions |= Gdk.DragAction.ASK; // Allow ASK if there is a possible action } + warning ("valid actions - %s", valid_actions.to_string ()); return valid_actions; } } diff --git a/src/View/AbstractDirectoryView.vala b/src/View/AbstractDirectoryView.vala index 2b3234cfe..9960ae5a1 100644 --- a/src/View/AbstractDirectoryView.vala +++ b/src/View/AbstractDirectoryView.vala @@ -1420,6 +1420,7 @@ namespace Files { Idle.add (() => { empty_label.visible = slot.directory.is_empty (); thaw_tree (); +warning ("tree thawed"); schedule_thumbnail_color_tag_timeout (); return Source.REMOVE; }); @@ -1784,16 +1785,18 @@ namespace Files { string uri = drop_target_file != null ? drop_target_file.uri : ""; if (uri != current_uri) { + warning ("drop target has changed"); cancel_timeout (ref drag_enter_timer_id); current_actions = Gdk.DragAction.DEFAULT; current_suggested_action = Gdk.DragAction.DEFAULT; if (drop_target_file != null) { + warning ("have a target file - %s", drop_target_file.uri); if (current_target_type == Gdk.Atom.intern_static_string ("XdndDirectSave0")) { + warning ("XdndDirectSave0 - copy"); current_suggested_action = Gdk.DragAction.COPY; current_actions = current_suggested_action; } else { - current_actions = DndHandler.file_accepts_drop ( drop_target_file, destination_drop_file_list, @@ -1807,14 +1810,18 @@ namespace Files { if (drop_target_file.is_folder () && is_valid_drop_folder (drop_target_file)) { /* open the target folder after a short delay */ + warning ("starting folder enter timer"); drag_enter_timer_id = GLib.Timeout.add_full (GLib.Priority.LOW, 1000, () => { + warning ("loading location during DnD"); load_location (drop_target_file.get_target_location ()); drag_enter_timer_id = 0; return GLib.Source.REMOVE; }); + } else { + warning ("not a valid drop folder - cannot drop onto a file's parent or itself"); } } } @@ -1822,6 +1829,7 @@ namespace Files { private bool is_valid_drop_folder (Files.File file) { /* Cannot drop onto a file onto its parent or onto itself */ + /* We no longer implement link creation by dropping onto parent */ if (file.uri != slot.uri && source_drag_file_list != null && source_drag_file_list.index (file) < 0) { From 5530abce9058f0605c84f431ed8f7d37c88ab395 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sun, 1 Mar 2026 13:24:03 +0000 Subject: [PATCH 2/2] Fix drop onto breadcrumb --- src/View/Widgets/BreadcrumbsEntry.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/View/Widgets/BreadcrumbsEntry.vala b/src/View/Widgets/BreadcrumbsEntry.vala index 1479e8243..9322acb00 100644 --- a/src/View/Widgets/BreadcrumbsEntry.vala +++ b/src/View/Widgets/BreadcrumbsEntry.vala @@ -234,6 +234,7 @@ namespace Files.View.Chrome { Gdk.Atom target = Gtk.drag_dest_find_target (this, context, list); if (target != Gdk.Atom.NONE) { Gtk.drag_get_data (this, context, target, time); /* emits "drag_data_received" */ + return false; } }