mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
Browser: Provide ability to create new browser windows
This change allows a user to spawn new browser processes by either going to "File -> New Window" or by the shortcut "Ctrl + N".
This commit is contained in:
parent
48389f4179
commit
90719d34af
4 changed files with 21 additions and 0 deletions
|
@ -103,6 +103,10 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
|
|||
create_new_tab(Browser::url_from_user_input(Browser::g_new_tab_url), true);
|
||||
};
|
||||
|
||||
m_window_actions.on_create_new_window = [this] {
|
||||
GUI::Process::spawn_or_show_error(this, "/bin/Browser"sv);
|
||||
};
|
||||
|
||||
m_window_actions.on_next_tab = [this] {
|
||||
m_tab_widget->activate_next_tab();
|
||||
};
|
||||
|
@ -154,6 +158,7 @@ void BrowserWindow::build_menus()
|
|||
{
|
||||
auto& file_menu = add_menu("&File");
|
||||
file_menu.add_action(WindowActions::the().create_new_tab_action());
|
||||
file_menu.add_action(WindowActions::the().create_new_window_action());
|
||||
|
||||
auto close_tab_action = GUI::CommonActions::make_close_tab_action([this](auto&) {
|
||||
active_tab().on_tab_close_request(active_tab());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -32,6 +33,15 @@ WindowActions::WindowActions(GUI::Window& window)
|
|||
&window);
|
||||
m_create_new_tab_action->set_status_tip("Open a new tab");
|
||||
|
||||
m_create_new_window_action = GUI::Action::create(
|
||||
"&New Window", { Mod_Ctrl, Key_N }, g_icon_bag.go_to, [this](auto&) {
|
||||
if (on_create_new_window) {
|
||||
on_create_new_window();
|
||||
}
|
||||
},
|
||||
&window);
|
||||
m_create_new_window_action->set_status_tip("Open a new browser window");
|
||||
|
||||
m_next_tab_action = GUI::Action::create(
|
||||
"&Next Tab", { Mod_Ctrl, Key_PageDown }, [this](auto&) {
|
||||
if (on_next_tab)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -17,6 +18,7 @@ public:
|
|||
WindowActions(GUI::Window&);
|
||||
|
||||
Function<void()> on_create_new_tab;
|
||||
Function<void()> on_create_new_window;
|
||||
Function<void()> on_next_tab;
|
||||
Function<void()> on_previous_tab;
|
||||
Vector<Function<void()>> on_tabs;
|
||||
|
@ -25,6 +27,7 @@ public:
|
|||
Function<void(GUI::Action&)> on_vertical_tabs;
|
||||
|
||||
GUI::Action& create_new_tab_action() { return *m_create_new_tab_action; }
|
||||
GUI::Action& create_new_window_action() { return *m_create_new_window_action; }
|
||||
GUI::Action& next_tab_action() { return *m_next_tab_action; }
|
||||
GUI::Action& previous_tab_action() { return *m_previous_tab_action; }
|
||||
GUI::Action& about_action() { return *m_about_action; }
|
||||
|
@ -33,6 +36,7 @@ public:
|
|||
|
||||
private:
|
||||
RefPtr<GUI::Action> m_create_new_tab_action;
|
||||
RefPtr<GUI::Action> m_create_new_window_action;
|
||||
RefPtr<GUI::Action> m_next_tab_action;
|
||||
RefPtr<GUI::Action> m_previous_tab_action;
|
||||
NonnullRefPtrVector<GUI::Action> m_tab_actions;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -91,6 +92,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Core::System::unveil("/etc/passwd", "r"));
|
||||
TRY(Core::System::unveil("/etc/timezone", "r"));
|
||||
TRY(Core::System::unveil("/bin/BrowserSettings", "x"));
|
||||
TRY(Core::System::unveil("/bin/Browser", "x"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue