]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-config.c
ui/ncurses: Fix unstranslated strings in sysinfo screen
[petitboot] / ui / ncurses / nc-config.c
index 54eb7ac5740d891bd32c6a7bcc57655cbf19bc8a..f6d544de3505f2cabf63636e428a1aafb8e951e8 100644 (file)
@@ -33,9 +33,9 @@
 #include "nc-config.h"
 #include "nc-widgets.h"
 
-#define N_FIELDS       25
+#define N_FIELDS       26
 
-extern const char *config_help_text;
+extern struct help_text config_help_text;
 
 enum autoboot_type {
        AUTOBOOT_ANY,
@@ -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;
@@ -146,7 +147,7 @@ static void config_screen_process_key(struct nc_scr *scr, int key)
        } else if (screen->show_help) {
                screen->show_help = false;
                cui_show_help(screen->cui, _("System Configuration"),
-                               config_help_text);
+                               &config_help_text);
 
        } else if (handled) {
                pad_refresh(screen);
@@ -187,8 +188,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);
@@ -198,8 +199,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
@@ -215,13 +217,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;
@@ -307,6 +307,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 +471,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 +738,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"),
@@ -768,13 +780,18 @@ 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);