diff --git a/Base/res/devel/templates/serenity-application.postcreate b/Base/res/devel/templates/serenity-application.postcreate index d28ead888f..6ab49b224e 100644 --- a/Base/res/devel/templates/serenity-application.postcreate +++ b/Base/res/devel/templates/serenity-application.postcreate @@ -24,5 +24,5 @@ serenity_app($1 ICON filetype-executable) # You should place all the libraries that your application uses here. You can # identify each library by their include path. An exception is LibCore, which # is linked to all components by default. -target_link_libraries($1 LibGUI LibGfx) +target_link_libraries($1 LibGUI LibGfx LibMain) EOF diff --git a/Base/res/devel/templates/serenity-application/main.cpp b/Base/res/devel/templates/serenity-application/main.cpp index bcb7bb1669..ed6e442826 100644 --- a/Base/res/devel/templates/serenity-application/main.cpp +++ b/Base/res/devel/templates/serenity-application/main.cpp @@ -1,37 +1,33 @@ +#include #include #include #include #include #include +#include #include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio recvfd sendfd rpath wpath cpath unix", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio recvfd sendfd rpath wpath cpath unix")); - 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")); - auto window = GUI::Window::construct(); + auto window = TRY(GUI::Window::try_create()); window->set_title("Form1"); window->resize(96, 44); window->set_resizable(false); - auto& main_widget = window->set_main_widget(); - main_widget.set_fill_with_background_color(true); + auto main_widget = TRY(window->try_set_main_widget()); + main_widget->set_fill_with_background_color(true); - auto& layout = main_widget.set_layout(); - layout.set_margins(16); + auto layout = TRY(main_widget->try_set_layout()); + layout->set_margins(16); - auto& button = main_widget.add("Click me!"); - button.on_click = [&](auto) { + auto button = TRY(main_widget->try_add("Click me!")); + button->on_click = [&](auto) { GUI::MessageBox::show(window, "Hello friends!", ":^)"); };