mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:17:34 +00:00
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:
parent
e9dda8d592
commit
fd5eb79d19
39 changed files with 88 additions and 86 deletions
|
@ -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);
|
||||
}));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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());
|
||||
}));
|
||||
|
|
|
@ -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);
|
||||
}));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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;
|
||||
}));
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}));
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}));
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}));
|
||||
|
|
|
@ -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"));
|
||||
}));
|
||||
|
|
|
@ -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);
|
||||
}));
|
||||
|
|
|
@ -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);
|
||||
}));
|
||||
|
|
|
@ -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());
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue