From 6ce1c664deedc932093d2750c37f509b067bf551 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Fri, 20 Aug 2010 10:22:48 +0200 Subject: Menu/cmd: add sub menu entry command support this will simplify the creation of navigation link as this menu -a -m boot -d "Boot Menu" menu -a -m network -d "Network settings" menu -e -a -m network -u boot -d "Back" menu -e -a -m boot -u network -d "Network settings ->" menu -e -a -m boot -c reset -R -d "Reset" menu -e -a -m boot -c clear -d "Exit" menu -s -m boot in C struct menu m_boot = { .name = "boot", .display = "Boot Menu", }; struct menu m_network = { .name = "network", .display = "Network settings", }; struct menu_entry e_to_network = { .display = "Network settings ->", .action = menu_action_show, .priv = &m_network, }; struct menu_entry e_to_boot = { .display = "Back", .action = menu_action_show, .priv = &m_boot, }; struct menu_entry e_reset = { .display = "Reset", .action = menu_action_run, .priv = "reset", }; struct menu_entry e_exit = { .display = "Exit", .action = menu_action_run, .non_re_ent = 1, .priv = "clear", }; void menu_test(void) { menu_add(&m_boot); menu_add(&m_network); menu_add_entry(&m_boot, &e_to_network); menu_add_entry(&m_boot, &e_reset); menu_add_entry(&m_boot, &e_exit); menu_add_entry(&m_network, &e_to_boot); menu_show(&m_boot); } Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- common/menu.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common/menu.c') diff --git a/common/menu.c b/common/menu.c index e03e4d1d28..b20164415c 100644 --- a/common/menu.c +++ b/common/menu.c @@ -306,6 +306,13 @@ void menu_action_run(struct menu *m, struct menu_entry *me) udelay(1000000); } +void menu_action_show(struct menu *m, struct menu_entry *me) +{ + struct menu *sm = me->priv; + + menu_show(sm); +} + static int menu_init(void) { INIT_LIST_HEAD(&menus.list); -- cgit v1.2.3