diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-23 21:36:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-23 21:36:17 +0200 |
commit | 312501f30917e8e22321a80fde294dd50a83012b (patch) | |
tree | efda9148c8a5de501ec56dd106bf3b80105e133d /Applications/Browser/main.cpp | |
parent | 476a4475e572b22128557f1d8a05bf6d948b56ac (diff) | |
download | serenity-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.cpp | 8 |
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"); |