From 3d126fe921eeaed269d408a5fb8b1f757afaca21 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Nov 2021 15:20:11 +0100 Subject: [PATCH] WidgetGallery: Port to LibMain :^) --- Userland/Demos/WidgetGallery/CMakeLists.txt | 2 +- Userland/Demos/WidgetGallery/main.cpp | 47 ++++++--------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/Userland/Demos/WidgetGallery/CMakeLists.txt b/Userland/Demos/WidgetGallery/CMakeLists.txt index 8afdf67022..71d1e410c8 100644 --- a/Userland/Demos/WidgetGallery/CMakeLists.txt +++ b/Userland/Demos/WidgetGallery/CMakeLists.txt @@ -27,4 +27,4 @@ set(SOURCES ) serenity_app(WidgetGallery ICON app-widget-gallery) -target_link_libraries(WidgetGallery LibGUI) +target_link_libraries(WidgetGallery LibGUI LibMain) diff --git a/Userland/Demos/WidgetGallery/main.cpp b/Userland/Demos/WidgetGallery/main.cpp index 4f92b13ada..539dbd3a32 100644 --- a/Userland/Demos/WidgetGallery/main.cpp +++ b/Userland/Demos/WidgetGallery/main.cpp @@ -1,53 +1,30 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2021, Andreas Kling * Copyright (c) 2020, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #include "GalleryWidget.h" +#include #include #include #include -#include +#include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio recvfd sendfd rpath unix thread", nullptr) < 0) { - perror("pledge"); - return 1; - } - - auto app = GUI::Application::construct(argc, argv); - - if (pledge("stdio recvfd sendfd rpath thread", nullptr) < 0) { - perror("pledge"); - return 1; - } - - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/home/anon", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/etc/FileIconProvider.ini", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil(nullptr, nullptr) < 0) { - perror("unveil"); - return 1; - } + TRY(Core::System::pledge("stdio recvfd sendfd rpath unix thread", nullptr)); + auto app = TRY(GUI::Application::try_create(arguments)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath thread", nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/home/anon", "r")); + TRY(Core::System::unveil("/etc/FileIconProvider.ini", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-widget-gallery"); - auto window = GUI::Window::construct(); + auto window = TRY(GUI::Window::try_create()); window->resize(430, 480); window->set_title("Widget Gallery"); window->set_icon(app_icon.bitmap_for_size(16));