[PATCH] ui/ncurses: Re-add autoboot selection to config screen

Sam Mendoza-Jonas sam at mendozajonas.com
Tue Mar 15 16:06:23 AEDT 2016


The new boot order interface removed the autoboot enable/disable buttons.
However this means the only way to disable autoboot is to remove all
options from the boot order list, or know that you can manually set the
`auto-boot?` flag in nvram.

This re-introduces an autoboot enable/disable widget so that autoboot
can be disabled without losing an existing boot order. The translated
strings for "Autoboot" are salvaged from earlier use, and two new
untranslated strings are introduced.

Signed-off-by: Sam Mendoza-Jonas <sam at mendozajonas.com>
---
 po/de.po               | 12 ++++++--
 po/en.po               | 12 ++++++--
 po/es.po               | 12 ++++++--
 po/fr.po               | 12 ++++++--
 po/it.po               | 12 ++++++--
 po/ja.po               | 12 ++++++--
 po/ko.po               | 12 ++++++--
 po/pt_BR.po            | 12 ++++++--
 po/ru.po               | 12 ++++++--
 po/zh_CN.po            | 12 ++++++--
 po/zh_TW.po            | 12 ++++++--
 ui/ncurses/nc-config.c | 82 ++++++++++++++++++++++++++++++++++++++------------
 12 files changed, 162 insertions(+), 52 deletions(-)

diff --git a/po/de.po b/po/de.po
index 0580e7b..8ee9d8b 100644
--- a/po/de.po
+++ b/po/de.po
@@ -198,6 +198,15 @@ msgstr "Wählen Sie eine Booteinheit aus, die hinzugefügt werden soll"
 msgid "Waiting for configuration data..."
 msgstr "Warten auf Konfigurationsdaten..."
 
+msgid "Autoboot:"
+msgstr "Autom. Booten:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "Einheit hinzufügen"
 
@@ -686,9 +695,6 @@ msgstr ""
 msgid "Usage"
 msgstr "Verwendung"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/en.po b/po/en.po
index 2be6372..588ea55 100644
--- a/po/en.po
+++ b/po/en.po
@@ -196,6 +196,15 @@ msgstr ""
 msgid "Waiting for configuration data..."
 msgstr "Waiting for configuration data..."
 
+msgid "Autoboot:"
+msgstr "Autoboot:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "Add Device:"
 
@@ -621,9 +630,6 @@ msgstr ""
 msgid "Usage"
 msgstr "Usage"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/es.po b/po/es.po
index abe0cba..0bb4137 100644
--- a/po/es.po
+++ b/po/es.po
@@ -196,6 +196,15 @@ msgstr "Seleccione un dispositivo de arranque para añadirlo"
 msgid "Waiting for configuration data..."
 msgstr "Esperando datos de configuración..."
 
+msgid "Autoboot:"
+msgstr "Arranque automático:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "Añadir dispositivo"
 
@@ -675,9 +684,6 @@ msgstr ""
 msgid "Usage"
 msgstr "Uso"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/fr.po b/po/fr.po
index eac32bc..e9c2d8b 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -196,6 +196,15 @@ msgstr "Sélectionner une unité d'amorçage à ajouter"
 msgid "Waiting for configuration data..."
 msgstr "Attente de données de configuration..."
 
+msgid "Autoboot:"
+msgstr "Amorçage auto:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "Ajouter une unité"
 
@@ -676,9 +685,6 @@ msgstr ""
 msgid "Usage"
 msgstr "Utilisation"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/it.po b/po/it.po
index 9f77a56..2195e80 100644
--- a/po/it.po
+++ b/po/it.po
@@ -197,6 +197,15 @@ msgstr "Selezionare un dispositivo di avvio da aggiungere"
 msgid "Waiting for configuration data..."
 msgstr "In attesa dei dati di configurazione..."
 
+msgid "Autoboot:"
+msgstr "Avvio automatico:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "Aggiungi dispositivo"
 
@@ -678,9 +687,6 @@ msgstr ""
 msgid "Usage"
 msgstr "Utilizzo"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/ja.po b/po/ja.po
index 6fe061b..427016a 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -196,6 +196,15 @@ msgstr "追加するブート・デバイスの選択"
 msgid "Waiting for configuration data..."
 msgstr "構成データを待っています..."
 
+msgid "Autoboot:"
+msgstr "自動ブート:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "デバイスの追加"
 
