1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 18:37:35 +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

@ -385,7 +385,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->try_set_main_widget<GLContextWidget>());
auto widget = TRY(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->try_set_main_widget<AnalogClock>());
auto clock = TRY(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

@ -165,14 +165,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Assistant::AppState app_state;
Assistant::Database db { app_state };
auto& container = window->set_main_widget<GUI::Frame>();
container.set_fill_with_background_color(true);
container.set_frame_shape(Gfx::FrameShape::Window);
auto& layout = container.set_layout<GUI::VerticalBoxLayout>();
auto container = TRY(window->set_main_widget<GUI::Frame>());
container->set_fill_with_background_color(true);
container->set_frame_shape(Gfx::FrameShape::Window);
auto& layout = container->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins({ 8 });
auto& text_box = container.add<GUI::TextBox>();
auto& results_container = container.add<GUI::Widget>();
auto& text_box = container->add<GUI::TextBox>();
auto& results_container = container->add<GUI::Widget>();
auto& results_layout = results_container.set_layout<GUI::VerticalBoxLayout>();
auto mark_selected_item = [&]() {

View file

@ -47,28 +47,28 @@ private:
BookmarkEditor(Window* parent_window, StringView title, StringView url)
: Dialog(parent_window)
{
auto& widget = set_main_widget<GUI::Widget>();
if (!widget.load_from_gml(edit_bookmark_gml))
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
if (!widget->load_from_gml(edit_bookmark_gml))
VERIFY_NOT_REACHED();
set_resizable(false);
resize(260, 85);
m_title_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("title_textbox");
m_title_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("title_textbox");
m_title_textbox->set_text(title);
m_title_textbox->set_focus(true);
m_title_textbox->select_all();
m_url_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("url_textbox");
m_url_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("url_textbox");
m_url_textbox->set_text(url);
auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button");
auto& ok_button = *widget->find_descendant_of_type_named<GUI::Button>("ok_button");
ok_button.on_click = [this](auto) {
done(ExecResult::OK);
};
ok_button.set_default(true);
auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);
};

View file

@ -73,12 +73,12 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
set_icon(app_icon.bitmap_for_size(16));
set_title("Browser");
auto& widget = set_main_widget<GUI::Widget>();
widget.load_from_gml(browser_window_gml);
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
widget->load_from_gml(browser_window_gml);
auto& top_line = *widget.find_descendant_of_type_named<GUI::HorizontalSeparator>("top_line");
auto& top_line = *widget->find_descendant_of_type_named<GUI::HorizontalSeparator>("top_line");
m_tab_widget = *widget.find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
m_tab_widget = *widget->find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
m_tab_widget->on_tab_count_change = [&top_line](size_t tab_count) {
top_line.set_visible(tab_count > 1);
};

View file

@ -70,18 +70,18 @@ void Tab::start_download(const URL& url)
window->resize(300, 170);
window->set_title(DeprecatedString::formatted("0% of {}", url.basename()));
window->set_resizable(false);
window->set_main_widget<DownloadWidget>(url);
(void)window->set_main_widget<DownloadWidget>(url).release_value_but_fixme_should_propagate_errors();
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>();
editor.set_text(source);
editor.set_mode(GUI::TextEditor::ReadOnly);
editor.set_syntax_highlighter(make<Web::HTML::SyntaxHighlighter>());
editor.set_ruler_visible(true);
auto editor = window->set_main_widget<GUI::TextEditor>().release_value_but_fixme_should_propagate_errors();
editor->set_text(source);
editor->set_mode(GUI::TextEditor::ReadOnly);
editor->set_syntax_highlighter(make<Web::HTML::SyntaxHighlighter>());
editor->set_ruler_visible(true);
window->resize(640, 480);
window->set_title(url.to_deprecated_string());
window->set_icon(g_icon_bag.filetype_text);
@ -663,7 +663,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>();
m_dom_inspector_widget = window->set_main_widget<InspectorWidget>().release_value_but_fixme_should_propagate_errors();
m_dom_inspector_widget->set_web_view(*m_web_content_view);
m_web_content_view->inspect_dom_tree();
}
@ -702,7 +702,7 @@ void Tab::show_console_window()
console_window->resize(500, 300);
console_window->set_title("JS Console");
console_window->set_icon(g_icon_bag.filetype_javascript);
m_console_widget = console_window->set_main_widget<ConsoleWidget>();
m_console_widget = console_window->set_main_widget<ConsoleWidget>().release_value_but_fixme_should_propagate_errors();
m_console_widget->on_js_input = [this](DeprecatedString const& js_source) {
m_web_content_view->js_console_input(js_source);
};
@ -723,7 +723,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>();
m_storage_widget = storage_window->set_main_widget<StorageWidget>().release_value_but_fixme_should_propagate_errors();
m_storage_widget->on_update_cookie = [this](Web::Cookie::Cookie cookie) {
if (on_update_cookie)
on_update_cookie(move(cookie));
@ -760,7 +760,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>();
m_history_widget = history_window->set_main_widget<HistoryWidget>().release_value_but_fixme_should_propagate_errors();
}
m_history_widget->clear_history_entries();

View file

