]> git.ozlabs.org Git - petitboot/commitdiff
ui/ncurses: Add help to system configuration screen
authorJeremy Kerr <jk@ozlabs.org>
Fri, 13 Dec 2013 07:20:22 +0000 (15:20 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 31 Jan 2014 00:46:34 +0000 (08:46 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/Makefile.am
ui/ncurses/nc-config-help.c [new file with mode: 0644]
ui/ncurses/nc-config.c

index 3251489fbb335f018610b915ac57fb47df585590..2834f12710a04c87618d61d83fe3da6df98ff17a 100644 (file)
@@ -31,6 +31,7 @@ noinst_LTLIBRARIES = libpbnc.la
 libpbnc_la_SOURCES = \
        nc-config.c \
        nc-config.h \
 libpbnc_la_SOURCES = \
        nc-config.c \
        nc-config.h \
+       nc-config-help.c \
        nc-cui.c \
        nc-cui.h \
        nc-boot-editor.c \
        nc-cui.c \
        nc-cui.h \
        nc-boot-editor.c \
diff --git a/ui/ncurses/nc-config-help.c b/ui/ncurses/nc-config-help.c
new file mode 100644 (file)
index 0000000..90565b2
--- /dev/null
@@ -0,0 +1,25 @@
+const char *config_help_text = "\
+Autoboot: If you select this option, Petitboot will automatically choose the \
+default option shown in the main menu. Use this option if you want to quickly \
+boot your system without changing any boot option settings.\n"
+"\n"
+"Timeout: Specify the length of time, in seconds, that the main menu will be \
+displayed before the first option on the main menu is started by default. \
+Timeout is applied only if the Autoboot option is selected.\n"
+"\n"
+"Network options:\n"
+"\n"
+"DHCP on all active interfaces: Automatically assigns IP addresses to each \
+network interface. Use this option if you have a DHCP server on your \
+network.\n"
+"\n"
+"DHCP on a specific interface: Automatically assigns IP addresses to the \
+selected network interface. The other interfaces are not configured. Select \
+this option if you have multiple DHCP servers on different interfaces, but \
+only want to configure a single interface during boot.\n"
+"\n"
+"Static IP configuration: Allows you to specify an IPv4 address and network \
+mask, gateway, and a DNS server or servers for a network interface. Select \
+this option if you do not have a DHCP server, or want explicit control of \
+network settings."
+;
index 9cc6a29085ff3e4b21b14d3bb11ed4ec689e6763..8d68e7446499e700a16122c6726da68d6171ac98 100644 (file)
@@ -32,7 +32,9 @@
 #include "nc-config.h"
 #include "nc-widgets.h"
 
 #include "nc-config.h"
 #include "nc-widgets.h"
 
-#define N_FIELDS       23
+#define N_FIELDS       24
+
+extern const char *config_help_text;
 
 enum net_conf_type {
        NET_CONF_TYPE_DHCP_ALL,
 
 enum net_conf_type {
        NET_CONF_TYPE_DHCP_ALL,
@@ -47,6 +49,7 @@ struct config_screen {
        WINDOW                  *pad;
 
        bool                    exit;
        WINDOW                  *pad;
 
        bool                    exit;
+       bool                    show_help;
        void                    (*on_exit)(struct cui *);
 
        int                     scroll_y;
        void                    (*on_exit)(struct cui *);
 
        int                     scroll_y;
@@ -83,6 +86,7 @@ struct config_screen {
                struct nc_widget_label          *dns_help_l;
 
                struct nc_widget_button         *ok_b;
                struct nc_widget_label          *dns_help_l;
 
                struct nc_widget_button         *ok_b;
+               struct nc_widget_button         *help_b;
                struct nc_widget_button         *cancel_b;
        } widgets;
 };
                struct nc_widget_button         *cancel_b;
        } widgets;
 };
@@ -114,10 +118,17 @@ static void config_screen_process_key(struct nc_scr *scr, int key)
        bool handled;
 
        handled = widgetset_process_key(screen->widgetset, key);
        bool handled;
 
        handled = widgetset_process_key(screen->widgetset, key);
-       if (screen->exit)
+       if (screen->exit) {
                screen->on_exit(screen->cui);
                screen->on_exit(screen->cui);
-       else if (handled)
+
+       } else if (screen->show_help || (!handled && key == 'h')) {
+               screen->show_help = false;
+               cui_show_help(screen->cui, "System Configuration",
+                               config_help_text);
+
+       } else if (handled) {
                pad_refresh(screen);
                pad_refresh(screen);
+       }
 }
 
 static void config_screen_resize(struct nc_scr *scr)
 }
 
 static void config_screen_resize(struct nc_scr *scr)
@@ -269,6 +280,12 @@ static void ok_click(void *arg)
                screen->exit = true;
 }
 
                screen->exit = true;
 }
 
+static void help_click(void *arg)
+{
+       struct config_screen *screen = arg;
+       screen->show_help = true;
+}
+
 static void cancel_click(void *arg)
 {
        struct config_screen *screen = arg;
 static void cancel_click(void *arg)
 {
        struct config_screen *screen = arg;
@@ -388,8 +405,10 @@ static void config_screen_layout_widgets(struct config_screen *screen,
 
        widget_move(widget_button_base(screen->widgets.ok_b),
                        y, screen->field_x);
 
        widget_move(widget_button_base(screen->widgets.ok_b),
                        y, screen->field_x);
-       widget_move(widget_button_base(screen->widgets.cancel_b),
+       widget_move(widget_button_base(screen->widgets.help_b),
                        y, screen->field_x + 10);
                        y, screen->field_x + 10);
+       widget_move(widget_button_base(screen->widgets.cancel_b),
+                       y, screen->field_x + 20);
 }
 
 static void config_screen_network_change(void *arg, int value)
 }
 
 static void config_screen_network_change(void *arg, int value)
@@ -558,6 +577,8 @@ static void config_screen_setup_widgets(struct config_screen *screen,
 
        screen->widgets.ok_b = widget_new_button(set, 0, 0, 6, "OK",
                        ok_click, screen);
 
        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",
+                       help_click, screen);
        screen->widgets.cancel_b = widget_new_button(set, 0, 0, 6, "Cancel",
                        cancel_click, screen);
 }
        screen->widgets.cancel_b = widget_new_button(set, 0, 0, 6, "Cancel",
                        cancel_click, screen);
 }