summaryrefslogtreecommitdiff
path: root/Applications/Browser/main.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-23 21:36:17 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-23 21:36:17 +0200
commit312501f30917e8e22321a80fde294dd50a83012b (patch)
treeefda9148c8a5de501ec56dd106bf3b80105e133d /Applications/Browser/main.cpp
parent476a4475e572b22128557f1d8a05bf6d948b56ac (diff)
downloadserenity-312501f30917e8e22321a80fde294dd50a83012b.zip
Browser: Add "Close tab" action (Ctrl+W) :^)
Note that this is a little bit unreliable with the keyboard shortcut since LibGUI can get confused about which Action it's supposed to use as each Browser::Tab has its own "close tab" action. This will need to be fixed in LibGUI.
Diffstat (limited to 'Applications/Browser/main.cpp')
-rw-r--r--Applications/Browser/main.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp
index 13ca696d17..16502bc97f 100644
--- a/Applications/Browser/main.cpp
+++ b/Applications/Browser/main.cpp
@@ -100,6 +100,14 @@ int main(int argc, char** argv)
window->set_title(String::format("%s - Browser", title.characters()));
};
+ new_tab.on_tab_close_request = [&](auto& tab) {
+ tab_widget.deferred_invoke([&](auto&) {
+ tab_widget.remove_tab(tab);
+ if (tab_widget.children().is_empty())
+ app.quit();
+ });
+ };
+
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"));
window->set_title("Browser");