|
14 | 14 | #include <LibGUI/GWidget.h>
|
15 | 15 | #include <LibGUI/GWindow.h>
|
16 | 16 | #include <LibGUI/GMenuBar.h>
|
| 17 | +#include <LibGUI/GAction.h> |
17 | 18 |
|
18 | 19 | static void make_shell(int ptm_fd)
|
19 | 20 | {
|
@@ -95,38 +96,28 @@ int main(int argc, char** argv)
|
95 | 96 | auto menubar = make<GMenuBar>();
|
96 | 97 |
|
97 | 98 | auto app_menu = make<GMenu>("Terminal");
|
98 |
| - app_menu->add_item(0, "Quit"); |
99 |
| - app_menu->on_item_activation = [] (unsigned identifier) { |
100 |
| - if (identifier == 0) { |
101 |
| - dbgprintf("Terminal: Quit menu activated!\n"); |
102 |
| - GApplication::the().exit(0); |
103 |
| - return; |
104 |
| - } |
105 |
| - }; |
| 99 | + app_menu->add_action(make<GAction>("Quit", String(), [] (const GAction&) { |
| 100 | + dbgprintf("Terminal: Quit menu activated!\n"); |
| 101 | + GApplication::the().exit(0); |
| 102 | + return; |
| 103 | + })); |
106 | 104 | menubar->add_menu(move(app_menu));
|
107 | 105 |
|
108 | 106 | auto font_menu = make<GMenu>("Font");
|
109 |
| - font_menu->add_item(0, "Liza Thin"); |
110 |
| - font_menu->add_item(1, "Liza Regular"); |
111 |
| - font_menu->add_item(2, "Liza Bold"); |
112 |
| - font_menu->on_item_activation = [&terminal] (unsigned identifier) { |
113 |
| - switch (identifier) { |
114 |
| - case 0: |
115 |
| - terminal.set_font(Font::load_from_file("/res/fonts/LizaThin8x10.font")); |
116 |
| - break; |
117 |
| - case 1: |
118 |
| - terminal.set_font(Font::load_from_file("/res/fonts/LizaRegular8x10.font")); |
119 |
| - break; |
120 |
| - case 2: |
121 |
| - terminal.set_font(Font::load_from_file("/res/fonts/LizaBold8x10.font")); |
122 |
| - break; |
123 |
| - } |
| 107 | + auto handle_font_selection = [&terminal] (const GAction& action) { |
| 108 | + terminal.set_font(Font::load_from_file(action.custom_data())); |
124 | 109 | terminal.force_repaint();
|
125 | 110 | };
|
| 111 | + font_menu->add_action(make<GAction>("Liza Thin", "/res/fonts/LizaThin8x10.font", move(handle_font_selection))); |
| 112 | + font_menu->add_action(make<GAction>("Liza Regular", "/res/fonts/LizaRegular8x10.font", move(handle_font_selection))); |
| 113 | + font_menu->add_action(make<GAction>("Liza Bold", "/res/fonts/LizaBold8x10.font", move(handle_font_selection))); |
| 114 | + |
126 | 115 | menubar->add_menu(move(font_menu));
|
127 | 116 |
|
128 | 117 | auto help_menu = make<GMenu>("Help");
|
129 |
| - help_menu->add_item(0, "About"); |
| 118 | + help_menu->add_action(make<GAction>("About", [] (const GAction&) { |
| 119 | + dbgprintf("FIXME: Implement Help/About\n"); |
| 120 | + })); |
130 | 121 | menubar->add_menu(move(help_menu));
|
131 | 122 |
|
132 | 123 | app.set_menubar(move(menubar));
|
|
0 commit comments