LibGUI: Make GMenu inherit from CObject

This is primarily to make it possible to pass a GMenu* where a CObject*
is expected.
This commit is contained in:
Andreas Kling 2019-12-09 21:05:28 +01:00
parent e9dda8d592
commit fd5eb79d19
Notes: sideshowbarker 2024-07-19 10:54:17 +09:00
39 changed files with 88 additions and 86 deletions

View file

@ -126,7 +126,7 @@ int main(int argc, char** argv)
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Browser");
auto app_menu = GMenu::construct("Browser");
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) {
app.quit();
}));
@ -135,7 +135,7 @@ int main(int argc, char** argv)
RefPtr<GWindow> dom_inspector_window;
RefPtr<GTreeView> dom_tree_view;
auto inspect_menu = make<GMenu>("Inspect");
auto inspect_menu = GMenu::construct("Inspect");
inspect_menu->add_action(GAction::create("View source", { Mod_Ctrl, Key_U }, [&](auto&) {
String filename_to_open;
char tmp_filename[] = "/tmp/view-source.XXXXXX";
@ -176,7 +176,7 @@ int main(int argc, char** argv)
}));
menubar->add_menu(move(inspect_menu));
auto debug_menu = make<GMenu>("Debug");
auto debug_menu = GMenu::construct("Debug");
debug_menu->add_action(GAction::create("Dump DOM tree", [&](auto&) {
dump_tree(*html_widget->document());
}));
@ -199,7 +199,7 @@ int main(int argc, char** argv)
debug_menu->add_action(line_box_borders_action);
menubar->add_menu(move(debug_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("Browser", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window);
}));

View file

@ -322,7 +322,7 @@ int main(int argc, char** argv)
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("File Manager");
auto app_menu = GMenu::construct("File Manager");
app_menu->add_action(mkdir_action);
app_menu->add_action(copy_action);
app_menu->add_action(paste_action);
@ -333,19 +333,19 @@ int main(int argc, char** argv)
}));
menubar->add_menu(move(app_menu));
auto view_menu = make<GMenu>("View");
auto view_menu = GMenu::construct("View");
view_menu->add_action(*view_as_icons_action);
view_menu->add_action(*view_as_table_action);
menubar->add_menu(move(view_menu));
auto go_menu = make<GMenu>("Go");
auto go_menu = GMenu::construct("Go");
go_menu->add_action(go_back_action);
go_menu->add_action(go_forward_action);
go_menu->add_action(open_parent_directory_action);
go_menu->add_action(go_home_action);
menubar->add_menu(move(go_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [](const GAction&) {
dbgprintf("FIXME: Implement Help/About\n");
}));
@ -412,14 +412,14 @@ int main(int argc, char** argv)
}
});
auto directory_context_menu = make<GMenu>();
auto directory_context_menu = GMenu::construct();
directory_context_menu->add_action(copy_action);
directory_context_menu->add_action(paste_action);
directory_context_menu->add_action(delete_action);
directory_context_menu->add_separator();
directory_context_menu->add_action(properties_action);
auto file_context_menu = make<GMenu>();
auto file_context_menu = GMenu::construct();
file_context_menu->add_action(copy_action);
file_context_menu->add_action(paste_action);
file_context_menu->add_action(delete_action);
@ -428,7 +428,7 @@ int main(int argc, char** argv)
file_context_menu->add_separator();
file_context_menu->add_action(properties_action);
auto directory_view_context_menu = make<GMenu>();
auto directory_view_context_menu = GMenu::construct();
directory_view_context_menu->add_action(mkdir_action);
directory_view->on_context_menu_request = [&](const GAbstractView&, const GModelIndex& index, const GContextMenuEvent& event) {

View file

@ -129,7 +129,7 @@ int main(int argc, char* argv[])
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Help");
auto app_menu = GMenu::construct("Help");
app_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("Help", load_png("/res/icons/16x16/book.png"), window);
}));
@ -139,7 +139,7 @@ int main(int argc, char* argv[])
}));
menubar->add_menu(move(app_menu));
auto go_menu = make<GMenu>("Go");
auto go_menu = GMenu::construct("Go");
go_menu->add_action(*go_back_action);
go_menu->add_action(*go_forward_action);
menubar->add_menu(move(go_menu));

View file

@ -106,7 +106,7 @@ HexEditorWidget::HexEditorWidget()
});
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Hex Editor");
auto app_menu = GMenu::construct("Hex Editor");
app_menu->add_action(*m_new_action);
app_menu->add_action(*m_open_action);
app_menu->add_action(*m_save_action);
@ -119,7 +119,7 @@ HexEditorWidget::HexEditorWidget()
}));
menubar->add_menu(move(app_menu));
auto bytes_per_row_menu = make<GMenu>("Bytes Per Row");
auto bytes_per_row_menu = GMenu::construct("Bytes Per Row");
for (int i = 8; i <= 32; i += 8) {
bytes_per_row_menu->add_action(GAction::create(String::number(i), [this, i](auto&) {
m_editor->set_bytes_per_row(i);
@ -146,7 +146,7 @@ HexEditorWidget::HexEditorWidget()
}
});
auto edit_menu = make<GMenu>("Edit");
auto edit_menu = GMenu::construct("Edit");
edit_menu->add_action(GAction::create("Fill selection...", [&](const GAction&) {
auto input_box = GInputBox::construct("Fill byte (hex):", "Fill Selection", this);
if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) {
@ -170,11 +170,11 @@ HexEditorWidget::HexEditorWidget()
}));
menubar->add_menu(move(edit_menu));
auto view_menu = make<GMenu>("View");
auto view_menu = GMenu::construct("View");
view_menu->add_submenu(move(bytes_per_row_menu));
menubar->add_menu(move(view_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("Hex Editor", load_png("/res/icons/32x32/app-hexeditor.png"), window());
}));

View file

@ -123,7 +123,7 @@ void IRCAppWindow::setup_actions()
void IRCAppWindow::setup_menus()
{
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("IRC Client");
auto app_menu = GMenu::construct("IRC Client");
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
dbgprintf("Terminal: Quit menu activated!\n");
GApplication::the().quit(0);
@ -131,7 +131,7 @@ void IRCAppWindow::setup_menus()
}));
menubar->add_menu(move(app_menu));
auto server_menu = make<GMenu>("Server");
auto server_menu = GMenu::construct("Server");
server_menu->add_action(*m_change_nick_action);
server_menu->add_separator();
server_menu->add_action(*m_join_action);
@ -142,7 +142,7 @@ void IRCAppWindow::setup_menus()
server_menu->add_action(*m_close_query_action);
menubar->add_menu(move(server_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [this](const GAction&) {
GAboutDialog::show("IRC Client", load_png("/res/icons/32x32/app-irc-client.png"), this);
}));

View file

@ -48,7 +48,7 @@ void EraseTool::on_mousemove(GMouseEvent& event)
void EraseTool::on_contextmenu(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
NonnullRefPtr<GAction> eraser_color_toggler = GAction::create("Use secondary color", [&](GAction& action) {
bool toggled = !m_use_secondary_color;

View file

@ -18,7 +18,7 @@ private:
Color get_color() const;
virtual const char* class_name() const override { return "EraseTool"; }
Rect build_rect(const Point& pos, const Rect& widget_rect);
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
bool m_use_secondary_color { true };
int m_thickness { 1 };

View file

@ -70,7 +70,7 @@ void LineTool::on_keydown(GKeyEvent& event)
void LineTool::on_contextmenu(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(GAction::create("1", [this](auto&) {
m_thickness = 1;
}));

View file

@ -23,6 +23,6 @@ private:
GMouseButton m_drawing_button { GMouseButton::None };
Point m_line_start_position;
Point m_line_end_position;
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
int m_thickness { 1 };
};

View file

@ -50,7 +50,7 @@ void PenTool::on_mousemove(GMouseEvent& event)
void PenTool::on_contextmenu(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(GAction::create("1", [this](auto&) {
m_thickness = 1;
}));

View file

@ -19,6 +19,6 @@ private:
virtual const char* class_name() const override { return "PenTool"; }
Point m_last_drawing_event_position { -1, -1 };
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
int m_thickness { 1 };
};

View file

@ -76,7 +76,7 @@ void SprayTool::on_mouseup(GMouseEvent&)
void SprayTool::on_contextmenu(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(GAction::create("1", [this](auto&) {
m_thickness = 1;
}));

View file

@ -22,6 +22,6 @@ private:
RefPtr<CTimer> m_timer;
Point m_last_pos;
Color m_color;
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
int m_thickness { 1 };
};

View file

@ -39,7 +39,7 @@ int main(int argc, char** argv)
window->show();
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("PaintBrush");
auto app_menu = GMenu::construct("PaintBrush");
app_menu->add_action(GCommonActions::make_open_action([&](auto&) {
Optional<String> open_path = GFilePicker::get_open_filepath();
@ -62,10 +62,10 @@ int main(int argc, char** argv)
menubar->add_menu(move(app_menu));
auto edit_menu = make<GMenu>("Edit");
auto edit_menu = GMenu::construct("Edit");
menubar->add_menu(move(edit_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](auto&) {
GAboutDialog::show("PaintBrush", load_png("/res/icons/32x32/app-paintbrush.png"), window);
}));

View file

@ -44,7 +44,7 @@ int main(int argc, char** argv)
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Piano");
auto app_menu = GMenu::construct("Piano");
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
GApplication::the().quit(0);
return;

View file

@ -15,17 +15,17 @@ int main(int argc, char** argv)
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("QuickShow");
auto app_menu = GMenu::construct("QuickShow");
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
GApplication::the().quit(0);
return;
}));
menubar->add_menu(move(app_menu));
auto file_menu = make<GMenu>("File");
auto file_menu = GMenu::construct("File");
menubar->add_menu(move(file_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [](const GAction&) {
dbgprintf("FIXME: Implement Help/About\n");
}));

View file

@ -24,7 +24,7 @@ int main(int argc, char** argv)
window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-sound-player.png"));
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("SoundPlayer");
auto app_menu = GMenu::construct("SoundPlayer");
auto player = SoundPlayerWidget::construct(window, audio_client);
if (argc > 1) {
@ -51,7 +51,7 @@ int main(int argc, char** argv)
app.quit();
}));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [](auto&) {
GAboutDialog::show("SoundPlayer", GraphicsBitmap::load_from_file("/res/icons/32x32/app-sound-player.png"));
}));

View file

@ -116,20 +116,20 @@ int main(int argc, char** argv)
window->set_main_widget(keeper);
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("System Monitor");
auto app_menu = GMenu::construct("System Monitor");
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
GApplication::the().quit(0);
return;
}));
menubar->add_menu(move(app_menu));
auto process_menu = make<GMenu>("Process");
auto process_menu = GMenu::construct("Process");
process_menu->add_action(kill_action);
process_menu->add_action(stop_action);
process_menu->add_action(continue_action);
menubar->add_menu(move(process_menu));
auto process_context_menu = make<GMenu>();
auto process_context_menu = GMenu::construct();
process_context_menu->add_action(kill_action);
process_context_menu->add_action(stop_action);
process_context_menu->add_action(continue_action);
@ -138,7 +138,7 @@ int main(int argc, char** argv)
process_context_menu->popup(event.screen_position());
};
auto frequency_menu = make<GMenu>("Frequency");
auto frequency_menu = GMenu::construct("Frequency");
frequency_menu->add_action(GAction::create("0.25 sec", [&](auto&) {
refresh_timer->restart(250);
}));
@ -156,7 +156,7 @@ int main(int argc, char** argv)
}));
menubar->add_menu(move(frequency_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("SystemMonitor", load_png("/res/icons/32x32/app-system-monitor.png"), window);
}));

View file

@ -195,7 +195,7 @@ int main(int argc, char** argv)
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Terminal");
auto app_menu = GMenu::construct("Terminal");
app_menu->add_action(GAction::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) {
if (!fork()) {
execl("/bin/Terminal", "Terminal", nullptr);
@ -221,12 +221,12 @@ int main(int argc, char** argv)
}));
menubar->add_menu(move(app_menu));
auto edit_menu = make<GMenu>("Edit");
auto edit_menu = GMenu::construct("Edit");
edit_menu->add_action(terminal->copy_action());
edit_menu->add_action(terminal->paste_action());
menubar->add_menu(move(edit_menu));
auto font_menu = make<GMenu>("Font");
auto font_menu = GMenu::construct("Font");
GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
font_menu->add_action(GAction::create(font_name, [&](const GAction& action) {
terminal->set_font(GFontDatabase::the().get_by_name(action.text()));
@ -239,7 +239,7 @@ int main(int argc, char** argv)
});
menubar->add_menu(move(font_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("Terminal", load_png("/res/icons/32x32/app-terminal.png"), window);
}));

View file

@ -192,7 +192,7 @@ TextEditorWidget::TextEditorWidget()
m_line_wrapping_setting_action->set_checked(m_editor->is_line_wrapping_enabled());
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Text Editor");
auto app_menu = GMenu::construct("Text Editor");
app_menu->add_action(*m_new_action);
app_menu->add_action(*m_open_action);
app_menu->add_action(*m_save_action);
@ -205,7 +205,7 @@ TextEditorWidget::TextEditorWidget()
}));
menubar->add_menu(move(app_menu));
auto edit_menu = make<GMenu>("Edit");
auto edit_menu = GMenu::construct("Edit");
edit_menu->add_action(m_editor->undo_action());
edit_menu->add_action(m_editor->redo_action());
edit_menu->add_separator();
@ -219,7 +219,7 @@ TextEditorWidget::TextEditorWidget()
edit_menu->add_action(*m_find_previous_action);
menubar->add_menu(move(edit_menu));
auto font_menu = make<GMenu>("Font");
auto font_menu = GMenu::construct("Font");
GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
font_menu->add_action(GAction::create(font_name, [this](const GAction& action) {
m_editor->set_font(GFontDatabase::the().get_by_name(action.text()));
@ -227,13 +227,13 @@ TextEditorWidget::TextEditorWidget()
}));
});
auto view_menu = make<GMenu>("View");
auto view_menu = GMenu::construct("View");
view_menu->add_action(*m_line_wrapping_setting_action);
view_menu->add_separator();
view_menu->add_submenu(move(font_menu));
menubar->add_menu(move(view_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("TextEditor", load_png("/res/icons/32x32/app-texteditor.png"), window());
}));

View file

@ -348,19 +348,19 @@ int main(int argc, char** argv)
});
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("HackStudio");
auto app_menu = GMenu::construct("HackStudio");
app_menu->add_action(save_action);
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) {
app.quit();
}));
menubar->add_menu(move(app_menu));
auto project_menu = make<GMenu>("Project");
auto project_menu = GMenu::construct("Project");
project_menu->add_action(new_action);
project_menu->add_action(add_existing_file_action);
menubar->add_menu(move(project_menu));
auto edit_menu = make<GMenu>("Edit");
auto edit_menu = GMenu::construct("Edit");
edit_menu->add_action(GAction::create("Find in files...", { Mod_Ctrl | Mod_Shift, Key_F }, [&](auto&) {
reveal_action_tab(find_in_files_widget);
find_in_files_widget->focus_textbox_and_select_all();
@ -391,13 +391,13 @@ int main(int argc, char** argv)
toolbar->add_action(run_action);
toolbar->add_action(stop_action);
auto build_menu = make<GMenu>("Build");
auto build_menu = GMenu::construct("Build");
build_menu->add_action(build_action);
build_menu->add_action(run_action);
build_menu->add_action(stop_action);
menubar->add_menu(move(build_menu));
auto view_menu = make<GMenu>("View");
auto view_menu = GMenu::construct("View");
view_menu->add_action(hide_action_tabs_action);
view_menu->add_action(open_locator_action);
view_menu->add_separator();
@ -407,7 +407,7 @@ int main(int argc, char** argv)
auto small_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/app-hack-studio.png");
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](auto&) {
GAboutDialog::show("HackStudio", small_icon, g_window);
}));

View file

@ -28,7 +28,7 @@ VBForm::VBForm(const String& name, GWidget* parent)
set_background_color(Color::WarmGray);
set_greedy_for_hits(true);
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(GCommonActions::make_move_to_front_action([this](auto&) {
if (auto* widget = single_selected_widget())
widget->gwidget()->move_to_front();

View file

@ -61,5 +61,5 @@ private:
Point m_next_insertion_position;
Direction m_resize_direction { Direction::None };
Direction m_mouse_direction_type { Direction::None };
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
};

View file

@ -31,14 +31,14 @@ int main(int argc, char** argv)
};
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Visual Builder");
auto app_menu = GMenu::construct("Visual Builder");
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
GApplication::the().quit(0);
return;
}));
menubar->add_menu(move(app_menu));
auto file_menu = make<GMenu>("File");
auto file_menu = GMenu::construct("File");
file_menu->add_action(GAction::create("Dump Form", [&](auto&) {
form1->dump();
}));
@ -54,7 +54,7 @@ int main(int argc, char** argv)
window->show();
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("Visual Builder", load_png("/res/icons/32x32/app-visual-builder.png"), window);
}));

View file

@ -46,7 +46,7 @@ int main(int argc, char** argv)
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Minesweeper");
auto app_menu = GMenu::construct("Minesweeper");
app_menu->add_action(GAction::create("New game", { Mod_None, Key_F2 }, [&](const GAction&) {
field->reset();
@ -73,7 +73,7 @@ int main(int argc, char** argv)
}));
menubar->add_menu(move(app_menu));
auto difficulty_menu = make<GMenu>("Difficulty");
auto difficulty_menu = GMenu::construct("Difficulty");
difficulty_menu->add_action(GAction::create("Beginner", { Mod_Ctrl, Key_B }, [&](const GAction&) {
field->set_field_size(9, 9, 10);
}));
@ -88,7 +88,7 @@ int main(int argc, char** argv)
}));
menubar->add_menu(move(difficulty_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [](const GAction&) {
dbgprintf("FIXME: Implement Help/About\n");
}));

View file

@ -23,7 +23,7 @@ int main(int argc, char** argv)
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Snake");
auto app_menu = GMenu::construct("Snake");
app_menu->add_action(GAction::create("New game", { Mod_None, Key_F2 }, [&](const GAction&) {
game->reset();
@ -34,7 +34,7 @@ int main(int argc, char** argv)
menubar->add_menu(move(app_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [](const GAction&) {
dbgprintf("FIXME: Implement Help/About\n");
}));

View file

@ -39,7 +39,7 @@ void GMenu::add_action(NonnullRefPtr<GAction> action)
#endif
}
void GMenu::add_submenu(NonnullOwnPtr<GMenu> submenu)
void GMenu::add_submenu(NonnullRefPtr<GMenu> submenu)
{
m_items.append(make<GMenuItem>(m_menu_id, move(submenu)));
}

View file

@ -3,15 +3,17 @@
#include <AK/Function.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/NonnullRefPtr.h>
#include <LibCore/CObject.h>
#include <LibGUI/GMenuItem.h>
class GAction;
class Point;
class GMenu {
class GMenu final : public CObject {
C_OBJECT(GMenu)
public:
explicit GMenu(const StringView& name = "");
~GMenu();
virtual ~GMenu() override;
static GMenu* from_menu_id(int);
@ -21,7 +23,7 @@ public:
void add_action(NonnullRefPtr<GAction>);
void add_separator();
void add_submenu(NonnullOwnPtr<GMenu>);
void add_submenu(NonnullRefPtr<GMenu>);
void popup(const Point& screen_position);
void dismiss();

View file

@ -10,7 +10,7 @@ GMenuBar::~GMenuBar()
unrealize_menubar();
}
void GMenuBar::add_menu(NonnullOwnPtr<GMenu>&& menu)
void GMenuBar::add_menu(NonnullRefPtr<GMenu> menu)
{
m_menus.append(move(menu));
}

View file

@ -11,7 +11,7 @@ public:
GMenuBar();
~GMenuBar();
void add_menu(NonnullOwnPtr<GMenu>&&);
void add_menu(NonnullRefPtr<GMenu>);
void notify_added_to_application(Badge<GApplication>);
void notify_removed_from_application(Badge<GApplication>);
@ -21,5 +21,5 @@ private:
void unrealize_menubar();
int m_menubar_id { -1 };
NonnullOwnPtrVector<GMenu> m_menus;
NonnullRefPtrVector<GMenu> m_menus;
};

View file

@ -21,7 +21,7 @@ GMenuItem::GMenuItem(unsigned menu_id, NonnullRefPtr<GAction>&& action)
m_checked = m_action->is_checked();
}
GMenuItem::GMenuItem(unsigned menu_id, NonnullOwnPtr<GMenu>&& submenu)
GMenuItem::GMenuItem(unsigned menu_id, NonnullRefPtr<GMenu>&& submenu)
: m_type(Submenu)
, m_menu_id(menu_id)
, m_submenu(move(submenu))

View file

@ -19,7 +19,7 @@ public:
GMenuItem(unsigned menu_id, Type);
GMenuItem(unsigned menu_id, NonnullRefPtr<GAction>&&);
GMenuItem(unsigned menu_id, NonnullOwnPtr<GMenu>&&);
GMenuItem(unsigned menu_id, NonnullRefPtr<GMenu>&&);
~GMenuItem();
Type type() const { return m_type; }
@ -53,5 +53,5 @@ private:
bool m_checkable { false };
bool m_checked { false };
RefPtr<GAction> m_action;
OwnPtr<GMenu> m_submenu;
RefPtr<GMenu> m_submenu;
};

