summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/nc-config.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-10-25 09:19:35 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-11-14 13:23:52 +1100
commitbdcb1f9712f9e99ff1f72497387b34e68585523c (patch)
tree6b065e8711b655c0e26461b448d909e33a1b338b /ui/ncurses/nc-config.c
parent9df37efcae13a272b25cc5b4e0ba441948fea886 (diff)
downloadtalos-petitboot-bdcb1f9712f9e99ff1f72497387b34e68585523c.tar.gz
talos-petitboot-bdcb1f9712f9e99ff1f72497387b34e68585523c.zip
nui/ncurses: Allow config screen updates
We may receive configuration (or sysinfo) data after the configuration screen has been displayed. Implement config_screen_update and redraw the widgetset when new config data arrives. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui/ncurses/nc-config.c')
-rw-r--r--ui/ncurses/nc-config.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c
index 00fe72c..49f2e2f 100644
--- a/ui/ncurses/nc-config.c
+++ b/ui/ncurses/nc-config.c
@@ -378,6 +378,15 @@ static enum net_conf_type find_net_conf_type(const struct config *config)
return NET_CONF_TYPE_DHCP_ALL;
}
+static void config_screen_setup_empty(struct config_screen *screen)
+{
+ widget_new_label(screen->widgetset, 2, screen->field_x,
+ "Waiting for configuration data...");
+ screen->widgets.cancel_b = widget_new_button(screen->widgetset,
+ 4, screen->field_x, 6, "Cancel", cancel_click, screen);
+}
+
+
static void config_screen_setup_widgets(struct config_screen *screen,
const struct config *config,
const struct system_info *sysinfo)
@@ -477,6 +486,36 @@ static void config_screen_setup_widgets(struct config_screen *screen,
cancel_click, screen);
}
+void config_screen_update(struct config_screen *screen,
+ const struct config *config,
+ const struct system_info *sysinfo)
+{
+ bool repost = false;
+
+ if (screen->widgetset) {
+ widgetset_unpost(screen->widgetset);
+ talloc_free(screen->widgetset);
+ repost = true;
+ }
+
+ screen->widgetset = widgetset_create(screen, screen->scr.main_ncw,
+ screen->scr.sub_ncw);
+
+ if (!config || !sysinfo) {
+ config_screen_setup_empty(screen);
+ } else {
+ screen->net_conf_type = find_net_conf_type(config);
+
+ config_screen_setup_widgets(screen, config, sysinfo);
+ config_screen_layout_widgets(screen, screen->net_conf_type);
+ }
+
+ if (repost)
+ widgetset_post(screen->widgetset);
+
+ wrefresh(screen->scr.main_ncw);
+}
+
struct config_screen *config_screen_init(struct cui *cui,
const struct config *config,
const struct system_info *sysinfo,
@@ -502,15 +541,9 @@ struct config_screen *config_screen_init(struct cui *cui,
"tab=next, shift+tab=previous");
nc_scr_frame_draw(&screen->scr);
- screen->widgetset = widgetset_create(screen, screen->scr.main_ncw,
- screen->scr.sub_ncw);
- screen->net_conf_type = find_net_conf_type(config);
-
- config_screen_setup_widgets(screen, config, sysinfo);
- config_screen_layout_widgets(screen, screen->net_conf_type);
-
- wrefresh(screen->scr.main_ncw);
scrollok(screen->scr.sub_ncw, true);
+ config_screen_update(screen, config, sysinfo);
+
return screen;
}
OpenPOWER on IntegriCloud