@ -39,18 +39,18 @@ RoundingDialog::RoundingDialog(GUI::Window* parent_window, StringView title)
set_resizable(false);
set_title(title);
auto& main_widget = set_main_widget<GUI::Widget>();
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget.set_fill_with_background_color(true);
main_widget.set_layout<GUI::VerticalBoxLayout>();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>();
m_rounding_spinbox = GUI::SpinBox::construct();
m_buttons_container = GUI::Widget::construct();
m_ok_button = GUI::DialogButton::construct("OK");
m_cancel_button = GUI::DialogButton::construct("Cancel");
main_widget.add_child(*m_rounding_spinbox);
main_widget.add_child(*m_buttons_container);
main_widget->add_child(*m_rounding_spinbox);
main_widget->add_child(*m_buttons_container);
m_buttons_container->set_layout<GUI::HorizontalBoxLayout>();
m_buttons_container->layout()->add_spacer();

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->try_set_main_widget<CalculatorWidget>());
auto widget = TRY(window->set_main_widget<CalculatorWidget>());
window->set_icon(app_icon.bitmap_for_size(16));

View file

@ -28,11 +28,11 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window)
set_resizable(false);
set_icon(parent_window->icon());
auto& widget = set_main_widget<GUI::Widget>();
widget.set_fill_with_background_color(true);
widget.set_layout<GUI::VerticalBoxLayout>();
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
widget->set_fill_with_background_color(true);
widget->set_layout<GUI::VerticalBoxLayout>();
auto& top_container = widget.add<GUI::Widget>();
auto& top_container = widget->add<GUI::Widget>();
top_container.set_layout<GUI::VerticalBoxLayout>();
top_container.set_fixed_height(45);
top_container.layout()->set_margins(4);
@ -45,12 +45,12 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window)
auto& event_title_textbox = top_container.add<GUI::TextBox>();
event_title_textbox.set_fixed_height(20);
auto& middle_container = widget.add<GUI::Widget>();
auto& middle_container = widget->add<GUI::Widget>();
middle_container.set_layout<GUI::HorizontalBoxLayout>();
middle_container.set_fixed_height(25);
middle_container.layout()->set_margins(4);
auto& time_container = widget.add<GUI::Widget>();
auto& time_container = widget->add<GUI::Widget>();
time_container.set_layout<GUI::HorizontalBoxLayout>();
time_container.set_fixed_height(25);
time_container.layout()->set_margins(4);
@ -87,9 +87,9 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window)
starting_meridiem_combo.set_model(MeridiemListModel::create());
starting_meridiem_combo.set_selected_index(0);
widget.layout()->add_spacer();
widget->layout()->add_spacer();
auto& button_container = widget.add<GUI::Widget>();
auto& button_container = widget->add<GUI::Widget>();
button_container.set_fixed_height(20);
button_container.set_layout<GUI::HorizontalBoxLayout>();
button_container.layout()->add_spacer();

View file

@ -42,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(600, 480);
window->set_icon(app_icon.bitmap_for_size(16));
auto main_widget = TRY(window->try_set_main_widget<GUI::Widget>());
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
main_widget->load_from_gml(calendar_window_gml);
auto toolbar = main_widget->find_descendant_of_type_named<GUI::Toolbar>("toolbar");

View file