@@ -675,9 +684,6 @@ msgstr ""
 msgid "Usage"
 msgstr "使用法"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/ko.po b/po/ko.po
index e1bcd0f..fc450b6 100644
--- a/po/ko.po
+++ b/po/ko.po
@@ -196,6 +196,15 @@ msgstr "추가할 부트 장치를 선택하십시오. "
 msgid "Waiting for configuration data..."
 msgstr "구성 데이터 대기 중..."
 
+msgid "Autoboot:"
+msgstr "자동 부트:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "장치 추가"
 
@@ -660,9 +669,6 @@ msgstr ""
 msgid "Usage"
 msgstr "사용법"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 48bc5de..62c943c 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -196,6 +196,15 @@ msgstr "Selecione um dispositivo de inicialização a incluir."
 msgid "Waiting for configuration data..."
 msgstr "Aguardando dados de configuração..."
 
+msgid "Autoboot:"
+msgstr "Inicialização automática:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "Incluir dispositivo"
 
@@ -678,9 +687,6 @@ msgstr ""
 msgid "Usage"
 msgstr "Uso"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/ru.po b/po/ru.po
index bfe68d1..0a68bc9 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -197,6 +197,15 @@ msgstr "Выберите загрузочное устройство для до
 msgid "Waiting for configuration data..."
 msgstr "Ожидание данных конфигурации..."
 
+msgid "Autoboot:"
+msgstr "Автоматическая загрузка:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "Добавить устройство"
 
@@ -670,9 +679,6 @@ msgstr ""
 msgid "Usage"
 msgstr "Использование"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 13ab6a6..12d7785 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -196,6 +196,15 @@ msgstr "选择要添加的引导设备"
 msgid "Waiting for configuration data..."
 msgstr "正在等待配置数据..."
 
+msgid "Autoboot:"
+msgstr "自动引导:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "添加设备"
 
@@ -645,9 +654,6 @@ msgstr ""
 msgid "Usage"
 msgstr "用法"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/po/zh_TW.po b/po/zh_TW.po
index f9b48f9..c9f1f7f 100644
--- a/po/zh_TW.po
+++ b/po/zh_TW.po
@@ -196,6 +196,15 @@ msgstr "選取要新增的啟動裝置"
 msgid "Waiting for configuration data..."
 msgstr "正在等待配置資料..."
 
+msgid "Autoboot:"
+msgstr "自動啟動:"
+
+msgid "Disabled"
+msgstr ""
+
+msgid "Enabled"
+msgstr ""
+
 msgid "Add Device"
 msgstr "新增裝置"
 
@@ -648,9 +657,6 @@ msgstr ""
 msgid "Usage"
 msgstr "用法"
 
-#~ msgid "Autoboot:"
-#~ msgstr "Autoboot:"
-
 #~ msgid "Don't autoboot"
 #~ msgstr "Don't autoboot"
 
diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c
index e7451bb..b03666e 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	37
+#define N_FIELDS	39
 
 extern struct help_text config_help_text;
 
