ui/ncurses: Toggle visibility of timeout help label
[petitboot] / ui / ncurses / nc-lang.c
index 35f54e628456ce2a98af61947dc27addf92d5be7..0b871566aa83fbeda61e02da393f6fb204be36ed 100644 (file)
 #include "nc-lang.h"
 #include "nc-widgets.h"
 
-#define N_FIELDS       4
+#define N_FIELDS       5
 
 static struct lang {
        const char      *name;
        const wchar_t   *label;
 } languages[] = {
+       { "de_DE.utf8", L"Deutsch"},
        { "en_US.utf8", L"English"},
+       { "es_ES.utf8", L"Espa\u00f1ol"},
+       { "fr_FR.utf8", L"Fran\u00e7ais"},
+       { "it_IT.utf8", L"Italiano"},
+       { "ja_JP.utf8", L"\u65e5\u672c\u8a9e"},
+       { "ko_KR.utf8", L"\ud55c\uad6d\uc5b4"},
+       { "pt_BR.utf8", L"Portugu\u00eas/Brasil"},
+       { "ru_RU.utf8", L"\u0420\u0443\u0441\u0441\u043a\u0438\u0439"},
+       { "zh_CN.utf8", L"\u7b80\u4f53\u4e2d\u6587"},
+       { "zh_TW.utf8", L"\u7e41\u9ad4\u4e2d\u6587"},
 };
 
 struct lang_screen {
@@ -59,6 +69,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;
@@ -120,7 +131,6 @@ static int lang_screen_post(struct nc_scr *scr)
        struct lang_screen *screen = lang_screen_from_scr(scr);
        widgetset_post(screen->widgetset);
        nc_scr_frame_draw(scr);
-       redrawwin(scr->main_ncw);
        wrefresh(screen->scr.main_ncw);
        pad_refresh(screen);
        return 0;
@@ -160,6 +170,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 +220,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),
@@ -220,7 +237,7 @@ static void lang_screen_setup_empty(struct lang_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);
 }
 
@@ -265,9 +282,13 @@ 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"),
+       screen->widgets.cancel_b = widget_new_button(set, 0, 0, 10, _("Cancel"),
                        cancel_click, screen);
 }