@ -86,8 +86,8 @@ CharacterMapWidget::CharacterMapWidget()
m_find_glyphs_action = GUI::Action::create("&Find glyphs...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_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>();
search_widget.on_character_selected = [&](auto code_point) {
auto search_widget = m_find_window->set_main_widget<CharacterSearchWidget>().release_value_but_fixme_should_propagate_errors();
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

@ -68,7 +68,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->try_set_main_widget<CharacterMapWidget>());
auto character_map_widget = TRY(window->set_main_widget<CharacterMapWidget>());
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

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

View file

@ -31,10 +31,10 @@ EscalatorWindow::EscalatorWindow(StringView executable, Vector<StringView> argum
set_resizable(false);
set_minimizable(false);
auto& main_widget = set_main_widget<GUI::Widget>();
main_widget.load_from_gml(escalator_gml);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->load_from_gml(escalator_gml);
RefPtr<GUI::Label> app_label = *main_widget.find_descendant_of_type_named<GUI::Label>("description");
RefPtr<GUI::Label> app_label = *main_widget->find_descendant_of_type_named<GUI::Label>("description");
DeprecatedString prompt;
if (options.description.is_empty())
@ -44,10 +44,10 @@ EscalatorWindow::EscalatorWindow(StringView executable, Vector<StringView> argum
app_label->set_text(prompt);
m_icon_image_widget = *main_widget.find_descendant_of_type_named<GUI::ImageWidget>("icon");
m_icon_image_widget = *main_widget->find_descendant_of_type_named<GUI::ImageWidget>("icon");
m_icon_image_widget->set_bitmap(app_icon.bitmap_for_size(32));
m_ok_button = *main_widget.find_descendant_of_type_named<GUI::DialogButton>("ok_button");
m_ok_button = *main_widget->find_descendant_of_type_named<GUI::DialogButton>("ok_button");
m_ok_button->on_click = [this](auto) {
auto result = check_password();
if (result.is_error()) {
@ -57,12 +57,12 @@ EscalatorWindow::EscalatorWindow(StringView executable, Vector<StringView> argum
};
m_ok_button->set_default(true);
m_cancel_button = *main_widget.find_descendant_of_type_named<GUI::DialogButton>("cancel_button");
m_cancel_button = *main_widget->find_descendant_of_type_named<GUI::DialogButton>("cancel_button");
m_cancel_button->on_click = [this](auto) {
close();
};
m_password_input = *main_widget.find_descendant_of_type_named<GUI::PasswordBox>("password");
m_password_input = *main_widget->find_descendant_of_type_named<GUI::PasswordBox>("password");
}
ErrorOr<void> EscalatorWindow::check_password()

View file

@ -99,7 +99,7 @@ ErrorOr<void> run_file_operation(FileOperation operation, Vector<DeprecatedStrin
auto pipe_input_file = TRY(Core::Stream::File::adopt_fd(pipe_fds[0], Core::Stream::OpenMode::Read));
auto buffered_pipe = TRY(Core::Stream::BufferedFile::create(move(pipe_input_file)));
(void)TRY(window->try_set_main_widget<FileOperationProgressWidget>(operation, move(buffered_pipe), pipe_fds[0]));
(void)TRY(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

@ -31,18 +31,18 @@ PropertiesWindow::PropertiesWindow(DeprecatedString const& path, bool disable_re
{
auto lexical_path = LexicalPath(path);
auto& main_widget = set_main_widget<GUI::Widget>();
main_widget.set_layout<GUI::VerticalBoxLayout>();
main_widget.layout()->set_spacing(6);
main_widget.layout()->set_margins(4);
main_widget.set_fill_with_background_color(true);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_layout<GUI::VerticalBoxLayout>();
main_widget->layout()->set_spacing(6);
main_widget->layout()->set_margins(4);
main_widget->set_fill_with_background_color(true);
set_rect({ 0, 0, 360, 420 });
set_resizable(false);
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png"sv).release_value_but_fixme_should_propagate_errors());
auto& tab_widget = main_widget.add<GUI::TabWidget>();
auto& tab_widget = main_widget->add<GUI::TabWidget>();
auto& general_tab = tab_widget.add_tab<GUI::Widget>("General");
general_tab.load_from_gml(properties_window_general_tab_gml);
@ -142,7 +142,7 @@ PropertiesWindow::PropertiesWindow(DeprecatedString const& path, bool disable_re
auto others_execute = general_tab.find_descendant_of_type_named<GUI::CheckBox>("others_execute");
setup_permission_checkboxes(*others_read, *others_write, *others_execute, { S_IROTH, S_IWOTH, S_IXOTH }, m_mode);
auto& button_widget = main_widget.add<GUI::Widget>();
auto& button_widget = main_widget->add<GUI::Widget>();
button_widget.set_layout<GUI::HorizontalBoxLayout>();
button_widget.set_fixed_height(22);
button_widget.layout()->set_spacing(5);

View file

@ -351,7 +351,7 @@ ErrorOr<int> run_in_desktop_mode()
window->set_window_type(GUI::WindowType::Desktop);
window->set_has_alpha_channel(true);
auto desktop_widget = TRY(window->try_set_main_widget<FileManager::DesktopWidget>());
auto desktop_widget = TRY(window->set_main_widget<FileManager::DesktopWidget>());
(void)TRY(desktop_widget->try_set_layout<GUI::VerticalBoxLayout>());
auto directory_view = TRY(desktop_widget->try_add<DirectoryView>(DirectoryView::Mode::Desktop));
@ -579,7 +579,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr
auto height = Config::read_i32("FileManager"sv, "Window"sv, "Height"sv, 480);
auto was_maximized = Config::read_bool("FileManager"sv, "Window"sv, "Maximized"sv, false);
auto widget = TRY(window->try_set_main_widget<GUI::Widget>());
auto widget = TRY(window->set_main_widget<GUI::Widget>());
widget->load_from_gml(file_manager_window_gml);

View file

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

View file

@ -39,7 +39,7 @@ 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->try_set_main_widget<FontEditor::MainWidget>());
auto font_editor = TRY(window->set_main_widget<FontEditor::MainWidget>());
TRY(font_editor->initialize_menubar(*window));
if (path) {

View file

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

View file

@ -99,16 +99,16 @@ FindDialog::FindDialog()
set_resizable(false);
set_title("Find");
auto& main_widget = set_main_widget<GUI::Widget>();
if (!main_widget.load_from_gml(find_dialog_gml))
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
if (!main_widget->load_from_gml(find_dialog_gml))
VERIFY_NOT_REACHED();
m_text_editor = *main_widget.find_descendant_of_type_named<GUI::TextBox>("text_editor");
m_find_button = *main_widget.find_descendant_of_type_named<GUI::Button>("find_button");
m_find_all_button = *main_widget.find_descendant_of_type_named<GUI::Button>("find_all_button");
m_cancel_button = *main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
m_text_editor = *main_widget->find_descendant_of_type_named<GUI::TextBox>("text_editor");
m_find_button = *main_widget->find_descendant_of_type_named<GUI::Button>("find_button");
m_find_all_button = *main_widget->find_descendant_of_type_named<GUI::Button>("find_all_button");
m_cancel_button = *main_widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
auto& radio_container = *main_widget.find_descendant_of_type_named<GUI::Widget>("radio_container");
auto& radio_container = *main_widget->find_descendant_of_type_named<GUI::Widget>("radio_container");
for (size_t i = 0; i < options.size(); i++) {
auto action = options[i];
auto& radio = radio_container.add<GUI::RadioButton>();

View file

@ -96,15 +96,15 @@ GoToOffsetDialog::GoToOffsetDialog()
set_resizable(false);
set_title("Go to Offset");
auto& main_widget = set_main_widget<GUI::Widget>();
if (!main_widget.load_from_gml(go_to_offset_dialog_gml))
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
if (!main_widget->load_from_gml(go_to_offset_dialog_gml))
VERIFY_NOT_REACHED();
m_text_editor = *main_widget.find_descendant_of_type_named<GUI::TextBox>("text_editor");
m_go_button = *main_widget.find_descendant_of_type_named<GUI::Button>("go_button");
m_offset_type_box = *main_widget.find_descendant_of_type_named<GUI::ComboBox>("offset_type");
m_offset_from_box = *main_widget.find_descendant_of_type_named<GUI::ComboBox>("offset_from");
m_statusbar = *main_widget.find_descendant_of_type_named<GUI::Statusbar>("statusbar");
m_text_editor = *main_widget->find_descendant_of_type_named<GUI::TextBox>("text_editor");
m_go_button = *main_widget->find_descendant_of_type_named<GUI::Button>("go_button");
m_offset_type_box = *main_widget->find_descendant_of_type_named<GUI::ComboBox>("offset_type");
m_offset_from_box = *main_widget->find_descendant_of_type_named<GUI::ComboBox>("offset_from");
m_statusbar = *main_widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
m_offset_type.append("Decimal");
m_offset_type.append("Hexadecimal");

View file

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

View file

@ -56,7 +56,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->try_set_main_widget<GUI::Widget>());
auto root_widget = TRY(window->set_main_widget<GUI::Widget>());
root_widget->set_fill_with_background_color(true);
root_widget->set_layout<GUI::VerticalBoxLayout>();
root_widget->layout()->set_spacing(2);

View file

@ -34,7 +34,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->try_set_main_widget<KeyboardMapperWidget>());
auto keyboard_mapper_widget = TRY(window->set_main_widget<KeyboardMapperWidget>());
window->resize(775, 315);
window->set_resizable(false);

View file

@ -51,8 +51,8 @@ private:
KeymapSelectionDialog(Window* parent_window, Vector<DeprecatedString> const& selected_keymaps)
: Dialog(parent_window)
{
auto& widget = set_main_widget<GUI::Widget>();
if (!widget.load_from_gml(keymap_dialog_gml))
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
if (!widget->load_from_gml(keymap_dialog_gml))
VERIFY_NOT_REACHED();
set_resizable(false);
@ -77,7 +77,7 @@ private:
m_selected_keymap = m_character_map_files.first();
m_keymaps_combobox = *widget.find_descendant_of_type_named<GUI::ComboBox>("keymaps_combobox");
m_keymaps_combobox = *widget->find_descendant_of_type_named<GUI::ComboBox>("keymaps_combobox");
m_keymaps_combobox->set_only_allow_values_from_model(true);
m_keymaps_combobox->set_model(*GUI::ItemListModel<DeprecatedString>::create(m_character_map_files));
m_keymaps_combobox->set_selected_index(0);
@ -86,12 +86,12 @@ private:
m_selected_keymap = keymap;
};
auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button");
auto& ok_button = *widget->find_descendant_of_type_named<GUI::Button>("ok_button");
ok_button.on_click = [this](auto) {
done(ExecResult::OK);
};
auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);
};

View file

@ -61,7 +61,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->try_set_main_widget<MagnifierWidget>());
auto magnifier = TRY(window->set_main_widget<MagnifierWidget>());
auto file_menu = TRY(window->try_add_menu("&File"));
TRY(file_menu->try_add_action(GUI::CommonActions::make_save_as_action([&](auto&) {

View file

@ -41,7 +41,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->try_set_main_widget<MailWidget>());
auto mail_widget = TRY(window->set_main_widget<MailWidget>());
window->set_title("Mail");
window->resize(640, 400);

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->try_set_main_widget<PDFViewerWidget>());
auto pdf_viewer_widget = TRY(window->set_main_widget<PDFViewerWidget>());
pdf_viewer_widget->initialize_menubar(*window);

View file

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

View file

@ -42,7 +42,7 @@ 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->try_set_main_widget<MainWidget>(track_manager, audio_loop));
auto main_widget = TRY(window->set_main_widget<MainWidget>(track_manager, audio_loop));
window->set_title("Piano");
window->resize(840, 600);
window->set_icon(app_icon.bitmap_for_size(16));

View file

@ -27,31 +27,31 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
set_icon(parent_window->icon());
resize(200, 220);
auto& main_widget = set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_fill_with_background_color(true);
auto& layout = main_widget.set_layout<GUI::VerticalBoxLayout>();
auto& layout = main_widget->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins(4);
auto& name_label = main_widget.add<GUI::Label>("Name:");
auto& name_label = main_widget->add<GUI::Label>("Name:");
name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
m_name_textbox = main_widget.add<GUI::TextBox>();
m_name_textbox = main_widget->add<GUI::TextBox>();
m_name_textbox->on_change = [this] {
m_image_name = m_name_textbox->text();
};
auto default_name = Config::read_string("PixelPaint"sv, "NewImage"sv, "Name"sv);
m_name_textbox->set_text(default_name);
auto& width_label = main_widget.add<GUI::Label>("Width:");
auto& width_label = main_widget->add<GUI::Label>("Width:");
width_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
auto& width_spinbox = main_widget.add<GUI::SpinBox>();
auto& width_spinbox = main_widget->add<GUI::SpinBox>();
auto& height_label = main_widget.add<GUI::Label>("Height:");
auto& height_label = main_widget->add<GUI::Label>("Height:");
height_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
auto& height_spinbox = main_widget.add<GUI::SpinBox>();
auto& height_spinbox = main_widget->add<GUI::SpinBox>();
enum class BackgroundIndex {
Transparent = 0,
@ -81,10 +81,10 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
return BackgroundIndex::Custom;
}();
auto& background_label = main_widget.add<GUI::Label>("Background:");
auto& background_label = main_widget->add<GUI::Label>("Background:");
background_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
auto& background_color_combo = main_widget.add<GUI::ComboBox>();
auto& background_color_input = main_widget.add<GUI::ColorInput>();
auto& background_color_combo = main_widget->add<GUI::ComboBox>();
auto& background_color_input = main_widget->add<GUI::ColorInput>();
background_color_input.set_visible(false);
background_color_combo.set_only_allow_values_from_model(true);
background_color_combo.set_model(*GUI::ItemListModel<StringView, decltype(suggested_backgrounds)>::create(suggested_backgrounds));
@ -110,10 +110,10 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
m_background_color = background_color_input.color();
};
auto& set_defaults_checkbox = main_widget.add<GUI::CheckBox>();
auto& set_defaults_checkbox = main_widget->add<GUI::CheckBox>();
set_defaults_checkbox.set_text("Use these settings as default");
auto& button_container = main_widget.add<GUI::Widget>();
auto& button_container = main_widget->add<GUI::Widget>();
button_container.set_layout<GUI::HorizontalBoxLayout>();
auto& ok_button = button_container.add<GUI::Button>("OK");

View file

@ -20,33 +20,33 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize suggested_size, GUI::Win
set_icon(parent_window->icon());
resize(200, 200);
auto& main_widget = set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_fill_with_background_color(true);
auto& layout = main_widget.set_layout<GUI::VerticalBoxLayout>();
auto& layout = main_widget->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins(4);
auto& name_label = main_widget.add<GUI::Label>("Name:");
auto& name_label = main_widget->add<GUI::Label>("Name:");
name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
m_name_textbox = main_widget.add<GUI::TextBox>();
m_name_textbox = main_widget->add<GUI::TextBox>();
m_name_textbox->set_text("Layer"sv);
m_name_textbox->select_all();
m_name_textbox->on_change = [this] {
m_layer_name = m_name_textbox->text();
};
auto& width_label = main_widget.add<GUI::Label>("Width:");
auto& width_label = main_widget->add<GUI::Label>("Width:");
width_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
auto& width_spinbox = main_widget.add<GUI::SpinBox>();
auto& width_spinbox = main_widget->add<GUI::SpinBox>();
auto& height_label = main_widget.add<GUI::Label>("Height:");
auto& height_label = main_widget->add<GUI::Label>("Height:");
height_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
auto& height_spinbox = main_widget.add<GUI::SpinBox>();
auto& height_spinbox = main_widget->add<GUI::SpinBox>();
auto& button_container = main_widget.add<GUI::Widget>();
auto& button_container = main_widget->add<GUI::Widget>();
button_container.set_layout<GUI::HorizontalBoxLayout>();
auto& ok_button = button_container.add<GUI::Button>("OK");

View file

@ -23,15 +23,15 @@ EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, DeprecatedString co
resize(200, 130);
set_resizable(false);
auto& main_widget = set_main_widget<GUI::Widget>();
if (!main_widget.load_from_gml(edit_guide_dialog_gml))
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
if (!main_widget->load_from_gml(edit_guide_dialog_gml))
VERIFY_NOT_REACHED();
auto horizontal_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("orientation_horizontal_radio");
auto vertical_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("orientation_vertical_radio");
auto ok_button = main_widget.find_descendant_of_type_named<GUI::Button>("ok_button");
auto cancel_button = main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
m_offset_text_box = main_widget.find_descendant_of_type_named<GUI::TextBox>("offset_text_box");
auto horizontal_radio = main_widget->find_descendant_of_type_named<GUI::RadioButton>("orientation_horizontal_radio");
auto vertical_radio = main_widget->find_descendant_of_type_named<GUI::RadioButton>("orientation_vertical_radio");
auto ok_button = main_widget->find_descendant_of_type_named<GUI::Button>("ok_button");
auto cancel_button = main_widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
m_offset_text_box = main_widget->find_descendant_of_type_named<GUI::TextBox>("offset_text_box");
VERIFY(horizontal_radio);
VERIFY(ok_button);

View file

@ -21,15 +21,15 @@ FilterGallery::FilterGallery(GUI::Window* parent_window, ImageEditor* editor)
resize(400, 250);
set_resizable(true);
auto& main_widget = set_main_widget<GUI::Widget>();
if (!main_widget.load_from_gml(filter_gallery_gml))
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
if (!main_widget->load_from_gml(filter_gallery_gml))
VERIFY_NOT_REACHED();
m_filter_tree = main_widget.find_descendant_of_type_named<GUI::TreeView>("tree_view");
auto apply_button = main_widget.find_descendant_of_type_named<GUI::Button>("apply_button");
auto cancel_button = main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
m_config_widget = main_widget.find_descendant_of_type_named<GUI::Widget>("config_widget");
m_preview_widget = main_widget.find_descendant_of_type_named<FilterPreviewWidget>("preview_widget");
m_filter_tree = main_widget->find_descendant_of_type_named<GUI::TreeView>("tree_view");
auto apply_button = main_widget->find_descendant_of_type_named<GUI::Button>("apply_button");
auto cancel_button = main_widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
m_config_widget = main_widget->find_descendant_of_type_named<GUI::Widget>("config_widget");
m_preview_widget = main_widget->find_descendant_of_type_named<FilterPreviewWidget>("preview_widget");
VERIFY(m_filter_tree);
VERIFY(apply_button);

View file

@ -48,11 +48,11 @@ private:
set_title(builder.string_view());
resize(200, 250);
auto& main_widget = set_main_widget<GUI::Frame>();
main_widget.set_frame_shape(Gfx::FrameShape::Container);
main_widget.set_frame_shadow(Gfx::FrameShadow::Raised);
main_widget.set_fill_with_background_color(true);
auto& layout = main_widget.template set_layout<GUI::VerticalBoxLayout>();
auto main_widget = set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors();
main_widget->set_frame_shape(Gfx::FrameShape::Container);
main_widget->set_frame_shadow(Gfx::FrameShadow::Raised);
main_widget->set_fill_with_background_color(true);
auto& layout = main_widget->template set_layout<GUI::VerticalBoxLayout>();
layout.set_margins(4);
size_t index = 0;
@ -60,7 +60,7 @@ private:
size_t rows = N;
for (size_t row = 0; row < rows; ++row) {
auto& horizontal_container = main_widget.template add<GUI::Widget>();
auto& horizontal_container = main_widget->template add<GUI::Widget>();
horizontal_container.template set_layout<GUI::HorizontalBoxLayout>();
for (size_t column = 0; column < columns; ++column) {
if (index < columns * rows) {
@ -81,13 +81,13 @@ private:
}
}
auto& norm_checkbox = main_widget.template add<GUI::CheckBox>("Normalize");
auto& norm_checkbox = main_widget->template add<GUI::CheckBox>("Normalize");
norm_checkbox.set_checked(false);
auto& wrap_checkbox = main_widget.template add<GUI::CheckBox>("Wrap");
auto& wrap_checkbox = main_widget->template add<GUI::CheckBox>("Wrap");
wrap_checkbox.set_checked(m_should_wrap);
auto& button = main_widget.template add<GUI::Button>("Done");
auto& button = main_widget->template add<GUI::Button>("Done");
button.on_click = [&](auto) {
m_should_wrap = wrap_checkbox.is_checked();
if (norm_checkbox.is_checked())

View file

@ -18,8 +18,8 @@ LevelsDialog::LevelsDialog(GUI::Window* parent_window, ImageEditor* editor)
set_title("Levels");
set_icon(parent_window->icon());
auto& main_widget = set_main_widget<GUI::Widget>();
if (!main_widget.load_from_gml(levels_dialog_gml))
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
if (!main_widget->load_from_gml(levels_dialog_gml))
VERIFY_NOT_REACHED();
resize(305, 202);
@ -27,12 +27,12 @@ LevelsDialog::LevelsDialog(GUI::Window* parent_window, ImageEditor* editor)
m_editor = editor;
m_brightness_slider = main_widget.find_descendant_of_type_named<GUI::ValueSlider>("brightness_slider");
m_contrast_slider = main_widget.find_descendant_of_type_named<GUI::ValueSlider>("contrast_slider");
m_gamma_slider = main_widget.find_descendant_of_type_named<GUI::ValueSlider>("gamma_slider");
auto context_label = main_widget.find_descendant_of_type_named<GUI::Label>("context_label");
auto apply_button = main_widget.find_descendant_of_type_named<GUI::Button>("apply_button");
auto cancel_button = main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
m_brightness_slider = main_widget->find_descendant_of_type_named<GUI::ValueSlider>("brightness_slider");
m_contrast_slider = main_widget->find_descendant_of_type_named<GUI::ValueSlider>("contrast_slider");
m_gamma_slider = main_widget->find_descendant_of_type_named<GUI::ValueSlider>("gamma_slider");
auto context_label = main_widget->find_descendant_of_type_named<GUI::Label>("context_label");
auto apply_button = main_widget->find_descendant_of_type_named<GUI::Button>("apply_button");
auto cancel_button = main_widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
VERIFY(m_brightness_slider);
VERIFY(m_contrast_slider);

View file

@ -27,13 +27,13 @@ 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>();
if (!main_widget.load_from_gml(resize_image_dialog_gml))
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
if (!main_widget->load_from_gml(resize_image_dialog_gml))
VERIFY_NOT_REACHED();
auto width_spinbox = main_widget.find_descendant_of_type_named<GUI::SpinBox>("width_spinbox");
auto height_spinbox = main_widget.find_descendant_of_type_named<GUI::SpinBox>("height_spinbox");
auto keep_aspect_ratio_checkbox = main_widget.find_descendant_of_type_named<GUI::CheckBox>("keep_aspect_ratio_checkbox");
auto width_spinbox = main_widget->find_descendant_of_type_named<GUI::SpinBox>("width_spinbox");
auto height_spinbox = main_widget->find_descendant_of_type_named<GUI::SpinBox>("height_spinbox");
auto keep_aspect_ratio_checkbox = main_widget->find_descendant_of_type_named<GUI::CheckBox>("keep_aspect_ratio_checkbox");
VERIFY(width_spinbox);
VERIFY(height_spinbox);
@ -67,10 +67,10 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize suggested_size, GUI::Window* p
}
};
auto nearest_neighbor_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("nearest_neighbor_radio");
auto smooth_pixels_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("smooth_pixels_radio");
auto bilinear_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("bilinear_radio");
auto resize_canvas_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("resize_canvas");
auto nearest_neighbor_radio = main_widget->find_descendant_of_type_named<GUI::RadioButton>("nearest_neighbor_radio");
auto smooth_pixels_radio = main_widget->find_descendant_of_type_named<GUI::RadioButton>("smooth_pixels_radio");
auto bilinear_radio = main_widget->find_descendant_of_type_named<GUI::RadioButton>("bilinear_radio");
auto resize_canvas_radio = main_widget->find_descendant_of_type_named<GUI::RadioButton>("resize_canvas");
VERIFY(nearest_neighbor_radio);
VERIFY(smooth_pixels_radio);
@ -99,8 +99,8 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize suggested_size, GUI::Window* p
m_scaling_mode = Gfx::Painter::ScalingMode::None;
};
auto ok_button = main_widget.find_descendant_of_type_named<GUI::Button>("ok_button");
auto cancel_button = main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
auto ok_button = main_widget->find_descendant_of_type_named<GUI::Button>("ok_button");
auto cancel_button = main_widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
VERIFY(ok_button);
VERIFY(cancel_button);

View file

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

View file

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

View file

@ -41,24 +41,24 @@ RunWindow::RunWindow()
set_resizable(false);
set_minimizable(false);
auto& main_widget = set_main_widget<GUI::Widget>();
main_widget.load_from_gml(run_gml);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->load_from_gml(run_gml);
m_icon_image_widget = *main_widget.find_descendant_of_type_named<GUI::ImageWidget>("icon");
m_icon_image_widget = *main_widget->find_descendant_of_type_named<GUI::ImageWidget>("icon");
m_icon_image_widget->set_bitmap(app_icon.bitmap_for_size(32));
m_path_combo_box = *main_widget.find_descendant_of_type_named<GUI::ComboBox>("path");
m_path_combo_box = *main_widget->find_descendant_of_type_named<GUI::ComboBox>("path");
m_path_combo_box->set_model(m_path_history_model);
if (!m_path_history.is_empty())
m_path_combo_box->set_selected_index(0);
m_ok_button = *main_widget.find_descendant_of_type_named<GUI::DialogButton>("ok_button");
m_ok_button = *main_widget->find_descendant_of_type_named<GUI::DialogButton>("ok_button");
m_ok_button->on_click = [this](auto) {
do_run();
};
m_ok_button->set_default(true);
m_cancel_button = *main_widget.find_descendant_of_type_named<GUI::DialogButton>("cancel_button");
m_cancel_button = *main_widget->find_descendant_of_type_named<GUI::DialogButton>("cancel_button");
m_cancel_button->on_click = [this](auto) {
close();
};

View file

@ -102,7 +102,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("Settings", 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

@ -48,7 +48,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->try_set_main_widget<SoundPlayerWidgetAdvancedView>(window, audio_client));
Player* player = TRY(window->set_main_widget<SoundPlayerWidgetAdvancedView>(window, audio_client));
if (!file_path.is_empty()) {
player->play_file_path(file_path);

View file

@ -141,14 +141,14 @@ static NonnullRefPtr<GUI::Window> create_progress_window()
window->resize(240, 50);
window->center_on_screen();
auto& main_widget = window->set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true);
main_widget.set_layout<GUI::VerticalBoxLayout>();
auto main_widget = window->set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>();
auto& label = main_widget.add<GUI::Label>("Analyzing storage space...");
auto& label = main_widget->add<GUI::Label>("Analyzing storage space...");
label.set_fixed_height(22);
auto& progresslabel = main_widget.add<GUI::Label>();
auto& progresslabel = main_widget->add<GUI::Label>();
progresslabel.set_name("progresslabel");
progresslabel.set_fixed_height(22);
@ -321,11 +321,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
// Load widgets.
auto& mainwidget = window->set_main_widget<GUI::Widget>();
mainwidget.load_from_gml(space_analyzer_gml);
auto& breadcrumbbar = *mainwidget.find_descendant_of_type_named<GUI::Breadcrumbbar>("breadcrumbbar");
auto& treemapwidget = *mainwidget.find_descendant_of_type_named<SpaceAnalyzer::TreeMapWidget>("tree_map");
auto& statusbar = *mainwidget.find_descendant_of_type_named<GUI::Statusbar>("statusbar");
auto mainwidget = TRY(window->set_main_widget<GUI::Widget>());
mainwidget->load_from_gml(space_analyzer_gml);
auto& breadcrumbbar = *mainwidget->find_descendant_of_type_named<GUI::Breadcrumbbar>("breadcrumbbar");
auto& treemapwidget = *mainwidget->find_descendant_of_type_named<SpaceAnalyzer::TreeMapWidget>("tree_map");
auto& statusbar = *mainwidget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
treemapwidget.set_focus(true);

View file

@ -45,14 +45,14 @@ CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet,
set_icon(parent->icon());
resize(285, 360);
auto& main_widget = set_main_widget<GUI::Widget>();
main_widget.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
main_widget.set_fill_with_background_color(true);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_layout<GUI::VerticalBoxLayout>().set_margins(4);
main_widget->set_fill_with_background_color(true);
auto& tab_widget = main_widget.add<GUI::TabWidget>();
auto& tab_widget = main_widget->add<GUI::TabWidget>();
setup_tabs(tab_widget, positions, sheet);
auto& buttonbox = main_widget.add<GUI::Widget>();
auto& buttonbox = main_widget->add<GUI::Widget>();
buttonbox.set_shrink_to_fit(true);
auto& button_layout = buttonbox.set_layout<GUI::HorizontalBoxLayout>();
button_layout.set_spacing(10);

View file

@ -67,11 +67,11 @@ HelpWindow::HelpWindow(GUI::Window* parent)
set_title("Spreadsheet Functions Help");
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"sv).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);
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
widget->set_layout<GUI::VerticalBoxLayout>();
widget->set_fill_with_background_color(true);
auto& splitter = widget.add<GUI::HorizontalSplitter>();
auto& splitter = widget->add<GUI::HorizontalSplitter>();
auto& left_frame = splitter.add<GUI::Frame>();
left_frame.set_layout<GUI::VerticalBoxLayout>();
// FIXME: Get rid of the magic number, dynamically calculate initial size based on left frame contents
@ -112,14 +112,14 @@ 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, NonnullRefPtrVector<Sheet> {}, false);
auto sheet = Sheet::from_json(value.as_object(), widget.workbook());
auto widget = window->set_main_widget<SpreadsheetWidget>(window, NonnullRefPtrVector<Sheet> {}, false).release_value_but_fixme_should_propagate_errors();
auto sheet = Sheet::from_json(value.as_object(), widget->workbook());
if (!sheet) {
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, url.path()));
return;
}
widget.add_sheet(sheet.release_nonnull());
widget->add_sheet(sheet.release_nonnull());
window->show();
} else if (url.host() == "doc") {
auto entry = LexicalPath::basename(url.path());

View file

@ -81,11 +81,11 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
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>();
inline_widget.set_fill_with_background_color(true);
inline_widget.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
inline_widget.set_frame_shape(Gfx::FrameShape::Box);
m_inline_documentation_label = inline_widget.add<GUI::Label>();
auto inline_widget = m_inline_documentation_window->set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors();
inline_widget->set_fill_with_background_color(true);
inline_widget->set_layout<GUI::VerticalBoxLayout>().set_margins(4);
inline_widget->set_frame_shape(Gfx::FrameShape::Box);
m_inline_documentation_label = inline_widget->add<GUI::Label>();
m_inline_documentation_label->set_fill_with_background_color(true);
m_inline_documentation_label->set_autosize(false);
m_inline_documentation_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);

