From 6bb1301835dbd6ff54e1becb5b684fedb0e4caaf Mon Sep 17 00:00:00 2001 From: Samuel Mendoza-Jonas Date: Wed, 21 Jan 2015 14:48:38 +1100 Subject: ui/ncurses: Add nc-subset selection screen The nc-subset screen is intended to be used as a sub-screen from the current screen (eg. nc-config) which passes a pointer to a nc_widget_subset struct. The nc-subset screen allows the user to select an option from a list of 'inactive' options, before returning control back to the current screen. Signed-off-by: Samuel Mendoza-Jonas --- ui/ncurses/nc-cui.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ui/ncurses/nc-cui.c') diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index 8e31fe2..2fc779e 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -41,6 +41,7 @@ #include "nc-sysinfo.h" #include "nc-lang.h" #include "nc-helpscreen.h" +#include "nc-subset.h" extern const struct help_text main_menu_help_text; @@ -328,6 +329,29 @@ void cui_show_help(struct cui *cui, const char *title, cui_set_current(cui, help_screen_scr(cui->help_screen)); } +static void cui_subset_exit(struct cui *cui) +{ + cui_set_current(cui, subset_screen_return_scr(cui->subset_screen)); + talloc_free(cui->subset_screen); + cui->subset_screen = NULL; +} + +void cui_show_subset(struct cui *cui, const char *title, + void *arg) +{ + if (!cui->current) + return; + + if (cui->subset_screen) + return; + + cui->subset_screen = subset_screen_init(cui, cui->current, + title, arg, cui_subset_exit); + + if (cui->subset_screen) + cui_set_current(cui, subset_screen_scr(cui->subset_screen)); +} + /** * cui_set_current - Set the currently active screen and redraw it. */ -- cgit v1.2.1