From 365379bcb1f9233906bae0ace0daab540201695c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Nov 2021 23:25:23 +0100 Subject: [PATCH] Applets/Audio: Port to LibMain :^) --- Userland/Applets/Audio/CMakeLists.txt | 2 +- Userland/Applets/Audio/main.cpp | 35 +++++++++------------------ 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/Userland/Applets/Audio/CMakeLists.txt b/Userland/Applets/Audio/CMakeLists.txt index 0d5aa975910..4941e58b4c4 100644 --- a/Userland/Applets/Audio/CMakeLists.txt +++ b/Userland/Applets/Audio/CMakeLists.txt @@ -9,4 +9,4 @@ set(SOURCES ) serenity_app(Audio.Applet ICON audio-volume-high) -target_link_libraries(Audio.Applet LibGUI LibGfx LibAudio LibCore LibConfig) +target_link_libraries(Audio.Applet LibGUI LibGfx LibAudio LibCore LibConfig LibMain) diff --git a/Userland/Applets/Audio/main.cpp b/Userland/Applets/Audio/main.cpp index d0dc1b6fffc..21d790f0e9b 100644 --- a/Userland/Applets/Audio/main.cpp +++ b/Userland/Applets/Audio/main.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include class AudioWidget final : public GUI::Widget { C_OBJECT(AudioWidget) @@ -208,31 +210,19 @@ private: RefPtr m_root_container; }; -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio recvfd sendfd rpath wpath cpath unix", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio recvfd sendfd rpath wpath cpath unix", nullptr)); - auto app = GUI::Application::construct(argc, argv); - if (unveil("/tmp/portal/config", "rw") < 0) { - perror("unveil"); - return 1; - } - if (unveil("/tmp/portal/audio", "rw") < 0) { - perror("unveil"); - return 1; - } - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - unveil(nullptr, nullptr); + auto app = TRY(GUI::Application::try_create(arguments)); + TRY(Core::System::unveil("/tmp/portal/config", "rw")); + TRY(Core::System::unveil("/tmp/portal/audio", "rw")); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); Config::pledge_domains("AudioApplet"); - auto window = GUI::Window::construct(); + auto window = TRY(GUI::Window::try_create()); window->set_has_alpha_channel(true); window->set_title("Audio"); window->set_window_type(GUI::WindowType::Applet); @@ -243,10 +233,7 @@ int main(int argc, char** argv) // This positioning code depends on the window actually existing. static_cast(window->main_widget())->set_audio_widget_size(Config::read_bool("AudioApplet", "Applet", "ShowPercent", false)); - if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr)); return app->exec(); }