[PATCH 2/2] ui/ncurses: Exit safe mode on configuration change

Samuel Mendoza-Jonas sam.mj at au1.ibm.com
Fri Aug 29 14:03:17 EST 2014


Selecting 'OK' in the configuration or language select screen will send
a configuration change to the server and exit safe mode.
Exit safe mode explicity and warn the user that they are about to exit
it.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj at au1.ibm.com>
---
 po/en.po               |  5 ++++-
 ui/ncurses/nc-config.c | 15 ++++++++++++++-
 ui/ncurses/nc-lang.c   | 14 +++++++++++++-
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/po/en.po b/po/en.po
index 691722d..2573845 100644
--- a/po/en.po
+++ b/po/en.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: petitboot 20140623-g89bd2ed2-dirty\n"
 "Report-Msgid-Bugs-To: Geoff Levand <geoff at infradead.org>\n"
-"POT-Creation-Date: 2014-08-29 13:24+1000\n"
+"POT-Creation-Date: 2014-08-29 13:42+1000\n"
 "PO-Revision-Date: 2014-06-24 13:56+0800\n"
 "Last-Translator: Jeremy Kerr <jk at ozlabs.org>\n"
 "Language-Team: English\n"
@@ -200,6 +200,9 @@ msgstr "(eg. 192.168.0.2)"
 msgid "(if not provided by DHCP server)"
 msgstr "(if not provided by DHCP server)"
 
+msgid "Selecting 'OK' will exit safe mode"
+msgstr "Selecting 'OK' will exit safe mode"
+
 msgid "Petitboot System Configuration"
 msgstr "Petitboot System Configuration"
 
diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c
index a095353..7a709ab 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	25
+#define N_FIELDS	26
 
 extern struct help_text config_help_text;
 
@@ -94,6 +94,7 @@ struct config_screen {
 		struct nc_widget_label		*dns_dhcp_help_l;
 		struct nc_widget_label		*dns_help_l;
 
+		struct nc_widget_label		*safe_mode;
 		struct nc_widget_button		*ok_b;
 		struct nc_widget_button		*help_b;
 		struct nc_widget_button		*cancel_b;
@@ -307,6 +308,7 @@ static int screen_process_form(struct config_screen *screen)
 		}
 	}
 
+	config->safe_mode = false;
 	rc = cui_send_config(screen->cui, config);
 	talloc_free(config);
 
@@ -470,6 +472,13 @@ static void config_screen_layout_widgets(struct config_screen *screen)
 
 	y += 1;
 
+	show = screen->cui->config->safe_mode;
+	if (show) {
+		widget_move(widget_label_base(screen->widgets.safe_mode),
+			y, screen->field_x);
+		y += 1;
+	}
+
 	widget_move(widget_button_base(screen->widgets.ok_b),
 			y, screen->field_x);
 	widget_move(widget_button_base(screen->widgets.help_b),
@@ -730,6 +739,10 @@ static void config_screen_setup_widgets(struct config_screen *screen,
 	screen->widgets.dns_dhcp_help_l = widget_new_label(set, 0, 0,
 			_("(if not provided by DHCP server)"));
 
+	if (config->safe_mode)
+		screen->widgets.safe_mode = widget_new_label(set, 0, 0,
+			 _("Selecting 'OK' will exit safe mode"));
+
 	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"),
diff --git a/ui/ncurses/nc-lang.c b/ui/ncurses/nc-lang.c
index 35f54e6..5e92707 100644
--- a/ui/ncurses/nc-lang.c
+++ b/ui/ncurses/nc-lang.c
@@ -32,7 +32,7 @@
 #include "nc-lang.h"
 #include "nc-widgets.h"
 
-#define N_FIELDS	4
+#define N_FIELDS	5
 
 static struct lang {
 	const char	*name;
@@ -59,6 +59,7 @@ struct lang_screen {
 		struct nc_widget_select		*lang_f;
 		struct nc_widget_label		*lang_l;
 
+		struct nc_widget_label		*safe_mode;
 		struct nc_widget_button		*ok_b;
 		struct nc_widget_button		*cancel_b;
 	} widgets;
@@ -160,6 +161,7 @@ static int lang_process_form(struct lang_screen *screen)
 
 	config->lang = talloc_strdup(screen, lang->name);
 
+	config->safe_mode = false;
 	rc = cui_send_config(screen->cui, config);
 	talloc_free(config);
 
@@ -209,6 +211,12 @@ static void lang_screen_layout_widgets(struct lang_screen *screen)
 
 	y += 1;
 
+	if (screen->cui->config->safe_mode) {
+		widget_move(widget_label_base(screen->widgets.safe_mode),
+			y, screen->field_x);
+		y += 1;
+	}
+
 	widget_move(widget_button_base(screen->widgets.ok_b),
 			y, screen->field_x);
 	widget_move(widget_button_base(screen->widgets.cancel_b),
@@ -265,6 +273,10 @@ static void lang_screen_setup_widgets(struct lang_screen *screen,
 					label, true);
 	}
 
+	if (config->safe_mode)
+		screen->widgets.safe_mode = widget_new_label(set, 0, 0,
+			 _("Selecting 'OK' will exit safe mode"));
+
 	screen->widgets.ok_b = widget_new_button(set, 0, 0, 6, _("OK"),
 			ok_click, screen);
 	screen->widgets.cancel_b = widget_new_button(set, 0, 0, 6, _("Cancel"),
-- 
1.9.3



More information about the Petitboot mailing list