summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndres Vieira <anvieiravazquez@gmail.com>2020-04-27 18:24:19 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-28 10:00:12 +0200
commit1d874c03af840eee2be12884d3a20c402e75b577 (patch)
tree3408c86cb8d4b7d886ec3059f4aa71c9b0e8a387 /Applications
parent42f493ec9d03bc8e7831499e937e666fc2b19627 (diff)
downloadserenity-1d874c03af840eee2be12884d3a20c402e75b577.zip
FileManager: Disable delete action if user can't write in current path
Before this the delete action would be enabled in whenever was the case in which the user had some selection made. This patch forces a check to access() with the current folder path to see if the user actually can delete nodes in it.
Diffstat (limited to 'Applications')
-rw-r--r--Applications/FileManager/main.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index 87cb5d72d9..3bd9755e5c 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -702,8 +702,10 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
directory_view.on_selection_change = [&](GUI::AbstractView& view) {
// FIXME: Figure out how we can enable/disable the paste action, based on clipboard contents.
- copy_action->set_enabled(!view.selection().is_empty());
- delete_action->set_enabled(!view.selection().is_empty());
+ auto selection = view.selection();
+
+ delete_action->set_enabled(!selection.is_empty() && access(directory_view.path().characters(), W_OK) == 0);
+ copy_action->set_enabled(!selection.is_empty());
};
auto open_in_text_editor_action = GUI::Action::create("Open in TextEditor...", Gfx::Bitmap::load_from_file("/res/icons/TextEditor16.png"), [&](auto&) {