summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2010-08-20 10:22:48 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-08-30 20:57:20 +0200
commit6ce1c664deedc932093d2750c37f509b067bf551 (patch)
treea1dbed529a6f43021d8676b38566086d6b89bf3b /common
parentb712b26632d4af1e1c9454a3b330ed7b401e165b (diff)
downloadbarebox-6ce1c664deedc932093d2750c37f509b067bf551.tar.gz
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 <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/menu.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/menu.c b/common/menu.c
index e03e4d1..b201644 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);