View file

@ -550,7 +550,7 @@ GMenu& GTableView::ensure_header_context_menu()
// or if the column count/names change.
if (!m_header_context_menu) {
ASSERT(model());
m_header_context_menu = make<GMenu>();
m_header_context_menu = GMenu::construct();
for (int column = 0; column < model()->column_count(); ++column) {
auto& column_data = this->column_data(column);

View file

@ -98,5 +98,5 @@ protected:
int m_hovered_column_header_index { -1 };
GMenu& ensure_header_context_menu();
OwnPtr<GMenu> m_header_context_menu;
RefPtr<GMenu> m_header_context_menu;
};

View file

@ -1180,7 +1180,7 @@ void GTextEditor::did_update_selection()
void GTextEditor::context_menu_event(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(undo_action());
m_context_menu->add_action(redo_action());
m_context_menu->add_separator();

View file

@ -196,7 +196,7 @@ private:
size_t m_soft_tab_width { 4 };
int m_horizontal_content_padding { 2 };
GTextRange m_selection;
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
RefPtr<GAction> m_undo_action;
RefPtr<GAction> m_redo_action;
RefPtr<GAction> m_cut_action;

View file

@ -648,7 +648,7 @@ void TerminalWidget::beep()
void TerminalWidget::context_menu_event(GContextMenuEvent& event)
{
if (!m_context_menu) {
m_context_menu = make<GMenu>();
m_context_menu = GMenu::construct();
m_context_menu->add_action(copy_action());
m_context_menu->add_action(paste_action());
}

View file

@ -128,7 +128,7 @@ private:
RefPtr<GAction> m_copy_action;
RefPtr<GAction> m_paste_action;
OwnPtr<GMenu> m_context_menu;
RefPtr<GMenu> m_context_menu;
CElapsedTimer m_triple_click_timer;
};

View file

@ -48,13 +48,13 @@ int main(int argc, char** argv)
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("HTML");
auto app_menu = GMenu::construct("HTML");
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) {
app.quit();
}));
menubar->add_menu(move(app_menu));
auto help_menu = make<GMenu>("Help");
auto help_menu = GMenu::construct("Help");
help_menu->add_action(GAction::create("About", [&](const GAction&) {
GAboutDialog::show("HTML", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window);
}));