From 31867bed5c28667ccb247aacb1d3dabcde541388 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Nov 2021 23:16:12 +0100 Subject: [PATCH] KeyboardSettings: Port to LibMain :^) --- .../KeyboardSettings/CMakeLists.txt | 2 +- .../Applications/KeyboardSettings/main.cpp | 43 +++++-------------- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/Userland/Applications/KeyboardSettings/CMakeLists.txt b/Userland/Applications/KeyboardSettings/CMakeLists.txt index db79be722f..8a7ccbc475 100644 --- a/Userland/Applications/KeyboardSettings/CMakeLists.txt +++ b/Userland/Applications/KeyboardSettings/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_app(KeyboardSettings ICON app-keyboard-settings) -target_link_libraries(KeyboardSettings LibGUI LibKeyboard LibConfig) +target_link_libraries(KeyboardSettings LibGUI LibKeyboard LibConfig LibMain) diff --git a/Userland/Applications/KeyboardSettings/main.cpp b/Userland/Applications/KeyboardSettings/main.cpp index a85d126ca8..4e0da94d8b 100644 --- a/Userland/Applications/KeyboardSettings/main.cpp +++ b/Userland/Applications/KeyboardSettings/main.cpp @@ -6,51 +6,30 @@ */ #include "KeyboardSettingsWidget.h" +#include #include #include #include +#include // Including this after to avoid LibIPC errors #include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio rpath cpath wpath recvfd sendfd unix proc exec", nullptr) < 0) { - perror("pledge"); - return 1; - } - - auto app = GUI::Application::construct(argc, argv); + TRY(Core::System::pledge("stdio rpath cpath wpath recvfd sendfd unix proc exec", nullptr)); + auto app = TRY(GUI::Application::try_create(arguments)); Config::pledge_domains("KeyboardSettings"); - if (pledge("stdio rpath cpath wpath recvfd sendfd proc exec", nullptr) < 0) { - perror("pledge"); - return 1; - } - - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/bin/keymap", "x") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/proc/keymap", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil(nullptr, nullptr)) { - perror("unveil"); - return 1; - } + TRY(Core::System::pledge("stdio rpath cpath wpath recvfd sendfd proc exec", nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/bin/keymap", "x")); + TRY(Core::System::unveil("/proc/keymap", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-keyboard-settings"); - auto window = GUI::SettingsWindow::construct("Keyboard Settings"); + auto window = TRY(GUI::SettingsWindow::try_create("Keyboard Settings")); window->set_icon(app_icon.bitmap_for_size(16)); window->add_tab("Keyboard");