}
write_setting_s (sesskey, "Protocol", p);
}
- write_setting_i (sesskey, "CloseOnExit", !!cfg->close_on_exit);
+ write_setting_i (sesskey, "CloseOnExit", cfg->close_on_exit);
write_setting_i (sesskey, "WarnOnClose", !!cfg->warn_on_close);
write_setting_i (sesskey, "PingInterval", cfg->ping_interval / 60); /* minutes */
write_setting_i (sesskey, "PingIntervalSecs", cfg->ping_interval % 60); /* seconds */
break;
}
- gppi (sesskey, "CloseOnExit", 1, &cfg->close_on_exit);
+ gppi (sesskey, "CloseOnExit", COE_NORMAL, &cfg->close_on_exit);
gppi (sesskey, "WarnOnClose", 1, &cfg->warn_on_close);
{
/* This is two values for backward compatibility with 0.50/0.51 */
IDC_SESSSAVE,
IDC_SESSDEL,
IDC_CLOSEEXIT,
+ IDC_COEALWAYS,
+ IDC_COENORMAL,
+ IDC_COENEVER,
sessionpanelend,
loggingpanelstart,
CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur);
CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar);
CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize);
- CheckDlgButton (hwnd, IDC_CLOSEEXIT, cfg.close_on_exit);
+ CheckRadioButton (hwnd, IDC_COEALWAYS, IDC_COENEVER,
+ cfg.close_on_exit==COE_NEVER ? IDC_COENEVER :
+ cfg.close_on_exit==COE_NORMAL ? IDC_COENORMAL : IDC_COEALWAYS);
CheckDlgButton (hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
*/
static void create_controls(HWND hwnd, int dlgtype, int panel) {
if (panel == sessionpanelstart) {
- /* The Session panel. Accelerators used: [acgo] nprtih elsd x */
+ /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
struct ctlpos cp;
ctlposinit(&cp, hwnd, 80, 3, 13);
bartitle(&cp, "Basic options for your PuTTY session",
endbox(&cp);
}
beginbox(&cp, NULL, IDC_BOX_SESSION3);
- checkbox(&cp, "Close Window on E&xit", IDC_CLOSEEXIT);
+ radioline(&cp, "At session end, close &window:", IDC_CLOSEEXIT, 3,
+ "Always", IDC_COEALWAYS,
+ "On clean exit", IDC_COENORMAL,
+ "Never", IDC_COENEVER, NULL);
endbox(&cp);
}
GetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle,
sizeof(cfg.wintitle)-1);
break;
- case IDC_CLOSEEXIT:
- if (HIWORD(wParam) == BN_CLICKED ||
- HIWORD(wParam) == BN_DOUBLECLICKED)
- cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_CLOSEEXIT);
- break;
+ case IDC_COEALWAYS:
+ case IDC_COENORMAL:
+ case IDC_COENEVER:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED) {
+ cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_COEALWAYS) ? COE_ALWAYS :
+ IsDlgButtonChecked (hwnd, IDC_COENORMAL) ? COE_NORMAL :
+ COE_NEVER;
+ }
+ break;
case IDC_CLOSEWARN:
if (HIWORD(wParam) == BN_CLICKED ||
HIWORD(wParam) == BN_DOUBLECLICKED)
vsprintf(stuff, fmt, ap);
va_end(ap);
MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK);
- if (cfg.close_on_exit)
+ if (cfg.close_on_exit == COE_ALWAYS)
PostQuitMessage(1);
else {
session_closed = TRUE;
ret = select_result (pend_netevent_wParam, pend_netevent_lParam);
reentering = 0;
- if (ret == 0) {
- if (cfg.close_on_exit)
+ if (ret == 0 && !session_closed) {
+ /* Abnormal exits will already have set session_closed and taken
+ * appropriate action. */
+ if (cfg.close_on_exit == COE_ALWAYS ||
+ cfg.close_on_exit == COE_NORMAL)
PostQuitMessage(0);
else {
- if (!session_closed) {
- session_closed = TRUE;
- SetWindowText (hwnd, "PuTTY (inactive)");
- MessageBox(hwnd, "Connection closed by remote host",
- "PuTTY", MB_OK | MB_ICONINFORMATION);
- }
+ session_closed = TRUE;
+ SetWindowText (hwnd, "PuTTY (inactive)");
+ MessageBox(hwnd, "Connection closed by remote host",
+ "PuTTY", MB_OK | MB_ICONINFORMATION);
}
}
}