From: Dirk Gouders Date: Sun, 19 May 2013 19:49:34 +0000 (+0200) Subject: mconf/nconf: mark empty menus/menuconfigs different from non-empty ones X-Git-Tag: 1.9.9~22 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=f0c03963adbc21063171d0e0bc70ac78f554f605;p=carl9170fw.git mconf/nconf: mark empty menus/menuconfigs different from non-empty ones Submenus are sometimes empty and it would be nice if there is something that notifies us that we should not expect any content _before_ we enter a submenu. A new function menu_is_empty() was introduced and empty menus and menuconfigs are now marked by "----" as opposed to non-empty ones that are marked by "--->". This scheme was suggested by "Yann E. MORIN" . Signed-off-by: Dirk Gouders Tested-by: "Yann E. MORIN" Reviewed-by: "Yann E. MORIN" Signed-off-by: "Yann E. MORIN" Signed-off-by: Christian Lamparter --- diff --git a/config/lkc_proto.h b/config/lkc_proto.h index ef1a738..ecdb965 100644 --- a/config/lkc_proto.h +++ b/config/lkc_proto.h @@ -14,6 +14,7 @@ P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap))); /* menu.c */ P(rootmenu,struct menu,); +P(menu_is_empty, bool, (struct menu *menu)); P(menu_is_visible, bool, (struct menu *menu)); P(menu_has_prompt, bool, (struct menu *menu)); P(menu_get_prompt,const char *,(struct menu *menu)); diff --git a/config/menu.c b/config/menu.c index fd3f018..7e233a6 100644 --- a/config/menu.c +++ b/config/menu.c @@ -443,6 +443,22 @@ bool menu_has_prompt(struct menu *menu) return true; } +/* + * Determine if a menu is empty. + * A menu is considered empty if it contains no or only + * invisible entries. + */ +bool menu_is_empty(struct menu *menu) +{ + struct menu *child; + + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child)) + return(false); + } + return(true); +} + bool menu_is_visible(struct menu *menu) { struct menu *child;