mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:47:47 +00:00
Plumb menu item activation events from WindowServer to clients.
GMenu now has an "on_item_activation" callback that fires whenever one of its items are activated. The menu item identifier is used to distinguish between items. Use this to implement font switching in Terminal. :^)
This commit is contained in:
parent
9c1c885483
commit
db98327bdc
10 changed files with 93 additions and 3 deletions
|
@ -80,9 +80,23 @@ int main(int argc, char** argv)
|
|||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto font_menu = make<GMenu>("Font");
|
||||
font_menu->add_item(30, "Liza 8x10");
|
||||
font_menu->add_item(31, "LizaRegular 8x10");
|
||||
font_menu->add_item(32, "LizaBold 8x10");
|
||||
font_menu->add_item(30, "Liza Thin");
|
||||
font_menu->add_item(31, "Liza Regular");
|
||||
font_menu->add_item(32, "Liza Bold");
|
||||
font_menu->on_item_activation = [&terminal] (unsigned identifier) {
|
||||
switch (identifier) {
|
||||
case 30:
|
||||
terminal.set_font(Font::load_from_file("/res/fonts/Liza8x10.font"));
|
||||
break;
|
||||
case 31:
|
||||
terminal.set_font(Font::load_from_file("/res/fonts/LizaRegular8x10.font"));
|
||||
break;
|
||||
case 32:
|
||||
terminal.set_font(Font::load_from_file("/res/fonts/LizaBold8x10.font"));
|
||||
break;
|
||||
}
|
||||
terminal.force_repaint();
|
||||
};
|
||||
menubar->add_menu(move(font_menu));
|
||||
|
||||
auto help_menu = make<GMenu>("Help");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue