X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fnc-config.c;h=78e8e9e36e00476920022f661b81f30d19b0f944;hp=ee68a6fe622d4d822dc01eb661002fdb07581bc0;hb=90cc2a11507462e9c40f2494165741561729bdfb;hpb=28bd67dc4b57442dd1cd26794f44c66e700f7a9d diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index ee68a6f..78e8e9e 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -15,7 +15,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define _GNU_SOURCE +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif #include #include @@ -26,7 +28,6 @@ #include #include -#include "config.h" #include "nc-cui.h" #include "nc-config.h" #include "nc-widgets.h" @@ -471,17 +472,22 @@ static void config_screen_setup_widgets(struct config_screen *screen, config_screen_network_change, screen); screen->widgets.iface_l = widget_new_label(set, 0, 0, "Device:"); - screen->widgets.iface_f = widget_new_select(set, 0, 0, 20); + screen->widgets.iface_f = widget_new_select(set, 0, 0, 50); for (i = 0; i < sysinfo->n_interfaces; i++) { struct interface_info *info = sysinfo->interfaces[i]; + char str[50], mac[20]; bool is_default; is_default = ifcfg && !memcmp(ifcfg->hwaddr, info->hwaddr, sizeof(ifcfg->hwaddr)); + mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac)); + snprintf(str, sizeof(str), "%s [%s, %s]", info->name, mac, + info->link ? "link up" : "link down"); + widget_select_add_option(screen->widgets.iface_f, - i, info->name, is_default); + i, str, is_default); } gw = ip = mask = NULL; @@ -502,7 +508,7 @@ static void config_screen_setup_widgets(struct config_screen *screen, screen->widgets.ip_addr_l = widget_new_label(set, 0, 0, "IP/mask:"); screen->widgets.ip_addr_f = widget_new_textbox(set, 0, 0, 16, ip); screen->widgets.ip_mask_l = widget_new_label(set, 0, 0, "/"); - screen->widgets.ip_mask_f = widget_new_textbox(set, 0, 0, 3, mask); + screen->widgets.ip_mask_f = widget_new_textbox(set, 0, 0, 4, mask); screen->widgets.ip_addr_mask_help_l = widget_new_label(set, 0, 0, "(eg. 192.168.0.10 / 24)"); @@ -535,17 +541,16 @@ static void config_screen_setup_widgets(struct config_screen *screen, static void config_screen_widget_focus(struct nc_widget *widget, void *arg) { struct config_screen *screen = arg; - int w_y, w_height, s_max; + int w_y, s_max; - w_y = widget_y(widget); - w_height = widget_height(widget); - s_max = getmaxy(screen->scr.sub_ncw); + w_y = widget_y(widget) + widget_focus_y(widget); + s_max = getmaxy(screen->scr.sub_ncw) - 1; if (w_y < screen->scroll_y) screen->scroll_y = w_y; - else if (w_y + w_height + screen->scroll_y > s_max - 1) - screen->scroll_y = 1 + w_y + w_height - s_max; + else if (w_y + screen->scroll_y + 1 > s_max) + screen->scroll_y = 1 + w_y - s_max; else return; @@ -571,7 +576,7 @@ void config_screen_update(struct config_screen *screen, height = N_FIELDS + 3; if (sysinfo) height += sysinfo->n_interfaces; - if (!screen->pad || getmaxx(screen->pad) < height) { + if (!screen->pad || getmaxy(screen->pad) < height) { if (screen->pad) delwin(screen->pad); screen->pad = newpad(height, COLS);