mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 20:07: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:
parent
d223477bc6
commit
0c24522635
121 changed files with 441 additions and 449 deletions
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue