X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fnc-config.c;h=f7c6b8c4b1cc11cfee9d975590906b4e55edeb19;hp=911559dcefc0240c283b9ceea6ba6c4ddeee048b;hb=70907c3fc4b344d00ce900e6a536e9cc16a35216;hpb=37b4861cb01bf6bd9da41aa1b311a87b0d26fc25 diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 911559d..f7c6b8c 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -33,7 +33,7 @@ #include "nc-config.h" #include "nc-widgets.h" -#define N_FIELDS 32 +#define N_FIELDS 34 extern struct help_text config_help_text; @@ -100,6 +100,9 @@ struct config_screen { struct nc_widget_label *dns_dhcp_help_l; struct nc_widget_label *dns_help_l; + struct nc_widget_label *allow_write_l; + struct nc_widget_select *allow_write_f; + struct nc_widget_label *safe_mode; struct nc_widget_button *ok_b; struct nc_widget_button *help_b; @@ -203,6 +206,7 @@ static int screen_process_form(struct config_screen *screen) struct config *config; int i, n_boot_opts, rc, idx; unsigned int *order; + bool allow_write; char mac[20]; config = config_copy(screen, screen->cui->config); @@ -331,6 +335,10 @@ static int screen_process_form(struct config_screen *screen) } } + allow_write = widget_select_get_value(screen->widgets.allow_write_f); + if (allow_write != config->allow_writes) + config->allow_writes = allow_write; + config->safe_mode = false; rc = cui_send_config(screen->cui, config); talloc_free(config); @@ -383,11 +391,11 @@ static void config_screen_layout_widgets(struct config_screen *screen) bool show; y = 1; + /* currently, the longest label we have is the DNS-servers + * widget, so layout our screen based on that */ help_x = screen->field_x + 2 + widget_width(widget_textbox_base(screen->widgets.dns_f)); - y += 1; - wl = widget_label_base(screen->widgets.boot_order_l); widget_set_visible(wl, true); widget_move(wl, y, screen->label_x); @@ -412,9 +420,9 @@ static void config_screen_layout_widgets(struct config_screen *screen) widget_move(widget_button_base(screen->widgets.boot_add_b), y, screen->field_x); widget_move(widget_button_base(screen->widgets.boot_any_b), - y, screen->field_x + 12); + y, screen->field_x + 14); widget_move(widget_button_base(screen->widgets.boot_none_b), - y, screen->field_x + 30); + y, screen->field_x + 34); wf = widget_button_base(screen->widgets.boot_add_b); if (widget_subset_n_inactive(screen->widgets.boot_order_f)) @@ -453,7 +461,7 @@ static void config_screen_layout_widgets(struct config_screen *screen) y += 1; } - y += 2; + y += 1; y += layout_pair(screen, y, screen->widgets.network_l, widget_select_base(screen->widgets.network_f)); @@ -540,6 +548,12 @@ static void config_screen_layout_widgets(struct config_screen *screen) y += 1; } + layout_pair(screen, y, screen->widgets.allow_write_l, + widget_select_base(screen->widgets.allow_write_f)); + y += widget_height(widget_select_base(screen->widgets.allow_write_f)); + + y += 1; + widget_move(widget_button_base(screen->widgets.ok_b), y, screen->field_x); widget_move(widget_button_base(screen->widgets.help_b), @@ -571,7 +585,7 @@ static void config_screen_add_device(void *arg) struct config_screen *screen = arg; screen->show_subset = true; - cui_show_subset(screen->cui, _("Select an option"), + cui_show_subset(screen->cui, _("Select a boot device to add"), screen->widgets.boot_order_f); } @@ -704,19 +718,19 @@ static void config_screen_setup_widgets(struct config_screen *screen, ifcfg = first_active_interface(config); screen->widgets.boot_add_b = widget_new_button(set, 0, 0, 10, - _("Add Device"), config_screen_add_device, - screen); + _("Add Device"), + config_screen_add_device, screen); screen->widgets.boot_none_b = widget_new_button(set, 0, 0, 10, _("Clear"), config_screen_autoboot_none, screen); screen->widgets.boot_any_b = widget_new_button(set, 0, 0, 16, - _("Clear & Boot Any"), config_screen_autoboot_any, - screen); + _("Clear & Boot Any"), + config_screen_autoboot_any, screen); screen->widgets.boot_order_l = widget_new_label(set, 0, 0, - _("Boot order:")); + _("Boot Order:")); screen->widgets.boot_order_f = widget_new_subset(set, 0, 0, COLS - screen->field_x, config_screen_update_subset); @@ -748,7 +762,7 @@ static void config_screen_setup_widgets(struct config_screen *screen, widget_subset_add_option(screen->widgets.boot_order_f, label); } - for (i = DEVICE_TYPE_NETWORK; i < DEVICE_TYPE_NETWORK + 4; i++) { + for (i = DEVICE_TYPE_NETWORK; i < DEVICE_TYPE_UNKNOWN; i++) { char *label; if (i == DEVICE_TYPE_ANY) @@ -900,6 +914,18 @@ static void config_screen_setup_widgets(struct config_screen *screen, screen->widgets.safe_mode = widget_new_label(set, 0, 0, _("Selecting 'OK' will exit safe mode")); + screen->widgets.allow_write_l = widget_new_label(set, 0, 0, + _("Disk R/W:")); + screen->widgets.allow_write_f = widget_new_select(set, 0, 0, + COLS - screen->field_x); + + widget_select_add_option(screen->widgets.allow_write_f, 0, + _("Prevent all writes to disk"), + !config->allow_writes); + widget_select_add_option(screen->widgets.allow_write_f, 1, + _("Allow bootloader scripts to modify disks"), + config->allow_writes); + 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, 10, _("Help"),