View file

@ -58,13 +58,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(640, 480);
window->set_icon(app_icon.bitmap_for_size(16));
auto& spreadsheet_widget = window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, NonnullRefPtrVector<Spreadsheet::Sheet> {}, filename == nullptr);
auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, NonnullRefPtrVector<Spreadsheet::Sheet> {}, filename == nullptr));
spreadsheet_widget.initialize_menubar(*window);
spreadsheet_widget.update_window_title();
spreadsheet_widget->initialize_menubar(*window);
spreadsheet_widget->update_window_title();
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
if (spreadsheet_widget.request_close())
if (spreadsheet_widget->request_close())
return GUI::Window::CloseRequestDecision::Close;
return GUI::Window::CloseRequestDecision::StayOpen;
};
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (filename) {
auto file = TRY(FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, filename));
spreadsheet_widget.load_file(file);
spreadsheet_widget->load_file(file);
}
return app->exec();

View file

@ -278,7 +278,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_title("System Monitor");
window->resize(560, 430);
auto main_widget = TRY(window->try_set_main_widget<GUI::Widget>());
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
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");
@ -512,7 +512,7 @@ ErrorOr<NonnullRefPtr<GUI::Window>> build_process_window(pid_t pid)
auto app_icon = GUI::Icon::default_icon("app-system-monitor"sv);
window->set_icon(app_icon.bitmap_for_size(16));
auto main_widget = TRY(window->try_set_main_widget<GUI::Widget>());
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
main_widget->load_from_gml(process_window_gml);
GUI::ModelIndex process_index;