@@ -69,6 +69,8 @@ struct config_screen {
 	bool			ipmi_override;
 
 	struct {
+		struct nc_widget_label		*autoboot_l;
+		struct nc_widget_select		*autoboot_f;
 		struct nc_widget_label		*boot_order_l;
 		struct nc_widget_subset		*boot_order_f;
 		struct nc_widget_label		*boot_empty_l;
@@ -191,11 +193,11 @@ 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;
+	bool allow_write, autoboot_set;
 	char *str, *end;
 	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);
@@ -206,7 +208,8 @@ static int screen_process_form(struct config_screen *screen)
 	n_boot_opts = widget_subset_get_order(config, &order,
 					      screen->widgets.boot_order_f);
 
-	config->autoboot_enabled = n_boot_opts > 0;
+	autoboot_set = widget_select_get_value(screen->widgets.autoboot_f);
+	config->autoboot_enabled = autoboot_set || autoboot_set && n_boot_opts;
 
 	config->n_autoboot_opts = n_boot_opts;
 	config->autoboot_opts = talloc_array(config, struct autoboot_option,
@@ -387,41 +390,59 @@ static void config_screen_layout_widgets(struct config_screen *screen)
 	help_x = screen->field_x + 2 +
 		widget_width(widget_textbox_base(screen->widgets.dns_f));
 
-	wl = widget_label_base(screen->widgets.boot_order_l);
+	wl = widget_label_base(screen->widgets.autoboot_l);
 	widget_set_visible(wl, true);
 	widget_move(wl, y, screen->label_x);
 
+	wf = widget_select_base(screen->widgets.autoboot_f);
+	widget_move(wf, y, screen->field_x);
+	y += widget_height(wf);
+
+	show = screen->autoboot_enabled;
+
+	if (show)
+		y += 1;
+
+	wl = widget_label_base(screen->widgets.boot_order_l);
+	widget_set_visible(wl, show);
+	widget_move(wl, y, screen->label_x);
+
 	wf = widget_subset_base(screen->widgets.boot_order_f);
 	widget_move(wf, y, screen->field_x);
 	wl = widget_label_base(screen->widgets.boot_empty_l);
 	widget_move(wl, y, screen->field_x);
 
 	if (widget_subset_height(screen->widgets.boot_order_f)) {
-		widget_set_visible(wf, true);
 		widget_set_visible(wl, false);
-		y += widget_height(wf);
+		widget_set_visible(wf, show);
+		y += show ? widget_height(wf) : 0;
 	} else {
-		widget_set_visible(wl, true);
+		widget_set_visible(wl, show);
 		widget_set_visible(wf, false);
-		y += 1;
+		y += show ? 1 : 0;
 	}
 
-	y += 1;
-
-	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);
-	widget_move(widget_button_base(screen->widgets.boot_none_b),
-			y, screen->field_x);
+	if (show) {
+		y += 1;
+		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);
+		widget_move(widget_button_base(screen->widgets.boot_none_b),
+				y, screen->field_x);
+	}
 
 	wf = widget_button_base(screen->widgets.boot_add_b);
-	if (widget_subset_n_inactive(screen->widgets.boot_order_f))
+	if (widget_subset_n_inactive(screen->widgets.boot_order_f) && show)
 		widget_set_visible(wf, true);
 	else
 		widget_set_visible(wf, false);
 
-	y += 2;
+	if (show)
+		y += 2;
+
+	widget_set_visible(widget_button_base(screen->widgets.boot_any_b), show);
+	widget_set_visible(widget_button_base(screen->widgets.boot_none_b), show);
 
 	wf = widget_textbox_base(screen->widgets.timeout_f);
 	wl = widget_label_base(screen->widgets.timeout_l);
@@ -584,6 +605,15 @@ static void config_screen_boot_order_change(void *arg, int value)
 	widgetset_post(screen->widgetset);
 }
 
+static void config_screen_autoboot_change(void *arg, int value)
+{
+	struct config_screen *screen = arg;
+	screen->autoboot_enabled = !!value;
+	widgetset_unpost(screen->widgetset);
+	config_screen_layout_widgets(screen);
+	widgetset_post(screen->widgetset);
+}
+
 static void config_screen_add_device(void *arg)
 {
 	struct config_screen *screen = arg;
@@ -722,6 +752,21 @@ static void config_screen_setup_widgets(struct config_screen *screen,
 	type = screen->net_conf_type;
 	ifcfg = first_active_interface(config);
 
+	screen->autoboot_enabled = config->autoboot_enabled;
+
+	screen->widgets.autoboot_l = widget_new_label(set, 0, 0,
+					_("Autoboot:"));
+	screen->widgets.autoboot_f = widget_new_select(set, 0, 0,
+					COLS - screen->field_x - 1);
+
+	widget_select_add_option(screen->widgets.autoboot_f, 0, _("Disabled"),
+				 !screen->autoboot_enabled);
+	widget_select_add_option(screen->widgets.autoboot_f, 1, _("Enabled"),
+				 screen->autoboot_enabled);
+
+	widget_select_on_change(screen->widgets.autoboot_f,
+			config_screen_autoboot_change, screen);
+
 	add_len = max(min_len, strncols(_("Add Device")));
 	clear_len = max(min_len, strncols(_("Clear")));
 	any_len = max(min_len, strncols(_("Clear & Boot Any")));
@@ -783,7 +828,6 @@ static void config_screen_setup_widgets(struct config_screen *screen,
 		widget_subset_add_option(screen->widgets.boot_order_f, label);
 	}
 
-	screen->autoboot_enabled = config->n_autoboot_opts;
 	for (i = 0; i < config->n_autoboot_opts; i++) {
 		struct autoboot_option *opt = &config->autoboot_opts[i];
 		int idx;
-- 
2.7.3



More information about the Petitboot mailing list