1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 15:37:46 +00:00

LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)

Rip that bandaid off!

This does the following, in one big, awkward jump:
- Replace all uses of `set_main_widget<Foo>()` with the `try` version.
- Remove `set_main_widget<Foo>()`.
- Rename the `try` version to just be `set_main_widget` because it's now
  the only one.

The majority of places that call `set_main_widget<Foo>()` are inside
constructors, so this unfortunately gives us a big batch of new
`release_value_but_fixme_should_propagate_errors()` calls.
This commit is contained in:
Sam Atkins 2023-01-06 16:48:37 +00:00 committed by Andrew Kaster
parent d223477bc6
commit 0c24522635
121 changed files with 441 additions and 449 deletions

View file

@ -62,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
advice_window->set_has_alpha_channel(true);
advice_window->set_alpha_hit_threshold(1.0f);
auto advice_widget = TRY(advice_window->try_set_main_widget<SpeechBubble>(catdog_widget));
auto advice_widget = TRY(advice_window->set_main_widget<SpeechBubble>(catdog_widget));
(void)TRY(advice_widget->try_set_layout<GUI::VerticalBoxLayout>());
advice_widget->layout()->set_spacing(0);

View file

@ -97,7 +97,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
})));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Eyes Demo", app_icon, window)));
auto eyes_widget = TRY(window->try_set_main_widget<EyesWidget>(num_eyes, full_rows, extra_columns));
auto eyes_widget = TRY(window->set_main_widget<EyesWidget>(num_eyes, full_rows, extra_columns));
eyes_widget->on_context_menu_request = [&](auto& event) {
file_menu->popup(event.screen_position());
};

View file

@ -97,7 +97,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = TRY(Desktop::Screensaver::create_window("Screensaver"sv, "app-screensaver"sv));
auto screensaver_window = TRY(window->try_set_main_widget<Screensaver>(64, 48, 10000));
auto screensaver_window = TRY(window->set_main_widget<Screensaver>(64, 48, 10000));
screensaver_window->set_fill_with_background_color(false);
screensaver_window->set_override_cursor(Gfx::StandardCursor::Hidden);
screensaver_window->update();

View file

@ -200,7 +200,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-libgfx-demo"sv));
window->set_icon(app_icon.bitmap_for_size(16));
(void)TRY(window->try_set_main_widget<Canvas>());
(void)TRY(window->set_main_widget<Canvas>());
window->show();
return app->exec();

View file

@ -121,7 +121,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-libgfx-demo"sv));
window->set_icon(app_icon.bitmap_for_size(16));
(void)TRY(window->try_set_main_widget<Canvas>());
(void)TRY(window->set_main_widget<Canvas>());
window->show();
return app->exec();

View file

@ -413,7 +413,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_obey_widget_min_size(false);
window->set_minimum_size(320, 240);
window->resize(window->minimum_size() * 2);
auto mandelbrot = TRY(window->try_set_main_widget<Mandelbrot>());
auto mandelbrot = TRY(window->set_main_widget<Mandelbrot>());
auto file_menu = TRY(window->try_add_menu("&File"));

View file

@ -28,7 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_title("Model Gallery");
window->set_icon(app_icon.bitmap_for_size(16));
window->resize(430, 480);
(void)TRY(window->try_set_main_widget<GalleryWidget>());
(void)TRY(window->set_main_widget<GalleryWidget>());
window->show();
return app->exec();

View file

@ -86,7 +86,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Screensaver", app_icon, window)));
auto main_widget = TRY(window->try_set_main_widget<GUI::Widget>());
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>();

View file

@ -167,7 +167,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = TRY(Desktop::Screensaver::create_window("Starfield"sv, "app-starfield"sv));
auto starfield_window = TRY(window->try_set_main_widget<Starfield>(refresh_rate));
auto starfield_window = TRY(window->set_main_widget<Starfield>(refresh_rate));
starfield_window->set_fill_with_background_color(false);
starfield_window->set_override_cursor(Gfx::StandardCursor::Hidden);
starfield_window->update();

View file

@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = TRY(Desktop::Screensaver::create_window("Tubes"sv, "app-tubes"sv));
window->update();
auto tubes_widget = TRY(window->try_set_main_widget<Tubes>(refresh_rate));
auto tubes_widget = TRY(window->set_main_widget<Tubes>(refresh_rate));
tubes_widget->set_fill_with_background_color(false);
tubes_widget->set_override_cursor(Gfx::StandardCursor::Hidden);
window->show();

View file

@ -28,7 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(430, 480);
window->set_title("Widget Gallery");
window->set_icon(app_icon.bitmap_for_size(16));
(void)TRY(window->try_set_main_widget<GalleryWidget>());
(void)TRY(window->set_main_widget<GalleryWidget>());
window->show();
return app->exec();