X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fnc-config.c;h=c45df34e9afce17f5d641206bade8923e3bff252;hp=7a709ab1a3e3cf69914e65a717775fdb2f6354cc;hb=91143069d1a40cefd997522d85cb2d8adf1681f7;hpb=b793eb6e80e002208ef0c5d149f786c44e3c86a0 diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 7a709ab..c45df34 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -57,6 +57,7 @@ struct config_screen { bool exit; bool show_help; + bool need_redraw; void (*on_exit)(struct cui *); int scroll_y; @@ -146,6 +147,7 @@ static void config_screen_process_key(struct nc_scr *scr, int key) } else if (screen->show_help) { screen->show_help = false; + screen->need_redraw = true; cui_show_help(screen->cui, _("System Configuration"), &config_help_text); @@ -165,7 +167,10 @@ static int config_screen_post(struct nc_scr *scr) struct config_screen *screen = config_screen_from_scr(scr); widgetset_post(screen->widgetset); nc_scr_frame_draw(scr); - redrawwin(scr->main_ncw); + if (screen->need_redraw) { + redrawwin(scr->main_ncw); + screen->need_redraw = false; + } wrefresh(screen->scr.main_ncw); pad_refresh(screen); return 0; @@ -188,8 +193,8 @@ static int screen_process_form(struct config_screen *screen) const struct system_info *sysinfo = screen->cui->sysinfo; enum net_conf_type net_conf_type; struct interface_config *iface; + char *str, *end, *uuid; struct config *config; - char *str, *end; int rc, idx; config = config_copy(screen, screen->cui->config); @@ -199,8 +204,9 @@ static int screen_process_form(struct config_screen *screen) config->autoboot_enabled = screen->autoboot_type != AUTOBOOT_DISABLED; + uuid = NULL; if (screen->autoboot_type == AUTOBOOT_ONE) { - char mac[20], *uuid = NULL; + char mac[20]; /* if idx is -1 here, we have an unknown UUID selected. * Otherwise, it's a blockdev index (idx <= n_blockdevs) or an @@ -216,13 +222,11 @@ static int screen_process_form(struct config_screen *screen) } else if (idx != -1) { uuid = sysinfo->blockdevs[idx]->uuid; } - - if (uuid) { - talloc_free(config->boot_device); - config->boot_device = talloc_strdup(config, uuid); - } } + talloc_free(config->boot_device); + config->boot_device = uuid ? talloc_strdup(config, uuid) : NULL; + str = widget_textbox_get_value(screen->widgets.timeout_f); if (str) { unsigned long x; @@ -484,7 +488,7 @@ static void config_screen_layout_widgets(struct config_screen *screen) widget_move(widget_button_base(screen->widgets.help_b), y, screen->field_x + 10); widget_move(widget_button_base(screen->widgets.cancel_b), - y, screen->field_x + 20); + y, screen->field_x + 24); } static void config_screen_network_change(void *arg, int value) @@ -542,7 +546,7 @@ 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"), + 4, screen->field_x, 9, _("Cancel"), cancel_click, screen); } @@ -745,9 +749,9 @@ static void config_screen_setup_widgets(struct config_screen *screen, screen->widgets.ok_b = widget_new_button(set, 0, 0, 6, _("OK"), ok_click, screen); - screen->widgets.help_b = widget_new_button(set, 0, 0, 6, _("Help"), + screen->widgets.help_b = widget_new_button(set, 0, 0, 10, _("Help"), help_click, screen); - screen->widgets.cancel_b = widget_new_button(set, 0, 0, 6, _("Cancel"), + screen->widgets.cancel_b = widget_new_button(set, 0, 0, 10, _("Cancel"), cancel_click, screen); } @@ -781,17 +785,22 @@ static void config_screen_draw(struct config_screen *screen, /* The size of the pad we'll need depends on the number of interfaces. * * We use N_FIELDS (which is quite conservative, as some fields share - * a line) as a base, then add 3 (as the network select field is - * takes 3 lines), and n_interfaces (as the network interface field - * has n_interfaces lines). + * a line) as a base, then: + * - add 6 (as the network select & boot device select fields take 3 + * lines each), + * - add n_interfaces for every field in the network select field, and + * - add (n_blockdevs + n_interfaces) for every field in the boot device + * select field */ - height = N_FIELDS + 3; - if (sysinfo) + height = N_FIELDS + 6; + if (sysinfo) { height += sysinfo->n_interfaces; + height += (sysinfo->n_blockdevs + sysinfo->n_interfaces); + } if (!screen->pad || getmaxy(screen->pad) < height) { if (screen->pad) delwin(screen->pad); - screen->pad = newpad(height, COLS); + screen->pad = newpad(height, COLS + 10); } if (screen->widgetset) { @@ -855,6 +864,7 @@ struct config_screen *config_screen_init(struct cui *cui, screen->cui = cui; screen->on_exit = on_exit; + screen->need_redraw = false; screen->label_x = 2; screen->field_x = 17;