summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-12-16 01:49:54 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-16 09:58:51 +0100
commit61789de11d6e7796b1d662bfda89a517ff07a50b (patch)
tree4295d744d3a7462d18e39547412fed1cafa28ab5 /Userland/Libraries/LibGUI
parentc355e9692dd0fd417003d9fd42e7fcfe7f6840da (diff)
downloadserenity-61789de11d6e7796b1d662bfda89a517ff07a50b.zip
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<Widget> 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.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/TabWidget.h7
1 files changed, 7 insertions, 0 deletions
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<void> add_tab(NonnullRefPtr<Widget> 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);