Menu/cmd: add sub menu entry command support
commit6ce1c664deedc932093d2750c37f509b067bf551
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Fri, 20 Aug 2010 08:22:48 +0000 (20 10:22 +0200)
committerSascha Hauer <s.hauer@pengutronix.de>
Mon, 30 Aug 2010 18:57:20 +0000 (30 20:57 +0200)
treea1dbed529a6f43021d8676b38566086d6b89bf3b
parentb712b26632d4af1e1c9454a3b330ed7b401e165b
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>
commands/menu.c
common/menu.c
include/menu.h