diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2022-12-26 18:12:43 -0500 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-12-27 09:28:16 -0500 |
commit | 352c1fec2d5c60cb6fb97f193aebaf5bb29ad611 (patch) | |
tree | de8a08ae3f6244aefd95b63c01565d952dffdefc /Userland | |
parent | 10626e6c6c0c89191ab0f1b531621a9fcf30eb2c (diff) | |
download | serenity-352c1fec2d5c60cb6fb97f193aebaf5bb29ad611.zip |
Taskbar: Propagate more errors on widget population
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Services/Taskbar/TaskbarWindow.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index 2c6e3e9c34..d52a52b0fd 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -68,40 +68,36 @@ TaskbarWindow::TaskbarWindow() set_title("Taskbar"); on_screen_rects_change(GUI::Desktop::the().rects(), GUI::Desktop::the().main_screen_index()); - - auto& main_widget = set_main_widget<TaskbarWidget>(); - main_widget.set_layout<GUI::HorizontalBoxLayout>(); - main_widget.layout()->set_margins({ 2, 3, 0, 3 }); } ErrorOr<void> TaskbarWindow::populate_taskbar() { - if (!main_widget()) - return Error::from_string_literal("TaskbarWindow::populate_taskbar: main_widget is not set"); + auto main_widget = TRY(try_set_main_widget<TaskbarWidget>()); + (void)TRY(main_widget->try_set_layout<GUI::HorizontalBoxLayout>()); + main_widget->layout()->set_margins({ 2, 3, 0, 3 }); m_quick_launch = TRY(Taskbar::QuickLaunchWidget::create()); - main_widget()->add_child(*m_quick_launch); + TRY(main_widget->try_add_child(*m_quick_launch)); - m_task_button_container = main_widget()->add<GUI::Widget>(); - m_task_button_container->set_layout<GUI::HorizontalBoxLayout>(); + m_task_button_container = TRY(main_widget->try_add<GUI::Widget>()); + (void)TRY(m_task_button_container->try_set_layout<GUI::HorizontalBoxLayout>()); m_task_button_container->layout()->set_spacing(3); m_default_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"sv)); - m_applet_area_container = main_widget()->add<GUI::Frame>(); + m_applet_area_container = TRY(main_widget->try_add<GUI::Frame>()); m_applet_area_container->set_frame_thickness(1); m_applet_area_container->set_frame_shape(Gfx::FrameShape::Box); m_applet_area_container->set_frame_shadow(Gfx::FrameShadow::Sunken); - m_clock_widget = main_widget()->add<Taskbar::ClockWidget>(); + m_clock_widget = TRY(main_widget->try_add<Taskbar::ClockWidget>()); - m_show_desktop_button = GUI::Button::construct(); + m_show_desktop_button = TRY(main_widget->try_add<GUI::Button>()); m_show_desktop_button->set_tooltip("Show Desktop"); - m_show_desktop_button->set_icon(GUI::Icon::default_icon("desktop"sv).bitmap_for_size(16)); + m_show_desktop_button->set_icon(TRY(GUI::Icon::try_create_default_icon("desktop"sv)).bitmap_for_size(16)); m_show_desktop_button->set_button_style(Gfx::ButtonStyle::Coolbar); m_show_desktop_button->set_fixed_size(24, 24); m_show_desktop_button->on_click = TaskbarWindow::show_desktop_button_clicked; - main_widget()->add_child(*m_show_desktop_button); return {}; } |