Skip to content

Commit

Permalink
Do not accept drop on unmounted bookmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Wootten authored and Jeremy Wootten committed Feb 2, 2025
1 parent 3f2c1e1 commit 0cecac3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/View/Sidebar/BookmarkRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public class Sidebar.BookmarkRow : Gtk.ListBoxRow, SidebarItemInterface {

private bool valid = true; //Set to false if scheduled for removal
private Gtk.Image icon;
private Files.File target_file;
private List<GLib.File> drop_file_list = null;
private string? drop_text = null;
private bool drop_occurred = false;
private Gdk.DragAction? current_suggested_action = Gdk.DragAction.DEFAULT;
private Gtk.EventControllerKey key_controller;
private Gtk.GestureMultiPress button_controller;

protected Files.File? target_file = null;
protected Gtk.Grid content_grid;
protected Gtk.Grid icon_label_grid;
protected Gtk.Stack label_stack;
Expand Down Expand Up @@ -524,7 +524,7 @@ public class Sidebar.BookmarkRow : Gtk.ListBoxRow, SidebarItemInterface {
y > row_height - 1;

// When dropping onto a row, determine what actions are possible
if (!reveal && drop_file_list != null) {
if (target_file != null && !reveal && drop_file_list != null) {
Files.DndHandler.file_accepts_drop (
target_file,
drop_file_list,
Expand Down
7 changes: 7 additions & 0 deletions src/View/Sidebar/VolumeRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public class Sidebar.VolumeRow : Sidebar.AbstractMountableRow, SidebarItemInterf
if (drive_name != null && drive_name != "") {
custom_name = _("%s (%s)").printf (custom_name, drive_name);
}

if (mount == null) {
target_file = null;
}
}

construct {
Expand Down Expand Up @@ -120,13 +124,16 @@ public class Sidebar.VolumeRow : Sidebar.AbstractMountableRow, SidebarItemInterf
protected override void on_mount_added (Mount added_mount) {
if (added_mount == volume.get_mount ()) {
mount = volume.get_mount ();
target_file = Files.File.get (mount.get_root ());
target_file.ensure_query_info ();
update_visibilities ();
}
}

protected override void on_mount_removed (Mount removed_mount) {
if (volume.get_mount () == null) {
mount = null;
target_file = null;
update_visibilities ();
}
}
Expand Down

0 comments on commit 0cecac3

Please sign in to comment.