summaryrefslogtreecommitdiff
path: root/Userland/Demos/LibGfxDemo
diff options
context:
space:
mode:
authorpbrw <borowski.pb1@gmail.com>2021-11-25 02:55:12 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-25 08:49:31 +0100
commitdee90b2dc31017822a51886e902f97d9f2b3a7ee (patch)
treef6bd11a28b2f06e5b96efd7ff29fc9764806dc7e /Userland/Demos/LibGfxDemo
parentabf86b750100cc97bef0703c0e675bd2c30e4c2b (diff)
downloadserenity-dee90b2dc31017822a51886e902f97d9f2b3a7ee.zip
LibGfxDemo: Use TRY() a lot more :^)
Diffstat (limited to 'Userland/Demos/LibGfxDemo')
-rw-r--r--Userland/Demos/LibGfxDemo/CMakeLists.txt2
-rw-r--r--Userland/Demos/LibGfxDemo/main.cpp31
2 files changed, 12 insertions, 21 deletions
diff --git a/Userland/Demos/LibGfxDemo/CMakeLists.txt b/Userland/Demos/LibGfxDemo/CMakeLists.txt
index 38307046ba..f2cdfe4daf 100644
--- a/Userland/Demos/LibGfxDemo/CMakeLists.txt
+++ b/Userland/Demos/LibGfxDemo/CMakeLists.txt
@@ -8,4 +8,4 @@ set(SOURCES
)
serenity_app(LibGfxDemo ICON app-libgfx-demo)
-target_link_libraries(LibGfxDemo LibGUI LibIPC LibGfx LibCore)
+target_link_libraries(LibGfxDemo LibGUI LibIPC LibGfx LibCore LibMain)
diff --git a/Userland/Demos/LibGfxDemo/main.cpp b/Userland/Demos/LibGfxDemo/main.cpp
index d406d43ea7..0910023373 100644
--- a/Userland/Demos/LibGfxDemo/main.cpp
+++ b/Userland/Demos/LibGfxDemo/main.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibCore/System.h>
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
#include <LibGUI/Icon.h>
@@ -16,6 +17,7 @@
#include <LibGfx/FontDatabase.h>
#include <LibGfx/Painter.h>
#include <LibGfx/Path.h>
+#include <LibMain/Main.h>
#include <unistd.h>
const int WIDTH = 780;
@@ -182,37 +184,26 @@ void Canvas::draw()
update();
}
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments arguments)
{
- auto app = GUI::Application::construct(argc, argv);
+ auto app = TRY(GUI::Application::try_create(arguments));
- if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr));
+ TRY(Core::System::unveil("/res", "r"));
+ TRY(Core::System::unveil(nullptr, nullptr));
- if (unveil("/res", "r") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil(nullptr, nullptr) < 0) {
- perror("unveil");
- return 1;
- }
-
- auto window = GUI::Window::construct();
+ auto window = TRY(GUI::Window::try_create());
window->set_double_buffering_enabled(true);
window->set_title("LibGfx Demo");
window->set_resizable(false);
window->resize(WIDTH, HEIGHT);
- auto& file_menu = window->add_menu("&File");
- file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
+ auto file_menu = TRY(window->try_add_menu("&File"));
+ TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })));
auto app_icon = GUI::Icon::default_icon("app-libgfx-demo");
window->set_icon(app_icon.bitmap_for_size(16));
- window->set_main_widget<Canvas>();
+ TRY(window->try_set_main_widget<Canvas>());
window->show();
return app->exec();