mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 00:08:11 +00:00
FileManager: Refresh tree view when deleting directories
Fixes #825 The logic already existed. I just moved it to a separate lambda then added it to the appropriate action. Note that when the tree view refreshes, it seems to randomly open trees. I would like to fix this in a separate PR.
This commit is contained in:
parent
6db11e5bba
commit
9a01e70ff9
1 changed files with 23 additions and 15 deletions
|
@ -96,21 +96,7 @@ int main(int argc, char** argv)
|
|||
directory_view->open(path);
|
||||
};
|
||||
|
||||
auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GAction&) {
|
||||
directory_view->open_parent_directory();
|
||||
});
|
||||
|
||||
auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GAction&) {
|
||||
auto input_box = GInputBox::construct("Enter name:", "New directory", window);
|
||||
if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) {
|
||||
auto new_dir_path = canonicalized_path(
|
||||
String::format("%s/%s",
|
||||
directory_view->path().characters(),
|
||||
input_box->text_value().characters()));
|
||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||
if (rc < 0) {
|
||||
GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
|
||||
} else {
|
||||
auto refresh_tree_view = [&] {
|
||||
file_system_model->update();
|
||||
|
||||
auto current_path = directory_view->path();
|
||||
|
@ -126,6 +112,24 @@ int main(int argc, char** argv)
|
|||
tree_view->update();
|
||||
|
||||
directory_view->refresh();
|
||||
};
|
||||
|
||||
auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GAction&) {
|
||||
directory_view->open_parent_directory();
|
||||
});
|
||||
|
||||
auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GAction&) {
|
||||
auto input_box = GInputBox::construct("Enter name:", "New directory", window);
|
||||
if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) {
|
||||
auto new_dir_path = canonicalized_path(
|
||||
String::format("%s/%s",
|
||||
directory_view->path().characters(),
|
||||
input_box->text_value().characters()));
|
||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||
if (rc < 0) {
|
||||
GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
|
||||
} else {
|
||||
refresh_tree_view();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -263,6 +267,8 @@ int main(int argc, char** argv)
|
|||
GMessageBox::InputType::OK,
|
||||
window);
|
||||
break;
|
||||
} else {
|
||||
refresh_tree_view();
|
||||
}
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
|
@ -277,6 +283,8 @@ int main(int argc, char** argv)
|
|||
GMessageBox::InputType::OK,
|
||||
window);
|
||||
break;
|
||||
} else {
|
||||
refresh_tree_view();
|
||||
}
|
||||
} else if (unlink(path.characters()) < 0) {
|
||||
int saved_errno = errno;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue