mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-05 10:42:51 +00:00
FileManager: Disable paste action for non-writable directories
This commit is contained in:
parent
a1bcd9ca8a
commit
1f007181be
Notes:
sideshowbarker
2024-07-19 07:14:25 +09:00
Author: https://github.com/zlotny
Commit: 1f007181be
Pull-request: https://github.com/SerenityOS/serenity/pull/1967
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/sunverwerth
1 changed files with 5 additions and 2 deletions
|
@ -460,10 +460,10 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
window);
|
window);
|
||||||
paste_action->set_enabled(GUI::Clipboard::the().type() == "file-list");
|
|
||||||
|
|
||||||
GUI::Clipboard::the().on_content_change = [&](const String& data_type) {
|
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
|
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;
|
auto can_write_in_path = access(new_path.characters(), W_OK) == 0;
|
||||||
mkdir_action->set_enabled(can_write_in_path);
|
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_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);
|
go_back_action->set_enabled(directory_view.path_history_position() > 0);
|
||||||
open_parent_directory_action->set_enabled(new_path != "/");
|
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.open(initial_location);
|
||||||
directory_view.set_focus(true);
|
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->show();
|
||||||
|
|
||||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-folder.png"));
|
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-folder.png"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue