1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:07:34 +00:00

Userland: Make Window::set_main_widget() non-fallible

This commit is contained in:
Tim Ledbetter 2023-09-19 01:13:48 +01:00 committed by Andreas Kling
parent c9297126db
commit 3aa49f268c
120 changed files with 144 additions and 133 deletions

View file

@ -362,7 +362,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(640 + 4, 480 + 4);
window->set_resizable(false);
window->set_double_buffering_enabled(true);
auto widget = TRY(window->set_main_widget<GLContextWidget>());
auto widget = window->set_main_widget<GLContextWidget>();
auto& time = widget->add<GUI::Label>();
time.set_visible(false);

View file

@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
window->resize(170, 170);
window->set_resizable(false);
auto clock = TRY(window->set_main_widget<AnalogClock>());
auto clock = window->set_main_widget<AnalogClock>();
auto show_window_frame_action = GUI::Action::create_checkable(
"Show Window &Frame", { Mod_Alt, KeyCode::Key_F }, [&](auto& action) {

View file

@ -174,7 +174,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
Assistant::Database db { app_state, providers };
auto container = TRY(window->set_main_widget<GUI::Frame>());
auto container = window->set_main_widget<GUI::Frame>();
container->set_fill_with_background_color(true);
container->set_frame_style(Gfx::FrameStyle::Window);
container->set_layout<GUI::VerticalBoxLayout>(8);

View file

@ -53,7 +53,7 @@ private:
BookmarkEditor(Window* parent_window, StringView title, StringView url)
: Dialog(parent_window)
{
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<GUI::Widget>();
widget->load_from_gml(edit_bookmark_gml).release_value_but_fixme_should_propagate_errors();
set_resizable(false);

View file

@ -68,7 +68,7 @@ BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, URL url)
set_icon(app_icon.bitmap_for_size(16));
set_title("Ladybird");
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<GUI::Widget>();
widget->load_from_gml(browser_window_gml).release_value_but_fixme_should_propagate_errors();
auto& top_line = *widget->find_descendant_of_type_named<GUI::HorizontalSeparator>("top_line");

View file

@ -71,14 +71,14 @@ void Tab::start_download(const URL& url)
window->resize(300, 170);
window->set_title(DeprecatedString::formatted("0% of {}", url.basename()));
window->set_resizable(false);
(void)window->set_main_widget<DownloadWidget>(url).release_value_but_fixme_should_propagate_errors();
(void)window->set_main_widget<DownloadWidget>(url);
window->show();
}
void Tab::view_source(const URL& url, DeprecatedString const& source)
{
auto window = GUI::Window::construct(&this->window());
auto editor = window->set_main_widget<GUI::TextEditor>().release_value_but_fixme_should_propagate_errors();
auto editor = window->set_main_widget<GUI::TextEditor>();
editor->set_text(source);
editor->set_mode(GUI::TextEditor::ReadOnly);
editor->set_syntax_highlighter(make<Web::HTML::SyntaxHighlighter>());
@ -877,7 +877,7 @@ void Tab::show_inspector_window(Browser::Tab::InspectorTarget inspector_target)
window->on_close = [&]() {
m_web_content_view->clear_inspected_dom_node();
};
m_dom_inspector_widget = window->set_main_widget<InspectorWidget>().release_value_but_fixme_should_propagate_errors();
m_dom_inspector_widget = window->set_main_widget<InspectorWidget>();
m_dom_inspector_widget->set_web_view(*m_web_content_view);
m_web_content_view->inspect_dom_tree();
m_web_content_view->inspect_accessibility_tree();
@ -918,7 +918,7 @@ void Tab::show_console_window()
console_window->set_title("JS Console");
console_window->set_icon(g_icon_bag.filetype_javascript);
m_console_widget = MUST(console_window->set_main_widget<ConsoleWidget>(view()));
m_console_widget = console_window->set_main_widget<ConsoleWidget>(view());
}
auto* window = m_console_widget->window();
@ -933,7 +933,7 @@ void Tab::show_storage_inspector()
storage_window->resize(500, 300);
storage_window->set_title("Storage Inspector");
storage_window->set_icon(g_icon_bag.cookie);
m_storage_widget = storage_window->set_main_widget<StorageWidget>().release_value_but_fixme_should_propagate_errors();
m_storage_widget = storage_window->set_main_widget<StorageWidget>();
m_storage_widget->on_update_cookie = [this](Web::Cookie::Cookie cookie) {
if (on_update_cookie)
on_update_cookie(move(cookie));
@ -970,7 +970,7 @@ void Tab::show_history_inspector()
history_window->resize(500, 300);
history_window->set_title("History");
history_window->set_icon(g_icon_bag.history);
m_history_widget = history_window->set_main_widget<HistoryWidget>().release_value_but_fixme_should_propagate_errors();
m_history_widget = history_window->set_main_widget<HistoryWidget>();
}
m_history_widget->clear_history_entries();

View file

@ -35,7 +35,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_resizable(false);
window->resize(250, 215);
auto widget = TRY(window->set_main_widget<CalculatorWidget>());
auto widget = window->set_main_widget<CalculatorWidget>();
window->set_icon(app_icon.bitmap_for_size(16));

View file

@ -33,7 +33,7 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, EventManager& event_man
m_date_time = Core::DateTime::create(m_date_time.year(), m_date_time.month(), m_date_time.day(), 12, 0);
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<GUI::Widget>();
widget->set_fill_with_background_color(true);
widget->set_layout<GUI::VerticalBoxLayout>();

View file

@ -86,7 +86,7 @@ CharacterMapWidget::CharacterMapWidget()
m_find_glyphs_action = GUI::Action::create("&Find Glyphs...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
if (m_find_window.is_null()) {
m_find_window = GUI::Window::construct(window());
auto search_widget = m_find_window->set_main_widget<CharacterSearchWidget>().release_value_but_fixme_should_propagate_errors();
auto search_widget = m_find_window->set_main_widget<CharacterSearchWidget>();
search_widget->on_character_selected = [&](auto code_point) {
m_glyph_map->set_active_glyph(code_point);
m_glyph_map->scroll_to_glyph(code_point);

View file

@ -69,7 +69,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
window->resize(600, 400);
auto character_map_widget = TRY(window->set_main_widget<CharacterMapWidget>());
auto character_map_widget = window->set_main_widget<CharacterMapWidget>();
TRY(character_map_widget->initialize_menubar(*window));
auto font_query = Config::read_string("CharacterMap"sv, "History"sv, "Font"sv, Gfx::FontDatabase::the().default_font_query());

View file

@ -202,7 +202,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
unlink_coredump(coredump_path);
};
auto widget = TRY(window->set_main_widget<GUI::Widget>());
auto widget = window->set_main_widget<GUI::Widget>();
TRY(widget->load_from_gml(crash_reporter_window_gml));
auto& icon_image_widget = *widget->find_descendant_of_type_named<GUI::ImageWidget>("icon");

View file

@ -36,7 +36,7 @@ EscalatorWindow::EscalatorWindow(StringView executable, Vector<StringView> argum
set_resizable(false);
set_minimizable(false);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->load_from_gml(escalator_gml).release_value_but_fixme_should_propagate_errors();
RefPtr<GUI::Label> app_label = *main_widget->find_descendant_of_type_named<GUI::Label>("description");

View file

@ -101,7 +101,7 @@ ErrorOr<void> run_file_operation(FileOperation operation, Vector<DeprecatedStrin
auto pipe_input_file = TRY(Core::File::adopt_fd(pipe_fds[0], Core::File::OpenMode::Read));
auto buffered_pipe = TRY(Core::InputBufferedFile::create(move(pipe_input_file)));
(void)TRY(window->set_main_widget<FileOperationProgressWidget>(operation, move(buffered_pipe), pipe_fds[0]));
(void)window->set_main_widget<FileOperationProgressWidget>(operation, move(buffered_pipe), pipe_fds[0]);
window->resize(320, 190);
if (parent_window)
window->center_within(*parent_window);

View file

@ -70,7 +70,7 @@ PropertiesWindow::PropertiesWindow(DeprecatedString const& path, Window* parent_
ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename)
{
auto main_widget = TRY(set_main_widget<GUI::Widget>());
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->set_layout<GUI::VerticalBoxLayout>(4, 6);
main_widget->set_fill_with_background_color(true);

View file

@ -387,7 +387,7 @@ ErrorOr<int> run_in_desktop_mode()
auto desktop_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/desktop.png"sv));
window->set_icon(desktop_icon);
auto desktop_widget = TRY(window->set_main_widget<FileManager::DesktopWidget>());
auto desktop_widget = window->set_main_widget<FileManager::DesktopWidget>();
desktop_widget->set_layout<GUI::VerticalBoxLayout>();
auto directory_view = TRY(desktop_widget->try_add<DirectoryView>(DirectoryView::Mode::Desktop));
@ -609,7 +609,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
auto window = GUI::Window::construct();
window->set_title("File Manager");
auto widget = TRY(window->set_main_widget<GUI::Widget>());
auto widget = window->set_main_widget<GUI::Widget>();
TRY(widget->load_from_gml(file_manager_window_gml));
auto& toolbar_container = *widget->find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");

View file

@ -82,7 +82,7 @@ ErrorOr<RefPtr<GUI::Window>> MainWidget::create_preview_window()
window->resize(400, 150);
window->center_within(*this->window());
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
auto main_widget = window->set_main_widget<GUI::Widget>();
TRY(main_widget->load_from_gml(font_preview_window_gml));
m_preview_label = find_descendant_of_type_named<GUI::Label>("preview_label");

View file

@ -45,7 +45,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
window->resize(640, 470);
auto font_editor = TRY(window->set_main_widget<FontEditor::MainWidget>());
auto font_editor = TRY(FontEditor::MainWidget::try_create());
window->set_main_widget(font_editor);
TRY(font_editor->initialize_menubar(*window));
font_editor->reset();

View file

@ -60,7 +60,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_title("Help");
window->resize(570, 500);
auto main_widget = TRY(window->set_main_widget<MainWidget>());
auto main_widget = TRY(MainWidget::try_create());
window->set_main_widget(main_widget);
TRY(main_widget->initialize_fallibles(window));
TRY(main_widget->set_start_page(query_parameters));

View file

@ -99,7 +99,7 @@ FindDialog::FindDialog()
set_resizable(false);
set_title("Find");
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->load_from_gml(find_dialog_gml).release_value_but_fixme_should_propagate_errors();
m_text_editor = *main_widget->find_descendant_of_type_named<GUI::TextBox>("text_editor");

View file

@ -96,7 +96,7 @@ GoToOffsetDialog::GoToOffsetDialog()
set_resizable(false);
set_title("Go to Offset");
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->load_from_gml(go_to_offset_dialog_gml).release_value_but_fixme_should_propagate_errors();
m_text_editor = *main_widget->find_descendant_of_type_named<GUI::TextBox>("text_editor");

View file

@ -36,7 +36,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_title("Hex Editor");
window->resize(640, 400);
auto hex_editor_widget = TRY(window->set_main_widget<HexEditorWidget>());
auto hex_editor_widget = window->set_main_widget<HexEditorWidget>();
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
if (hex_editor_widget->request_close())

View file

@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
window->set_title("Image Viewer");
auto root_widget = TRY(window->set_main_widget<MainWidget>());
auto root_widget = window->set_main_widget<MainWidget>();
auto toolbar_container = TRY(root_widget->try_add<GUI::ToolbarContainer>());
auto main_toolbar = TRY(toolbar_container->try_add<GUI::Toolbar>());

View file

@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = GUI::Window::construct();
window->set_title("Keyboard Mapper");
window->set_icon(app_icon.bitmap_for_size(16));
auto keyboard_mapper_widget = TRY(window->set_main_widget<KeyboardMapperWidget>());
auto keyboard_mapper_widget = window->set_main_widget<KeyboardMapperWidget>();
window->resize(775, 315);
window->set_resizable(false);

View file

@ -52,7 +52,7 @@ private:
KeymapSelectionDialog(Window* parent_window, Vector<DeprecatedString> const& selected_keymaps)
: Dialog(parent_window)
{
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<GUI::Widget>();
widget->load_from_gml(keymap_dialog_gml).release_value_but_fixme_should_propagate_errors();
set_resizable(false);

View file

@ -59,7 +59,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(window_dimensions, window_dimensions);
window->set_minimizable(false);
window->set_icon(app_icon.bitmap_for_size(16));
auto magnifier = TRY(window->set_main_widget<MagnifierWidget>());
auto magnifier = window->set_main_widget<MagnifierWidget>();
auto file_menu = window->add_menu("&File"_string);
file_menu->add_action(GUI::CommonActions::make_save_as_action([&](auto&) {

View file

@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = GUI::Icon::default_icon("app-mail"sv);
window->set_icon(app_icon.bitmap_for_size(16));
auto mail_widget = TRY(window->set_main_widget<MailWidget>());
auto mail_widget = window->set_main_widget<MailWidget>();
window->set_title("Mail");
window->resize(640, 400);

View file

@ -41,7 +41,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->save_size_and_position_on_close("Maps"sv, "Window"sv);
// Root widget
auto root_widget = TRY(window->set_main_widget<GUI::Widget>());
auto root_widget = window->set_main_widget<GUI::Widget>();
root_widget->set_fill_with_background_color(true);
root_widget->set_layout<GUI::VerticalBoxLayout>(GUI::Margins {}, 2);

View file

@ -39,7 +39,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto pdf_viewer_widget = TRY(window->set_main_widget<PDFViewerWidget>());
auto pdf_viewer_widget = window->set_main_widget<PDFViewerWidget>();
TRY(pdf_viewer_widget->initialize_menubar(*window));

View file

@ -58,7 +58,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return Error::from_string_view(error_message);
}
auto widget = TRY(window->set_main_widget<GUI::Widget>());
auto widget = window->set_main_widget<GUI::Widget>();
TRY(widget->load_from_gml(partition_editor_window_gml));
auto device_paths = get_device_paths();

View file

@ -20,7 +20,7 @@ ExportProgressWindow::ExportProgressWindow(GUI::Window& parent_window, Atomic<in
ErrorOr<void> ExportProgressWindow::initialize_fallibles()
{
auto main_widget = TRY(set_main_widget<GUI::Widget>());
auto main_widget = set_main_widget<GUI::Widget>();
TRY(main_widget->load_from_gml(export_progress_widget));
set_resizable(false);

View file

@ -44,7 +44,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = GUI::Icon::default_icon("app-piano"sv);
auto window = GUI::Window::construct();
auto main_widget = TRY(window->set_main_widget<MainWidget>(track_manager, audio_loop));
auto main_widget = TRY(MainWidget::try_create(track_manager, audio_loop));
window->set_main_widget(main_widget);
window->set_title("Piano");
window->resize(840, 600);
window->set_icon(app_icon.bitmap_for_size(16));

View file

@ -27,7 +27,7 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
set_icon(parent_window->icon());
resize(200, 220);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>(4);

View file

@ -20,7 +20,7 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize suggested_size, GUI::Win
set_icon(parent_window->icon());
resize(200, 200);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>(4);

View file

@ -23,7 +23,7 @@ EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, DeprecatedString co
resize(200, 130);
set_resizable(false);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->load_from_gml(edit_guide_dialog_gml).release_value_but_fixme_should_propagate_errors();
auto horizontal_radio = main_widget->find_descendant_of_type_named<GUI::RadioButton>("orientation_horizontal_radio");

View file

@ -21,7 +21,7 @@ FilterGallery::FilterGallery(GUI::Window* parent_window, ImageEditor* editor)
resize(400, 250);
set_resizable(true);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->load_from_gml(filter_gallery_gml).release_value_but_fixme_should_propagate_errors();
m_filter_tree = main_widget->find_descendant_of_type_named<GUI::TreeView>("tree_view");

View file

@ -48,7 +48,7 @@ private:
set_title(builder.string_view());
resize(200, 250);
auto main_widget = set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Frame>();
main_widget->set_frame_style(Gfx::FrameStyle::RaisedContainer);
main_widget->set_fill_with_background_color(true);
main_widget->template set_layout<GUI::VerticalBoxLayout>(4);

View file

@ -26,7 +26,7 @@ ImageMasking::ImageMasking(GUI::Window* parent_window, ImageEditor* editor, Mask
{
set_icon(parent_window->icon());
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
set_resizable(false);
m_previous_edit_mode = m_editor->active_layer()->edit_mode();

View file

@ -18,7 +18,7 @@ LevelsDialog::LevelsDialog(GUI::Window* parent_window, ImageEditor* editor)
set_title("Levels");
set_icon(parent_window->icon());
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->load_from_gml(levels_dialog_gml).release_value_but_fixme_should_propagate_errors();
resize(305, 202);

View file

@ -27,7 +27,7 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize suggested_size, GUI::Window* p
resize(260, 228);
set_icon(parent_window->icon());
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->load_from_gml(resize_image_dialog_gml).release_value_but_fixme_should_propagate_errors();
auto width_spinbox = main_widget->find_descendant_of_type_named<GUI::SpinBox>("width_spinbox");

View file

@ -47,7 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(800, 520);
window->set_icon(app_icon.bitmap_for_size(16));
auto main_widget = TRY(window->set_main_widget<PixelPaint::MainWidget>());
auto main_widget = window->set_main_widget<PixelPaint::MainWidget>();
TRY(main_widget->initialize_menubar(*window));

View file

@ -27,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = GUI::Window::construct();
window->set_title("Presenter");
window->set_icon(GUI::Icon::default_icon("app-presenter"sv).bitmap_for_size(16));
auto main_widget = TRY(window->set_main_widget<PresenterWidget>());
auto main_widget = window->set_main_widget<PresenterWidget>();
TRY(main_widget->initialize_menubar());
window->show();

View file

@ -41,7 +41,7 @@ RunWindow::RunWindow()
set_resizable(false);
set_minimizable(false);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->load_from_gml(run_gml).release_value_but_fixme_should_propagate_errors();
m_icon_image_widget = *main_widget->find_descendant_of_type_named<GUI::ImageWidget>("icon");

View file

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

View file

@ -52,7 +52,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
// start in advanced view by default
Player* player = TRY(window->set_main_widget<SoundPlayerWidget>(window, audio_client, decoder_client));
Player* player = window->set_main_widget<SoundPlayerWidget>(window, audio_client, decoder_client);
if (!file_path.is_empty()) {
player->play_file_path(file_path);

View file

@ -14,7 +14,7 @@ ErrorOr<NonnullRefPtr<ProgressWindow>> ProgressWindow::try_create(StringView tit
{
auto window = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ProgressWindow(title, parent)));
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
auto main_widget = window->set_main_widget<GUI::Widget>();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>();

View file

@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
// Load widgets.
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
auto main_widget = window->set_main_widget<GUI::Widget>();
TRY(main_widget->load_from_gml(space_analyzer_gml));
auto& breadcrumbbar = *main_widget->find_descendant_of_type_named<GUI::Breadcrumbbar>("breadcrumbbar");
auto& tree_map_widget = *main_widget->find_descendant_of_type_named<SpaceAnalyzer::TreeMapWidget>("tree_map");

View file

@ -45,7 +45,7 @@ CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet,
set_icon(parent->icon());
resize(285, 360);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Widget>();
main_widget->set_layout<GUI::VerticalBoxLayout>(4);
main_widget->set_fill_with_background_color(true);

View file

@ -68,7 +68,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors());
set_window_mode(GUI::WindowMode::Modeless);
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<GUI::Widget>();
widget->set_layout<GUI::VerticalBoxLayout>();
widget->set_fill_with_background_color(true);
@ -115,7 +115,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
window->set_title(DeprecatedString::formatted("Spreadsheet Help - Example {} for {}", name, entry));
window->on_close = [window = window.ptr()] { window->remove_from_parent(); };
auto widget = window->set_main_widget<SpreadsheetWidget>(window, Vector<NonnullRefPtr<Sheet>> {}, false).release_value_but_fixme_should_propagate_errors();
auto widget = window->set_main_widget<SpreadsheetWidget>(window, Vector<NonnullRefPtr<Sheet>> {}, false);
auto sheet = Sheet::from_json(value, widget->workbook());
if (!sheet) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, example_path));

View file

@ -80,7 +80,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullR
m_inline_documentation_window->set_rect(m_cell_value_editor->rect().translated(0, m_cell_value_editor->height() + 7).inflated(6, 6));
m_inline_documentation_window->set_window_type(GUI::WindowType::Tooltip);
m_inline_documentation_window->set_resizable(false);
auto inline_widget = m_inline_documentation_window->set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors();
auto inline_widget = m_inline_documentation_window->set_main_widget<GUI::Frame>();
inline_widget->set_fill_with_background_color(true);
inline_widget->set_layout<GUI::VerticalBoxLayout>(4);
inline_widget->set_frame_style(Gfx::FrameStyle::Plain);

View file

@ -55,7 +55,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(640, 480);
window->set_icon(app_icon.bitmap_for_size(16));
auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, Vector<NonnullRefPtr<Spreadsheet::Sheet>> {}, filename.is_empty()));
auto spreadsheet_widget = window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, Vector<NonnullRefPtr<Spreadsheet::Sheet>> {}, filename.is_empty());
TRY(spreadsheet_widget->initialize_menubar(*window));
spreadsheet_widget->update_window_title();

View file

@ -282,7 +282,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_title("System Monitor");
window->resize(560, 430);
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
auto main_widget = window->set_main_widget<GUI::Widget>();
TRY(main_widget->load_from_gml(system_monitor_gml));
auto& tabwidget = *main_widget->find_descendant_of_type_named<GUI::TabWidget>("main_tabs");
statusbar = main_widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
@ -530,7 +530,7 @@ ErrorOr<NonnullRefPtr<GUI::Window>> build_process_window(pid_t pid)
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-system-monitor"sv));
window->set_icon(app_icon.bitmap_for_size(16));
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
auto main_widget = window->set_main_widget<GUI::Widget>();
TRY(main_widget->load_from_gml(process_window_gml));
GUI::ModelIndex process_index;

View file

@ -164,7 +164,7 @@ static ErrorOr<NonnullRefPtr<GUI::Window>> create_find_window(VT::TerminalWidget
window->set_resizable(false);
window->resize(300, 90);
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
auto main_widget = window->set_main_widget<GUI::Widget>();
main_widget->set_fill_with_background_color(true);
main_widget->set_background_role(ColorRole::Button);
main_widget->set_layout<GUI::VerticalBoxLayout>(4);
@ -283,7 +283,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_title("Terminal");
window->set_obey_widget_min_size(false);
auto terminal = TRY(window->set_main_widget<VT::TerminalWidget>(ptm_fd, true));
auto terminal = window->set_main_widget<VT::TerminalWidget>(ptm_fd, true);
terminal->on_command_exit = [&] {
app->quit(0);
};

View file

@ -44,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = GUI::Window::construct();
window->resize(640, 400);
auto text_widget = TRY(window->set_main_widget<MainWidget>());
auto text_widget = window->set_main_widget<MainWidget>();
text_widget->editor().set_focus(true);

View file

@ -50,7 +50,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app_icon = GUI::Icon::default_icon("app-theme-editor"sv);
auto window = GUI::Window::construct();
auto main_widget = TRY(window->set_main_widget<ThemeEditor::MainWidget>());
auto main_widget = TRY(ThemeEditor::MainWidget::try_create());
window->set_main_widget(main_widget);
if (path.has_value()) {
// Note: This is deferred to ensure that the window has already popped and any error dialog boxes would show up correctly.

View file

@ -34,7 +34,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto main_widget = TRY(window->set_main_widget<VideoPlayer::VideoPlayerWidget>());
auto main_widget = TRY(VideoPlayer::VideoPlayerWidget::try_create());
window->set_main_widget(main_widget);
main_widget->update_title();
TRY(main_widget->initialize_menubar(window));

View file

@ -32,7 +32,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->center_on_screen();
window->set_title("Welcome");
window->set_icon(app_icon.bitmap_for_size(16));
auto welcome_widget = TRY(window->set_main_widget<WelcomeWidget>());
auto welcome_widget = TRY(WelcomeWidget::try_create());
window->set_main_widget(welcome_widget);
window->show();