1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

If a new session was saved from Change Settings, a side-effect on Windows was

that the global `sesslist' got out of sync with the saved-sessions submenu,
causing the latter to launch the wrong sessions.

Also, Change Settings wasn't getting a fresh session list, so if the set of
sessions had changed since session startup it wouldn't reflect that (at least
until a session was saved). Fixed (on all platforms).

Therefore, since the global sesslist didn't seem to be useful, I've got rid
of it; config.c creates one as needed, as do the frontends. (Not tried
compiling Mac changes.)

Also, we now build the saved-sessions submenu on demand on Windows and Unix.
(This should probably also be done on the Mac.)

[originally from svn r5609]
This commit is contained in:
Jacob Nevins
2005-04-07 01:36:28 +00:00
parent a068889389
commit 52a17ab04a
9 changed files with 89 additions and 69 deletions

View File

@ -42,8 +42,6 @@ static int nevents = 0, negsize = 0;
extern Config cfg; /* defined in window.c */
struct sesslist sesslist; /* exported to window.c */
#define PRINTER_DISABLED_STRING "None (printing disabled)"
void force_normal(HWND hwnd)
@ -649,7 +647,7 @@ int do_config(void)
int ret;
ctrlbox = ctrl_new_box();
setup_config_box(ctrlbox, &sesslist, FALSE, 0, 0);
setup_config_box(ctrlbox, FALSE, 0, 0);
win_setup_config_box(ctrlbox, &dp.hwnd, (help_path != NULL), FALSE);
dp_init(&dp);
winctrl_init(&ctrls_base);
@ -661,11 +659,9 @@ int do_config(void)
dp.data = &cfg;
dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */
get_sesslist(&sesslist, TRUE);
ret =
SaneDialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL,
GenericMainDlgProc);
get_sesslist(&sesslist, FALSE);
ctrl_free_box(ctrlbox);
winctrl_cleanup(&ctrls_panel);
@ -683,7 +679,7 @@ int do_reconfig(HWND hwnd, int protcfginfo)
backup_cfg = cfg; /* structure copy */
ctrlbox = ctrl_new_box();
setup_config_box(ctrlbox, &sesslist, TRUE, cfg.protocol, protcfginfo);
setup_config_box(ctrlbox, TRUE, cfg.protocol, protcfginfo);
win_setup_config_box(ctrlbox, &dp.hwnd, (help_path != NULL), TRUE);
dp_init(&dp);
winctrl_init(&ctrls_base);

View File

@ -78,6 +78,7 @@ static void init_fonts(int, int);
static void another_font(int);
static void deinit_fonts(void);
static void set_input_locale(HKL);
static void update_savedsess_menu(void);
static int is_full_screen(void);
static void make_full_screen(void);
@ -121,10 +122,11 @@ static struct {
int specials_submenu_pos;
} popup_menus[2];
enum { SYSMENU, CTXMENU };
static HMENU savedsess_menu;
Config cfg; /* exported to windlg.c */
extern struct sesslist sesslist; /* imported from windlg.c */
static struct sesslist sesslist; /* for saved-session menu */
struct agent_callback {
void (*callback)(void *, void *, int);
@ -741,23 +743,17 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
* Set up the session-control options on the system menu.
*/
{
HMENU s, m;
int i, j;
HMENU m;
int j;
char *str;
popup_menus[SYSMENU].menu = GetSystemMenu(hwnd, FALSE);
popup_menus[CTXMENU].menu = CreatePopupMenu();
AppendMenu(popup_menus[CTXMENU].menu, MF_ENABLED, IDM_PASTE, "&Paste");
s = CreateMenu();
savedsess_menu = CreateMenu();
get_sesslist(&sesslist, TRUE);
/* skip sesslist.sessions[0] == Default Settings */
for (i = 1;
i < ((sesslist.nsessions <= MENU_SAVED_MAX+1) ? sesslist.nsessions
: MENU_SAVED_MAX+1);
i++)
AppendMenu(s, MF_ENABLED, IDM_SAVED_MIN + (i-1)*MENU_SAVED_STEP,
sesslist.sessions[i]);
update_savedsess_menu();
for (j = 0; j < lenof(popup_menus); j++) {
m = popup_menus[j].menu;
@ -768,7 +764,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session...");
AppendMenu(m, MF_ENABLED, IDM_DUPSESS, "&Duplicate Session");
AppendMenu(m, MF_POPUP | MF_ENABLED, (UINT) s, "Sa&ved Sessions");
AppendMenu(m, MF_POPUP | MF_ENABLED, (UINT) savedsess_menu,
"Sa&ved Sessions");
AppendMenu(m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings...");
AppendMenu(m, MF_SEPARATOR, 0, 0);
AppendMenu(m, MF_ENABLED, IDM_COPYALL, "C&opy All to Clipboard");
@ -895,6 +892,23 @@ char *do_select(SOCKET skt, int startup)
return NULL;
}
/*
* Refresh the saved-session submenu from `sesslist'.
*/
static void update_savedsess_menu(void)
{
int i;
while (DeleteMenu(savedsess_menu, 0, MF_BYPOSITION)) ;
/* skip sesslist.sessions[0] == Default Settings */
for (i = 1;
i < ((sesslist.nsessions <= MENU_SAVED_MAX+1) ? sesslist.nsessions
: MENU_SAVED_MAX+1);
i++)
AppendMenu(savedsess_menu, MF_ENABLED,
IDM_SAVED_MIN + (i-1)*MENU_SAVED_STEP,
sesslist.sessions[i]);
}
/*
* Update the Special Commands submenu.
*/
@ -1888,6 +1902,16 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
show_mouseptr(1);
PostQuitMessage(0);
return 0;
case WM_INITMENUPOPUP:
if ((HMENU)wParam == savedsess_menu) {
/* About to pop up Saved Sessions sub-menu.
* Refresh the session list. */
get_sesslist(&sesslist, FALSE); /* free */
get_sesslist(&sesslist, TRUE);
update_savedsess_menu();
return 0;
}
break;
case WM_COMMAND:
case WM_SYSCOMMAND:
switch (wParam & ~0xF) { /* low 4 bits reserved to Windows */