summaryrefslogtreecommitdiff
path: root/Userland/Applications/FileManager
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-03-13 20:29:33 +0000
committerLinus Groh <mail@linusgroh.de>2023-03-24 22:06:38 +0000
commit2aa8c9950e92534a3fb1347629b7b019c388ddc4 (patch)
tree8d7dc0919b62430116c392dccbb3680e0e8c3952 /Userland/Applications/FileManager
parentd27a513dc534ecb39c9d8f64c6bf4f1fea274218 (diff)
downloadserenity-2aa8c9950e92534a3fb1347629b7b019c388ddc4.zip
FileManager: Use GUI::Process::spawn_or_show_error() to open terminals
Diffstat (limited to 'Userland/Applications/FileManager')
-rw-r--r--Userland/Applications/FileManager/DirectoryView.cpp19
-rw-r--r--Userland/Applications/FileManager/DirectoryView.h2
-rw-r--r--Userland/Applications/FileManager/main.cpp6
3 files changed, 8 insertions, 19 deletions
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp
index efb908d993..005c9fb650 100644
--- a/Userland/Applications/FileManager/DirectoryView.cpp
+++ b/Userland/Applications/FileManager/DirectoryView.cpp
@@ -19,6 +19,7 @@
#include <LibGUI/Label.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/ModelEditingDelegate.h>
+#include <LibGUI/Process.h>
#include <LibGUI/SortingProxyModel.h>
#include <serenity.h>
#include <spawn.h>
@@ -27,21 +28,9 @@
namespace FileManager {
-void spawn_terminal(DeprecatedString const& directory)
+void spawn_terminal(GUI::Window* window, StringView directory)
{
- posix_spawn_file_actions_t spawn_actions;
- posix_spawn_file_actions_init(&spawn_actions);
- posix_spawn_file_actions_addchdir(&spawn_actions, directory.characters());
-
- pid_t pid;
- char const* argv[] = { "Terminal", nullptr };
- if ((errno = posix_spawn(&pid, "/bin/Terminal", &spawn_actions, nullptr, const_cast<char**>(argv), environ))) {
- perror("posix_spawn");
- } else {
- if (disown(pid) < 0)
- perror("disown");
- }
- posix_spawn_file_actions_destroy(&spawn_actions);
+ GUI::Process::spawn_or_show_error(window, "/bin/Terminal"sv, ReadonlySpan<StringView> {}, directory);
}
NonnullRefPtr<GUI::Action> LauncherHandler::create_launch_action(Function<void(LauncherHandler const&)> launch_handler)
@@ -617,7 +606,7 @@ void DirectoryView::setup_actions()
});
m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
- spawn_terminal(path());
+ spawn_terminal(window(), path());
});
m_delete_action = GUI::CommonActions::make_delete_action([this](auto&) { do_delete(true); }, window());
diff --git a/Userland/Applications/FileManager/DirectoryView.h b/Userland/Applications/FileManager/DirectoryView.h
index b7e4ef9e4c..258ed959eb 100644
--- a/Userland/Applications/FileManager/DirectoryView.h
+++ b/Userland/Applications/FileManager/DirectoryView.h
@@ -21,7 +21,7 @@
namespace FileManager {
-void spawn_terminal(DeprecatedString const& directory);
+void spawn_terminal(GUI::Window* window, StringView directory);
class LauncherHandler : public RefCounted<LauncherHandler> {
public:
diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp
index 5b1edd1772..9a946bcbd4 100644
--- a/Userland/Applications/FileManager/main.cpp
+++ b/Userland/Applications/FileManager/main.cpp
@@ -491,13 +491,13 @@ ErrorOr<int> run_in_desktop_mode()
auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"sv)), [&](auto&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty()) {
- spawn_terminal(directory_view->path());
+ spawn_terminal(window, directory_view->path());
return;
}
for (auto& path : paths) {
if (FileSystem::is_directory(path)) {
- spawn_terminal(path);
+ spawn_terminal(window, path);
}
}
});
@@ -841,7 +841,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
for (auto& path : paths) {
if (FileSystem::is_directory(path)) {
- spawn_terminal(path);
+ spawn_terminal(window, path);
}
}
},