diff options
Diffstat (limited to 'Userland')
47 files changed, 100 insertions, 110 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 6fc50f099c..3b4fdb0aba 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -290,7 +290,7 @@ Tab::Tab(Type type) m_menubar = GUI::MenuBar::construct(); - auto& app_menu = m_menubar->add_menu("Browser"); + auto& app_menu = m_menubar->add_menu("File"); app_menu.add_action(WindowActions::the().create_new_tab_action()); app_menu.add_action(GUI::Action::create( "Close tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::load_from_file("/res/icons/16x16/close-tab.png"), [this](auto&) { @@ -568,7 +568,7 @@ void Tab::did_become_active() m_toolbar_container->set_visible(!is_fullscreen); m_statusbar->set_visible(!is_fullscreen); - GUI::Application::the()->set_menubar(m_menubar); + window()->set_menubar(m_menubar); } void Tab::context_menu_requested(const Gfx::IntPoint& screen_position) diff --git a/Userland/Applications/Calculator/main.cpp b/Userland/Applications/Calculator/main.cpp index 79aaab58a4..5022b3da98 100644 --- a/Userland/Applications/Calculator/main.cpp +++ b/Userland/Applications/Calculator/main.cpp @@ -71,10 +71,9 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Calculator"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the()->quit(); - return; })); auto& edit_menu = menubar->add_menu("Edit"); @@ -93,8 +92,6 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Calculator", app_icon, window)); - - app->set_menubar(move(menubar)); - + window->set_menubar(move(menubar)); return app->exec(); } diff --git a/Userland/Applications/Calendar/main.cpp b/Userland/Applications/Calendar/main.cpp index 8406927b7f..57c734c298 100644 --- a/Userland/Applications/Calendar/main.cpp +++ b/Userland/Applications/Calendar/main.cpp @@ -159,7 +159,7 @@ int main(int argc, char** argv) }; auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Calendar"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::Action::create("Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, Gfx::Bitmap::load_from_file("/res/icons/16x16/add-event.png"), [&](const GUI::Action&) { AddEventDialog::show(calendar_widget.selected_date(), window); @@ -176,7 +176,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Calendar", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); app->exec(); } diff --git a/Userland/Applications/DisplaySettings/main.cpp b/Userland/Applications/DisplaySettings/main.cpp index a7a7a6de7d..6c51fe42c0 100644 --- a/Userland/Applications/DisplaySettings/main.cpp +++ b/Userland/Applications/DisplaySettings/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Display Settings"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](const GUI::Action&) { app->quit(); })); @@ -76,7 +76,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Display Settings", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); return app->exec(); } diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index d523074122..b783a97771 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -755,7 +755,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("File Manager"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(mkdir_action); app_menu.add_action(touch_action); app_menu.add_action(copy_action); @@ -814,7 +814,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("File Manager", GUI::Icon::default_icon("app-file-manager"), window)); - GUI::Application::the()->set_menubar(move(menubar)); + window->set_menubar(menubar); main_toolbar.add_action(go_back_action); main_toolbar.add_action(go_forward_action); diff --git a/Userland/Applications/FontEditor/main.cpp b/Userland/Applications/FontEditor/main.cpp index 61d14248dd..7055b49708 100644 --- a/Userland/Applications/FontEditor/main.cpp +++ b/Userland/Applications/FontEditor/main.cpp @@ -106,7 +106,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Font Editor"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { Optional<String> open_path = GUI::FilePicker::get_open_filepath(window); if (!open_path.has_value()) @@ -138,7 +138,6 @@ int main(int argc, char** argv) app_menu.add_separator(); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); - return; })); auto& help_menu = menubar->add_menu("Help"); @@ -148,8 +147,7 @@ int main(int argc, char** argv) help_menu.add_action(GUI::CommonActions::make_about_action("Font Editor", app_icon, window)); - app->set_menubar(move(menubar)); - + window->set_menubar(move(menubar)); window->show(); return app->exec(); diff --git a/Userland/Applications/Help/main.cpp b/Userland/Applications/Help/main.cpp index 50d2d816ae..22e6f83407 100644 --- a/Userland/Applications/Help/main.cpp +++ b/Userland/Applications/Help/main.cpp @@ -274,7 +274,7 @@ int main(int argc, char* argv[]) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Help"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_about_action("Help", app_icon, window)); app_menu.add_separator(); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { @@ -286,7 +286,7 @@ int main(int argc, char* argv[]) go_menu.add_action(*go_forward_action); go_menu.add_action(*go_home_action); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); if (start_page) { URL url = URL::create_with_url_or_path(start_page); diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index dea5484c75..7c7cda71f3 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -137,7 +137,7 @@ HexEditorWidget::~HexEditorWidget() void HexEditorWidget::initialize_menubar(GUI::MenuBar& menubar) { - auto& app_menu = menubar.add_menu("Hex Editor"); + auto& app_menu = menubar.add_menu("File"); app_menu.add_action(*m_new_action); app_menu.add_action(*m_open_action); app_menu.add_action(*m_save_action); diff --git a/Userland/Applications/HexEditor/main.cpp b/Userland/Applications/HexEditor/main.cpp index f9217af243..d83c428542 100644 --- a/Userland/Applications/HexEditor/main.cpp +++ b/Userland/Applications/HexEditor/main.cpp @@ -61,8 +61,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); hex_editor_widget.initialize_menubar(menubar); - app->set_menubar(menubar); - + window->set_menubar(menubar); window->show(); window->set_icon(app_icon.bitmap_for_size(16)); diff --git a/Userland/Applications/IRCClient/IRCAppWindow.cpp b/Userland/Applications/IRCClient/IRCAppWindow.cpp index 4e9706da15..383d3a8789 100644 --- a/Userland/Applications/IRCClient/IRCAppWindow.cpp +++ b/Userland/Applications/IRCClient/IRCAppWindow.cpp @@ -258,7 +258,7 @@ void IRCAppWindow::setup_actions() void IRCAppWindow::setup_menus() { auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("IRC Client"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { dbgln("Terminal: Quit menu activated!"); GUI::Application::the()->quit(); @@ -297,7 +297,7 @@ void IRCAppWindow::setup_menus() auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("IRC Client", GUI::Icon::default_icon("app-irc-client"), this)); - GUI::Application::the()->set_menubar(move(menubar)); + set_menubar(move(menubar)); } void IRCAppWindow::setup_widgets() diff --git a/Userland/Applications/KeyboardMapper/main.cpp b/Userland/Applications/KeyboardMapper/main.cpp index ad719dcbf3..10a8694c9f 100644 --- a/Userland/Applications/KeyboardMapper/main.cpp +++ b/Userland/Applications/KeyboardMapper/main.cpp @@ -106,7 +106,7 @@ int main(int argc, char** argv) // Menu auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Keyboard Mapper"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(open_action); app_menu.add_action(save_action); app_menu.add_action(save_as_action); @@ -116,7 +116,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Keyboard Mapper", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); return app->exec(); } diff --git a/Userland/Applications/KeyboardSettings/main.cpp b/Userland/Applications/KeyboardSettings/main.cpp index cc099d598a..9d03249bf8 100644 --- a/Userland/Applications/KeyboardSettings/main.cpp +++ b/Userland/Applications/KeyboardSettings/main.cpp @@ -188,13 +188,13 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Keyboard Settings"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(quit_action); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Keyboard Settings", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); diff --git a/Userland/Applications/MouseSettings/main.cpp b/Userland/Applications/MouseSettings/main.cpp index d9c026a1a8..451cd960ba 100644 --- a/Userland/Applications/MouseSettings/main.cpp +++ b/Userland/Applications/MouseSettings/main.cpp @@ -120,13 +120,13 @@ int main(int argc, char** argv) }; auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Mouse Settings"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Mouse Settings", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); return app->exec(); diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp index cceaf720ea..7f4d31dfaf 100644 --- a/Userland/Applications/Piano/main.cpp +++ b/Userland/Applications/Piano/main.cpp @@ -106,7 +106,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Piano"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) { save_path = GUI::FilePicker::get_save_filepath(window, "Untitled", "wav"); if (!save_path.has_value()) @@ -131,7 +131,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Piano", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); return app->exec(); } diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp index c8efb94830..bbaab8942a 100644 --- a/Userland/Applications/PixelPaint/main.cpp +++ b/Userland/Applications/PixelPaint/main.cpp @@ -115,7 +115,7 @@ int main(int argc, char** argv) window->show(); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("PixelPaint"); + auto& app_menu = menubar->add_menu("File"); auto open_image_file = [&](auto& path) { auto image = PixelPaint::Image::create_from_file(path); @@ -382,7 +382,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("PixelPaint", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); image_editor.on_active_layer_change = [&](auto* layer) { layer_list_widget.set_selected_layer(layer); diff --git a/Userland/Applications/QuickShow/main.cpp b/Userland/Applications/QuickShow/main.cpp index 331bffa714..fa083f207d 100644 --- a/Userland/Applications/QuickShow/main.cpp +++ b/Userland/Applications/QuickShow/main.cpp @@ -275,7 +275,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("QuickShow"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(open_action); app_menu.add_action(delete_action); app_menu.add_separator(); @@ -310,7 +310,7 @@ int main(int argc, char** argv) })); help_menu.add_action(GUI::CommonActions::make_about_action("QuickShow", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); if (path != nullptr) { widget.load_from_file(path); diff --git a/Userland/Applications/SoundPlayer/main.cpp b/Userland/Applications/SoundPlayer/main.cpp index 45752c089b..7a1946e6fc 100644 --- a/Userland/Applications/SoundPlayer/main.cpp +++ b/Userland/Applications/SoundPlayer/main.cpp @@ -66,7 +66,7 @@ int main(int argc, char** argv) window->set_icon(app_icon.bitmap_for_size(16)); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Sound Player"); + auto& app_menu = menubar->add_menu("File"); auto& player = window->set_main_widget<SoundPlayerWidget>(window, audio_client); if (argc > 1) { @@ -102,7 +102,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Sound Player", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); return app->exec(); diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 50d06bea1d..c0ae638bca 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -291,7 +291,7 @@ int main(int argc, char* argv[]) // Configure the menubar. auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu(APP_NAME); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::Action::create("Analyze", [&](auto&) { analyze(tree, treemapwidget, statusbar); })); @@ -300,7 +300,7 @@ int main(int argc, char* argv[]) })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action(APP_NAME, app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); // Configure the nodes context menu. auto open_folder_action = GUI::Action::create("Open Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) { diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index 2368174050..c2ecb7c2cd 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) spreadsheet_widget.load(filename); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Spreadsheet"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::Action::create("Add New Sheet", Gfx::Bitmap::load_from_file("/res/icons/16x16/new-tab.png"), [&](auto&) { spreadsheet_widget.add_sheet(); @@ -270,7 +270,7 @@ int main(int argc, char* argv[]) help_menu.add_action(GUI::CommonActions::make_about_action("Spreadsheet", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index 93e10b4476..b684ecea84 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -279,10 +279,9 @@ int main(int argc, char** argv) }); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("System Monitor"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the()->quit(); - return; })); auto& process_menu = menubar->add_menu("Process"); @@ -324,7 +323,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("System Monitor", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); auto& process_tab_unused_widget = process_container_splitter->add<UnavailableProcessWidget>("No process selected"); process_tab_unused_widget.set_visible(true); diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index d69ac2e3aa..89af1c5b0e 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -428,7 +428,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Terminal"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::Action::create("Open new Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { pid_t child; const char* argv[] = { "Terminal", nullptr }; @@ -473,7 +473,8 @@ int main(int argc, char** argv) })); help_menu.add_action(GUI::CommonActions::make_about_action("Terminal", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(menubar); + window->set_menubar(menubar); if (unveil("/res", "r") < 0) { perror("unveil"); diff --git a/Userland/Applications/TextEditor/TextEditorWidget.cpp b/Userland/Applications/TextEditor/TextEditorWidget.cpp index 68e78ed189..071076e9f0 100644 --- a/Userland/Applications/TextEditor/TextEditorWidget.cpp +++ b/Userland/Applications/TextEditor/TextEditorWidget.cpp @@ -361,7 +361,7 @@ TextEditorWidget::~TextEditorWidget() void TextEditorWidget::initialize_menubar(GUI::MenuBar& menubar) { - auto& app_menu = menubar.add_menu("Text Editor"); + auto& app_menu = menubar.add_menu("File"); app_menu.add_action(*m_new_action); app_menu.add_action(*m_open_action); app_menu.add_action(*m_save_action); diff --git a/Userland/Applications/TextEditor/main.cpp b/Userland/Applications/TextEditor/main.cpp index ab72dd97f2..7aa58a7218 100644 --- a/Userland/Applications/TextEditor/main.cpp +++ b/Userland/Applications/TextEditor/main.cpp @@ -87,7 +87,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); text_widget.initialize_menubar(menubar); - app->set_menubar(menubar); + window->set_menubar(menubar); if (file_to_edit) if (!text_widget.open_file(file_to_edit)) @@ -101,5 +101,7 @@ int main(int argc, char** argv) window->show(); window->set_icon(app_icon.bitmap_for_size(16)); + window->set_menubar(menubar); + return app->exec(); } diff --git a/Userland/Demos/CatDog/main.cpp b/Userland/Demos/CatDog/main.cpp index cc0c9576f8..6299f6e5c3 100644 --- a/Userland/Demos/CatDog/main.cpp +++ b/Userland/Demos/CatDog/main.cpp @@ -234,11 +234,11 @@ int main(int argc, char** argv) root_widget.layout()->set_spacing(0); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("CatDog Demo"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("CatDog Demo", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); root_widget.track_cursor_globally(); diff --git a/Userland/Demos/Cube/Cube.cpp b/Userland/Demos/Cube/Cube.cpp index 9c97fa8990..a5f78c5384 100644 --- a/Userland/Demos/Cube/Cube.cpp +++ b/Userland/Demos/Cube/Cube.cpp @@ -264,7 +264,7 @@ int main(int argc, char** argv) window->set_icon(app_icon.bitmap_for_size(16)); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Cube Demo"); + auto& app_menu = menubar->add_menu("File"); auto show_window_frame_action = GUI::Action::create_checkable("Show window frame", [&](auto& action) { cube.set_show_window_frame(action.is_checked()); }); @@ -276,7 +276,7 @@ int main(int argc, char** argv) app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Cube Demo", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); cube.on_context_menu_request = [&](auto& event) { app_menu.popup(event.screen_position()); diff --git a/Userland/Demos/Eyes/main.cpp b/Userland/Demos/Eyes/main.cpp index 5b120ae260..1cad75db3b 100644 --- a/Userland/Demos/Eyes/main.cpp +++ b/Userland/Demos/Eyes/main.cpp @@ -100,13 +100,13 @@ int main(int argc, char* argv[]) auto& eyes = window->set_main_widget<EyesWidget>(num_eyes, full_rows, extra_columns); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Eyes Demo"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Eyes Demo", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); eyes.track_cursor_globally(); diff --git a/Userland/Demos/Mouse/main.cpp b/Userland/Demos/Mouse/main.cpp index 547c510469..9878ae8dbb 100644 --- a/Userland/Demos/Mouse/main.cpp +++ b/Userland/Demos/Mouse/main.cpp @@ -199,13 +199,13 @@ int main(int argc, char** argv) main_widget.set_fill_with_background_color(true); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Mouse Demo"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Mouse Demo", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->set_resizable(false); window->show(); return app->exec(); diff --git a/Userland/Demos/WidgetGallery/main.cpp b/Userland/Demos/WidgetGallery/main.cpp index 63d3aa5a41..a63af424e8 100644 --- a/Userland/Demos/WidgetGallery/main.cpp +++ b/Userland/Demos/WidgetGallery/main.cpp @@ -77,14 +77,13 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Widget Gallery"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Widget Gallery", app_icon, window)); - app->set_menubar(move(menubar)); - + window->set_menubar(move(menubar)); window->show(); return app->exec(); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index dfb8611eb7..6861853a8a 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -888,7 +888,7 @@ void HackStudioWidget::create_action_tab(GUI::Widget& parent) void HackStudioWidget::create_app_menubar(GUI::MenuBar& menubar) { - auto& app_menu = menubar.add_menu("Hack Studio"); + auto& app_menu = menubar.add_menu("File"); app_menu.add_action(*m_new_project_action); app_menu.add_action(*m_open_action); app_menu.add_action(*m_save_action); diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index bc2636e6e9..fbeba335e3 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -99,7 +99,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); s_hack_studio_widget->initialize_menubar(menubar); - app->set_menubar(menubar); + s_window->set_menubar(menubar); s_window->show(); diff --git a/Userland/DevTools/Inspector/main.cpp b/Userland/DevTools/Inspector/main.cpp index 46f7e411b4..52c428a4a5 100644 --- a/Userland/DevTools/Inspector/main.cpp +++ b/Userland/DevTools/Inspector/main.cpp @@ -129,7 +129,7 @@ int main(int argc, char** argv) window->set_icon(app_icon.bitmap_for_size(16)); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Inspector"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); auto& help_menu = menubar->add_menu("Help"); @@ -168,7 +168,7 @@ int main(int argc, char** argv) remote_process.set_inspected_object(remote_object->address); }; - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); remote_process.update(); diff --git a/Userland/DevTools/Playground/main.cpp b/Userland/DevTools/Playground/main.cpp index dc63bd47b6..06e554e4e2 100644 --- a/Userland/DevTools/Playground/main.cpp +++ b/Userland/DevTools/Playground/main.cpp @@ -330,7 +330,7 @@ int main(int argc, char** argv) }; auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("GML Playground"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { Optional<String> open_path = GUI::FilePicker::get_open_filepath(window); @@ -400,7 +400,7 @@ int main(int argc, char** argv) })); help_menu.add_action(GUI::CommonActions::make_about_action("GML Playground", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); return app->exec(); diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index ea32b54be2..7491f24324 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -141,7 +141,7 @@ int main(int argc, char** argv) }; auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Profiler"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); auto& view_menu = menubar->add_menu("View"); @@ -185,8 +185,7 @@ int main(int argc, char** argv) })); help_menu.add_action(GUI::CommonActions::make_about_action("Profiler", app_icon, window)); - app->set_menubar(move(menubar)); - + window->set_menubar(move(menubar)); window->show(); return app->exec(); } diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index d82e42c293..5adbea5132 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -180,7 +180,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("2048"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](auto&) { start_a_new_game(); @@ -206,7 +206,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("2048", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); diff --git a/Userland/Games/Breakout/main.cpp b/Userland/Games/Breakout/main.cpp index c12a9d296f..af8e4d9a8c 100644 --- a/Userland/Games/Breakout/main.cpp +++ b/Userland/Games/Breakout/main.cpp @@ -69,23 +69,21 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Breakout"); + auto& app_menu = menubar->add_menu("Game"); app_menu.add_action(GUI::Action::create_checkable("Pause", { {}, Key_P }, [&](auto& action) { game.set_paused(action.is_checked()); - return; })); app_menu.add_separator(); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the()->quit(); - return; })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Breakout", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); return app->exec(); } diff --git a/Userland/Games/Chess/main.cpp b/Userland/Games/Chess/main.cpp index 540cfe5587..2cf90b73e9 100644 --- a/Userland/Games/Chess/main.cpp +++ b/Userland/Games/Chess/main.cpp @@ -96,7 +96,7 @@ int main(int argc, char** argv) widget.set_coordinates(config->read_bool_entry("Style", "Coordinates", true)); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Chess"); + auto& app_menu = menubar->add_menu("Game"); app_menu.add_action(GUI::Action::create("Resign", { Mod_None, Key_F3 }, [&](auto&) { widget.resign(); @@ -223,7 +223,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Chess", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); widget.reset(); diff --git a/Userland/Games/Conway/main.cpp b/Userland/Games/Conway/main.cpp index f103cabfbb..bc7210b86b 100644 --- a/Userland/Games/Conway/main.cpp +++ b/Userland/Games/Conway/main.cpp @@ -71,7 +71,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Conway"); + auto& app_menu = menubar->add_menu("Game"); app_menu.add_action(GUI::Action::create("Reset", { Mod_None, Key_F2 }, [&](auto&) { game.reset(); @@ -84,7 +84,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Conway", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); diff --git a/Userland/Games/Minesweeper/main.cpp b/Userland/Games/Minesweeper/main.cpp index 2541234426..d0d09f4c42 100644 --- a/Userland/Games/Minesweeper/main.cpp +++ b/Userland/Games/Minesweeper/main.cpp @@ -105,7 +105,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Minesweeper"); + auto& app_menu = menubar->add_menu("Game"); app_menu.add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](auto&) { field.reset(); @@ -143,7 +143,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Minesweeper", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); diff --git a/Userland/Games/Pong/main.cpp b/Userland/Games/Pong/main.cpp index 34ebe0f239..24829629ca 100644 --- a/Userland/Games/Pong/main.cpp +++ b/Userland/Games/Pong/main.cpp @@ -76,16 +76,15 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Pong"); + auto& app_menu = menubar->add_menu("Game"); app_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the()->quit(); - return; })); auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Pong", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); return app->exec(); } diff --git a/Userland/Games/Snake/main.cpp b/Userland/Games/Snake/main.cpp index e48de628c3..9a6e1d87f9 100644 --- a/Userland/Games/Snake/main.cpp +++ b/Userland/Games/Snake/main.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Snake"); + auto& app_menu = menubar->add_menu("Game"); app_menu.add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](auto&) { game.reset(); @@ -93,7 +93,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Snake", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->show(); diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index 0979e842a0..7879b9269f 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -64,7 +64,7 @@ int main(int argc, char** argv) }); auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("Solitaire"); + auto& app_menu = menubar->add_menu("Game"); app_menu.add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](auto&) { widget->setup(); @@ -75,7 +75,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("Solitaire", app_icon, window)); - app->set_menubar(move(menubar)); + window->set_menubar(move(menubar)); window->set_main_widget(widget); window->set_icon(app_icon.bitmap_for_size(16)); window->show(); diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 73e4caa964..da40d8edfe 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -125,15 +125,6 @@ void Application::quit(int exit_code) m_event_loop->quit(exit_code); } -void Application::set_menubar(RefPtr<MenuBar> menubar) -{ - if (m_menubar) - m_menubar->notify_removed_from_application({}); - m_menubar = move(menubar); - if (m_menubar) - m_menubar->notify_added_to_application({}); -} - void Application::register_global_shortcut_action(Badge<Action>, Action& action) { m_global_shortcut_actions.set(action.shortcut(), &action); diff --git a/Userland/Libraries/LibGUI/Application.h b/Userland/Libraries/LibGUI/Application.h index 32731c8853..b1710ce8dd 100644 --- a/Userland/Libraries/LibGUI/Application.h +++ b/Userland/Libraries/LibGUI/Application.h @@ -49,7 +49,6 @@ public: int exec(); void quit(int = 0); - void set_menubar(RefPtr<MenuBar>); Action* action_for_key_event(const KeyEvent&); void register_global_shortcut_action(Badge<Action>, Action&); @@ -106,7 +105,6 @@ private: void set_pending_drop_widget(Widget*); OwnPtr<Core::EventLoop> m_event_loop; - RefPtr<MenuBar> m_menubar; RefPtr<Gfx::PaletteImpl> m_palette; RefPtr<Gfx::PaletteImpl> m_system_palette; HashMap<Shortcut, Action*> m_global_shortcut_actions; diff --git a/Userland/Libraries/LibGUI/MenuBar.cpp b/Userland/Libraries/LibGUI/MenuBar.cpp index 1900aa046c..3fc5f65617 100644 --- a/Userland/Libraries/LibGUI/MenuBar.cpp +++ b/Userland/Libraries/LibGUI/MenuBar.cpp @@ -61,7 +61,7 @@ void MenuBar::unrealize_menubar() m_menubar_id = -1; } -void MenuBar::notify_added_to_application(Badge<Application>) +void MenuBar::notify_added_to_window(Badge<Window>) { VERIFY(m_menubar_id == -1); m_menubar_id = realize_menubar(); @@ -71,10 +71,9 @@ void MenuBar::notify_added_to_application(Badge<Application>) VERIFY(menu_id != -1); WindowServerConnection::the().send_sync<Messages::WindowServer::AddMenuToMenubar>(m_menubar_id, menu_id); } - WindowServerConnection::the().send_sync<Messages::WindowServer::SetApplicationMenubar>(m_menubar_id); } -void MenuBar::notify_removed_from_application(Badge<Application>) +void MenuBar::notify_removed_from_window(Badge<Window>) { unrealize_menubar(); } diff --git a/Userland/Libraries/LibGUI/MenuBar.h b/Userland/Libraries/LibGUI/MenuBar.h index 5e223cff9e..971bc5559e 100644 --- a/Userland/Libraries/LibGUI/MenuBar.h +++ b/Userland/Libraries/LibGUI/MenuBar.h @@ -41,8 +41,8 @@ public: Menu& add_menu(String name); - void notify_added_to_application(Badge<Application>); - void notify_removed_from_application(Badge<Application>); + void notify_added_to_window(Badge<Window>); + void notify_removed_from_window(Badge<Window>); int menubar_id() const { return m_menubar_id; } diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index a7f3c79911..23332112b1 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,6 +110,8 @@ Window::Window(Core::Object* parent) Window::~Window() { + if (m_menubar) + m_menubar->notify_removed_from_window({}); all_windows->remove(this); hide(); } @@ -161,6 +163,12 @@ void Window::show() apply_icon(); + if (m_menubar) { + // This little dance makes us create a server-side menubar. + auto menubar = move(m_menubar); + set_menubar(menubar); + } + reified_windows->set(m_window_id, this); Application::the()->did_create_window({}); update(); @@ -1057,9 +1065,13 @@ void Window::set_menubar(RefPtr<MenuBar> menubar) { if (m_menubar == menubar) return; + if (m_menubar) + m_menubar->notify_removed_from_window({}); m_menubar = move(menubar); - if (m_window_id && m_menubar) + if (m_window_id && m_menubar) { + m_menubar->notify_added_to_window({}); WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowMenubar>(m_window_id, m_menubar->menubar_id()); + } } } diff --git a/Userland/Utilities/html.cpp b/Userland/Utilities/html.cpp index ec4da58e4e..b4fda8e353 100644 --- a/Userland/Utilities/html.cpp +++ b/Userland/Utilities/html.cpp @@ -69,7 +69,7 @@ int main(int argc, char** argv) auto menubar = GUI::MenuBar::construct(); - auto& app_menu = menubar->add_menu("HTML"); + auto& app_menu = menubar->add_menu("File"); app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); })); @@ -77,8 +77,7 @@ int main(int argc, char** argv) auto& help_menu = menubar->add_menu("Help"); help_menu.add_action(GUI::CommonActions::make_about_action("HTML", GUI::Icon::default_icon("filetype-html"), window)); - app->set_menubar(move(menubar)); - + window->set_menubar(move(menubar)); window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); return app->exec(); |