WidgetGallery: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-23 15:20:11 +01:00
parent 24bf74a177
commit 3d126fe921
Notes: sideshowbarker 2024-07-18 00:48:01 +09:00
2 changed files with 13 additions and 36 deletions

View file

@ -27,4 +27,4 @@ set(SOURCES
)
serenity_app(WidgetGallery ICON app-widget-gallery)
target_link_libraries(WidgetGallery LibGUI)
target_link_libraries(WidgetGallery LibGUI LibMain)

View file

@ -1,53 +1,30 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "GalleryWidget.h"
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Window.h>
#include <unistd.h>
#include <LibMain/Main.h>
int main(int argc, char** argv)
ErrorOr<int> 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));