mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
CharacterMap: Propagate errors from initialize_menubar()
This commit is contained in:
parent
b4f78760f2
commit
abe5787126
Notes:
sideshowbarker
2024-07-17 20:33:50 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/abe5787126 Pull-request: https://github.com/SerenityOS/serenity/pull/18410 Reviewed-by: https://github.com/AtkinsSJ
@ -149,19 +149,20 @@ CharacterMapWidget::CharacterMapWidget()
|
||||
update_statusbar();
|
||||
}
|
||||
|
||||
void CharacterMapWidget::initialize_menubar(GUI::Window& window)
|
||||
ErrorOr<void> CharacterMapWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto& file_menu = window.add_menu("&File"_short_string);
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([](GUI::Action&) {
|
||||
auto file_menu = TRY(window.try_add_menu("&File"_short_string));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](GUI::Action&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
})));
|
||||
|
||||
auto& help_menu = window.add_menu("&Help"_short_string);
|
||||
help_menu.add_action(GUI::CommonActions::make_command_palette_action(&window));
|
||||
help_menu.add_action(GUI::CommonActions::make_help_action([&](auto&) {
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"_short_string));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(&window)));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([&](auto&) {
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/CharacterMap.md"), "/bin/Help");
|
||||
}));
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Character Map", GUI::Icon::default_icon("app-character-map"sv), &window));
|
||||
})));
|
||||
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Character Map", GUI::Icon::default_icon("app-character-map"sv), &window)));
|
||||
return {};
|
||||
}
|
||||
|
||||
void CharacterMapWidget::did_change_font()
|
||||
|
@ -17,7 +17,7 @@ class CharacterMapWidget final : public GUI::Widget {
|
||||
public:
|
||||
virtual ~CharacterMapWidget() override = default;
|
||||
|
||||
void initialize_menubar(GUI::Window& window);
|
||||
ErrorOr<void> initialize_menubar(GUI::Window& window);
|
||||
|
||||
private:
|
||||
CharacterMapWidget();
|
||||
|
@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
window->resize(600, 400);
|
||||
|
||||
auto character_map_widget = TRY(window->set_main_widget<CharacterMapWidget>());
|
||||
character_map_widget->initialize_menubar(*window);
|
||||
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());
|
||||
character_map_widget->set_font(Gfx::FontDatabase::the().get_by_name(font_query));
|
||||
|
Loading…
Reference in New Issue
Block a user