X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/4eaff8d484f9fadb26c593f64f4e9513aa71b959..d4413bd2bbee00fa4a058e6c3a58c11d5596cd3d:/config.c diff --git a/config.c b/config.c index ed2bee66..239247db 100644 --- a/config.c +++ b/config.c @@ -133,12 +133,18 @@ static void printerbox_handler(union control *ctrl, void *dlg, printer_enum *pe; dlg_update_start(ctrl, dlg); - dlg_listbox_clear(ctrl, dlg); - dlg_listbox_add(ctrl, dlg, PRINTER_DISABLED_STRING); - pe = printer_start_enum(&nprinters); - for (i = 0; i < nprinters; i++) - dlg_listbox_add(ctrl, dlg, printer_get_name(pe, i)); - printer_finish_enum(pe); + /* + * Some backends may wish to disable the drop-down list on + * this edit box. Be prepared for this. + */ + if (ctrl->editbox.has_list) { + dlg_listbox_clear(ctrl, dlg); + dlg_listbox_add(ctrl, dlg, PRINTER_DISABLED_STRING); + pe = printer_start_enum(&nprinters); + for (i = 0; i < nprinters; i++) + dlg_listbox_add(ctrl, dlg, printer_get_name(pe, i)); + printer_finish_enum(pe); + } dlg_editbox_set(ctrl, dlg, (*cfg->printer ? cfg->printer : PRINTER_DISABLED_STRING)); @@ -156,7 +162,7 @@ static void codepage_handler(union control *ctrl, void *dlg, Config *cfg = (Config *)data; if (event == EVENT_REFRESH) { int i; - char *cp; + const char *cp; dlg_update_start(ctrl, dlg); strcpy(cfg->line_codepage, cp_name(decode_codepage(cfg->line_codepage))); @@ -305,7 +311,13 @@ static void sessionsaver_handler(union control *ctrl, void *dlg, savedsession[0] = '\0'; } } - save_settings(savedsession, !isdef, cfg); + { + char *errmsg = save_settings(savedsession, !isdef, cfg); + if (errmsg) { + dlg_error_msg(dlg, errmsg); + sfree(errmsg); + } + } get_sesslist(ssd->sesslist, FALSE); get_sesslist(ssd->sesslist, TRUE); dlg_refresh(ssd->editbox, dlg); @@ -628,24 +640,31 @@ static void portfwd_handler(union control *ctrl, void *dlg, if (ctrl == pfd->addbutton) { char str[sizeof(cfg->portfwd)]; char *p; - if (dlg_radiobutton_get(pfd->direction, dlg) == 0) + int whichbutton = dlg_radiobutton_get(pfd->direction, dlg); + if (whichbutton == 0) str[0] = 'L'; - else + else if (whichbutton == 1) str[0] = 'R'; + else + str[0] = 'D'; dlg_editbox_get(pfd->sourcebox, dlg, str+1, sizeof(str) - 2); if (!str[1]) { dlg_error_msg(dlg, "You need to specify a source port number"); return; } p = str + strlen(str); - *p++ = '\t'; - dlg_editbox_get(pfd->destbox, dlg, p, sizeof(str)-1 - (p - str)); - if (!*p || !strchr(p, ':')) { - dlg_error_msg(dlg, - "You need to specify a destination address\n" - "in the form \"host.name:port\""); - return; - } + if (str[0] != 'D') { + *p++ = '\t'; + dlg_editbox_get(pfd->destbox, dlg, p, + sizeof(str)-1 - (p - str)); + if (!*p || !strchr(p, ':')) { + dlg_error_msg(dlg, + "You need to specify a destination address\n" + "in the form \"host.name:port\""); + return; + } + } else + *p = '\0'; p = cfg->portfwd; while (*p) { while (*p) @@ -1141,7 +1160,7 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist, charclass_handler, P(ccd)); ccd->listbox->listbox.multisel = 1; ccd->listbox->listbox.ncols = 4; - ccd->listbox->listbox.percentages = smalloc(4*sizeof(int)); + ccd->listbox->listbox.percentages = snewn(4, int); ccd->listbox->listbox.percentages[0] = 15; ccd->listbox->listbox.percentages[1] = 25; ccd->listbox->listbox.percentages[2] = 20; @@ -1345,7 +1364,7 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist, environ_handler, P(ed)); ed->listbox->listbox.height = 3; ed->listbox->listbox.ncols = 2; - ed->listbox->listbox.percentages = smalloc(2*sizeof(int)); + ed->listbox->listbox.percentages = snewn(2, int); ed->listbox->listbox.percentages[0] = 30; ed->listbox->listbox.percentages[1] = 70; } @@ -1525,7 +1544,7 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist, portfwd_handler, P(pfd)); pfd->listbox->listbox.height = 3; pfd->listbox->listbox.ncols = 2; - pfd->listbox->listbox.percentages = smalloc(2*sizeof(int)); + pfd->listbox->listbox.percentages = snewn(2, int); pfd->listbox->listbox.percentages[0] = 20; pfd->listbox->listbox.percentages[1] = 80; ctrl_tabdelay(s, pfd->rembutton); @@ -1544,11 +1563,13 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist, pfd->destbox = ctrl_editbox(s, "Destination", 'i', 67, HELPCTX(ssh_tunnels_portfwd), portfwd_handler, P(pfd), P(NULL)); - pfd->direction = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 2, + pfd->direction = ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3, HELPCTX(ssh_tunnels_portfwd), portfwd_handler, P(pfd), "Local", 'l', P(NULL), - "Remote", 'm', P(NULL), NULL); + "Remote", 'm', P(NULL), + "Dynamic", 'y', P(NULL), + NULL); ctrl_tabdelay(s, pfd->addbutton); ctrl_columns(s, 1, 100);