From 61789de11d6e7796b1d662bfda89a517ff07a50b Mon Sep 17 00:00:00 2001 From: Baitinq Date: Fri, 16 Dec 2022 01:49:54 +0100 Subject: [PATCH] LibGUI: Add GUI::TabWidget::add_tab() that takes a constructed tab This patch adds a new add_tab() function in GUI::TabWidget that takes an already created NonnullRefPtr object. This allows us to handle errors while creating the Tab object and then pass it to this function to actually add the object to the TabWidget. --- Userland/Libraries/LibGUI/TabWidget.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Libraries/LibGUI/TabWidget.h b/Userland/Libraries/LibGUI/TabWidget.h index 47a383a0a2..835d29d04b 100644 --- a/Userland/Libraries/LibGUI/TabWidget.h +++ b/Userland/Libraries/LibGUI/TabWidget.h @@ -73,6 +73,13 @@ public: return *t; } + ErrorOr add_tab(NonnullRefPtr const& tab, DeprecatedString title) + { + tab->set_title(move(title)); + TRY(try_add_widget(*tab)); + return {}; + } + void remove_tab(Widget& tab) { remove_widget(tab); } void remove_all_tabs_except(Widget& tab);