summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndres Vieira <anvieiravazquez@gmail.com>2020-04-26 18:20:57 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-28 10:00:12 +0200
commit1f007181be8bb86a954560783394cb1590c675fa (patch)
tree05d15ac01c526be424c25bdf87b41effed221103 /Applications
parenta1bcd9ca8aa345ec7c7573dfc3d9471366e73437 (diff)
downloadserenity-1f007181be8bb86a954560783394cb1590c675fa.zip
FileManager: Disable paste action for non-writable directories
Diffstat (limited to 'Applications')
-rw-r--r--Applications/FileManager/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index 3acdb42164..26fb7f040f 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -460,10 +460,10 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
}
},
window);
- paste_action->set_enabled(GUI::Clipboard::the().type() == "file-list");
GUI::Clipboard::the().on_content_change = [&](const String& data_type) {
- paste_action->set_enabled(data_type == "file-list");
+ auto current_location = directory_view.path();
+ paste_action->set_enabled(data_type == "file-list" && access(current_location.characters(), W_OK) == 0);
};
auto properties_action
@@ -662,6 +662,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
auto can_write_in_path = access(new_path.characters(), W_OK) == 0;
mkdir_action->set_enabled(can_write_in_path);
+ paste_action->set_enabled(can_write_in_path && GUI::Clipboard::the().type() == "file-list");
go_forward_action->set_enabled(directory_view.path_history_position() < directory_view.path_history_size() - 1);
go_back_action->set_enabled(directory_view.path_history_position() > 0);
open_parent_directory_action->set_enabled(new_path != "/");
@@ -801,6 +802,8 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
directory_view.open(initial_location);
directory_view.set_focus(true);
+ paste_action->set_enabled(GUI::Clipboard::the().type() == "file-list" && access(initial_location.characters(), W_OK) == 0);
+
window->show();
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-folder.png"));