View file

@ -172,7 +172,7 @@ static ErrorOr<NonnullRefPtr<GUI::Window>> create_find_window(VT::TerminalWidget
window->set_resizable(false);
window->resize(300, 90);
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_background_role(ColorRole::Button);
(void)TRY(main_widget->try_set_layout<GUI::VerticalBoxLayout>());
@ -291,7 +291,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_title("Terminal");
window->set_obey_widget_min_size(false);
auto terminal = TRY(window->try_set_main_widget<VT::TerminalWidget>(ptm_fd, true));
auto terminal = TRY(window->set_main_widget<VT::TerminalWidget>(ptm_fd, true));
terminal->on_command_exit = [&] {
app->quit(0);
};

View file

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

View file

@ -47,7 +47,7 @@ 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->try_set_main_widget<ThemeEditor::MainWidget>());
auto main_widget = TRY(window->set_main_widget<ThemeEditor::MainWidget>());
if (path.has_value()) {
// Note: This is deferred to ensure that the window has already popped and thus proper window stealing can be performed.

View file

@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(640, 480);
window->set_resizable(true);
auto main_widget = TRY(window->try_set_main_widget<VideoPlayer::VideoPlayerWidget>(window));
auto main_widget = TRY(window->set_main_widget<VideoPlayer::VideoPlayerWidget>(window));
main_widget->update_title();
main_widget->initialize_menubar(window);

View file

@ -33,7 +33,7 @@ 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->try_set_main_widget<WelcomeWidget>());
auto welcome_widget = TRY(window->set_main_widget<WelcomeWidget>());
window->show();