Taskbar: Use Process::spawn_or_show_error() to open the "Run" dialog

This commit is contained in:
MacDue 2023-03-13 20:34:50 +00:00 committed by Linus Groh
parent c9043280ec
commit e46b9c189e
Notes: sideshowbarker 2024-07-18 04:46:35 +09:00

View File

@ -250,22 +250,8 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
system_menu->add_action(GUI::Action::create("&Help", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-help.png"sv)), [&](auto&) {
GUI::Process::spawn_or_show_error(&window, "/bin/Help"sv);
}));
system_menu->add_action(GUI::Action::create("&Run...", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-run.png"sv)), [](auto&) {
posix_spawn_file_actions_t spawn_actions;
posix_spawn_file_actions_init(&spawn_actions);
auto home_directory = Core::StandardPaths::home_directory();
posix_spawn_file_actions_addchdir(&spawn_actions, home_directory.characters());
pid_t child_pid;
const char* argv[] = { "/bin/Run", nullptr };
if ((errno = posix_spawn(&child_pid, "/bin/Run", &spawn_actions, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
} else {
if (disown(child_pid) < 0)
perror("disown");
}
posix_spawn_file_actions_destroy(&spawn_actions);
system_menu->add_action(GUI::Action::create("&Run...", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-run.png"sv)), [&](auto&) {
GUI::Process::spawn_or_show_error(&window, "/bin/Run"sv, ReadonlySpan<StringView> {}, Core::StandardPaths::home_directory());
}));
system_menu->add_separator();
system_menu->add_action(GUI::Action::create("E&xit...", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/power.png"sv)), [](auto&) {