summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Demos/Fire/CMakeLists.txt2
-rw-r--r--Userland/Demos/Fire/Fire.cpp39
2 files changed, 16 insertions, 25 deletions
diff --git a/Userland/Demos/Fire/CMakeLists.txt b/Userland/Demos/Fire/CMakeLists.txt
index 31e7aaf90f..67480837c4 100644
--- a/Userland/Demos/Fire/CMakeLists.txt
+++ b/Userland/Demos/Fire/CMakeLists.txt
@@ -8,4 +8,4 @@ set(SOURCES
)
serenity_app(Fire ICON app-fire)
-target_link_libraries(Fire LibGUI LibCore LibGfx)
+target_link_libraries(Fire LibGUI LibCore LibGfx LibMain)
diff --git a/Userland/Demos/Fire/Fire.cpp b/Userland/Demos/Fire/Fire.cpp
index 7e9fdbc155..63f98edd5c 100644
--- a/Userland/Demos/Fire/Fire.cpp
+++ b/Userland/Demos/Fire/Fire.cpp
@@ -23,6 +23,7 @@
*/
#include <LibCore/ElapsedTimer.h>
+#include <LibCore/System.h>
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
#include <LibGUI/Frame.h>
@@ -33,6 +34,7 @@
#include <LibGUI/Painter.h>
#include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h>
+#include <LibMain/Main.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -195,40 +197,29 @@ void Fire::mouseup_event(GUI::MouseEvent& event)
return GUI::Widget::mouseup_event(event);
}
-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;
- }
-
- if (unveil("/res", "r") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil(nullptr, nullptr) < 0) {
- perror("unveil");
- return 1;
- }
+ TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr));
+ TRY(Core::System::unveil("/res", "r"));
+ TRY(Core::System::unveil(nullptr, nullptr));
- auto window = GUI::Window::construct();
+ auto window = TRY(GUI::Window::try_create());
window->set_double_buffering_enabled(false);
window->set_title("Fire");
window->set_resizable(false);
window->resize(FIRE_WIDTH * 2 + 4, FIRE_HEIGHT * 2 + 4);
- 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& fire = window->set_main_widget<Fire>();
+ auto fire = TRY(window->try_set_main_widget<Fire>());
- auto& time = fire.add<GUI::Label>();
- time.set_relative_rect({ 0, 4, 40, 10 });
- time.move_by({ window->width() - time.width(), 0 });
- fire.set_stat_label(time);
+ auto time = TRY(fire->try_add<GUI::Label>());
+ time->set_relative_rect({ 0, 4, 40, 10 });
+ time->move_by({ window->width() - time->width(), 0 });
+ fire->set_stat_label(time);
window->show();