]> git.ozlabs.org Git - petitboot/commit
ui/ncurses: Separate menu item creation & initialisation from insertion
authorJeremy Kerr <jk@ozlabs.org>
Wed, 12 Mar 2014 06:59:03 +0000 (14:59 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 10 Apr 2014 03:18:24 +0000 (11:18 +0800)
commit1bbd230d618162ccd5ea97540a413c766a07c0cb
tree8bf596660165d015328d54930ba2f91ed4c4effd
parente07bd59ad5f4ba9cd113f8dfdcc72e6ca2e69819
ui/ncurses: Separate menu item creation & initialisation from insertion

Currently, the menu item creation is has two main functions:
pmenu_item_alloc and pmenu_item_setup. The latter does initialisation
(it sets item->name), and inserts the item into the menu. We have
pmenu_item_init to combine this into one, but that means we need to do
further initialisation (eg, to set on_execute) after the item has been
added to the menu.

Instead, this change use a more direct _create and _insert interface.
Create does the allocation and initialisation, while _insert does the
actual insertion.

This means new_item failures will be detected at creation time, rather
than during pmenu_insert. Also, we're now insert a completely-populated
item into the menu, rather than populating on_edit, on_execute and data
after insertion.

Because we can detect errors from creation (ie, from new_item failing),
we add handling code to cui_boot_option_add and cui_boot_editor_on_exit.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/generic-main.c
ui/ncurses/nc-cui.c
ui/ncurses/nc-menu.c
ui/ncurses/nc-menu.h