mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12: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:
@ -1956,7 +1956,6 @@ int do_config_box(const char *title, Config *cfg, int midsession,
|
||||
GtkTreeItem *treeitemlevels[8];
|
||||
GtkTree *treelevels[8];
|
||||
struct dlgparam dp;
|
||||
struct sesslist sl;
|
||||
struct Shortcuts scs;
|
||||
|
||||
struct selparam *selparams = NULL;
|
||||
@ -1964,8 +1963,6 @@ int do_config_box(const char *title, Config *cfg, int midsession,
|
||||
|
||||
dlg_init(&dp);
|
||||
|
||||
get_sesslist(&sl, TRUE);
|
||||
|
||||
listitemheight = get_listitemheight();
|
||||
|
||||
for (index = 0; index < lenof(scs.sc); index++) {
|
||||
@ -1975,7 +1972,7 @@ int do_config_box(const char *title, Config *cfg, int midsession,
|
||||
window = gtk_dialog_new();
|
||||
|
||||
ctrlbox = ctrl_new_box();
|
||||
setup_config_box(ctrlbox, &sl, midsession, cfg->protocol, protcfginfo);
|
||||
setup_config_box(ctrlbox, midsession, cfg->protocol, protcfginfo);
|
||||
unix_setup_config_box(ctrlbox, midsession);
|
||||
gtk_setup_config_box(ctrlbox, midsession, window);
|
||||
|
||||
@ -2161,7 +2158,6 @@ int do_config_box(const char *title, Config *cfg, int midsession,
|
||||
|
||||
gtk_main();
|
||||
|
||||
get_sesslist(&sl, FALSE);
|
||||
dlg_cleanup(&dp);
|
||||
sfree(selparams);
|
||||
|
||||
|
@ -3226,6 +3226,33 @@ void saved_session_freedata(GtkMenuItem *item, gpointer data)
|
||||
sfree(str);
|
||||
}
|
||||
|
||||
static void update_savedsess_menu(GtkMenuItem *menuitem, gpointer data)
|
||||
{
|
||||
struct gui_data *inst = (struct gui_data *)data;
|
||||
struct sesslist sesslist;
|
||||
int i;
|
||||
|
||||
gtk_container_foreach(GTK_CONTAINER(inst->sessionsmenu),
|
||||
(GtkCallback)gtk_widget_destroy, NULL);
|
||||
|
||||
get_sesslist(&sesslist, TRUE);
|
||||
for (i = 1; i < sesslist.nsessions; i++) {
|
||||
GtkWidget *menuitem =
|
||||
gtk_menu_item_new_with_label(sesslist.sessions[i]);
|
||||
gtk_container_add(GTK_CONTAINER(inst->sessionsmenu), menuitem);
|
||||
gtk_widget_show(menuitem);
|
||||
gtk_object_set_data(GTK_OBJECT(menuitem), "user-data",
|
||||
dupstr(sesslist.sessions[i]));
|
||||
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
|
||||
GTK_SIGNAL_FUNC(saved_session_menuitem),
|
||||
inst);
|
||||
gtk_signal_connect(GTK_OBJECT(menuitem), "destroy",
|
||||
GTK_SIGNAL_FUNC(saved_session_freedata),
|
||||
inst);
|
||||
}
|
||||
get_sesslist(&sesslist, FALSE); /* free up */
|
||||
}
|
||||
|
||||
void update_specials_menu(void *frontend)
|
||||
{
|
||||
struct gui_data *inst = (struct gui_data *)frontend;
|
||||
@ -3505,28 +3532,10 @@ int pt_main(int argc, char **argv)
|
||||
gtk_widget_hide(inst->restartitem);
|
||||
MKMENUITEM("Duplicate Session", dup_session_menuitem);
|
||||
if (saved_sessions) {
|
||||
struct sesslist sesslist;
|
||||
int i;
|
||||
|
||||
inst->sessionsmenu = gtk_menu_new();
|
||||
|
||||
get_sesslist(&sesslist, TRUE);
|
||||
for (i = 1; i < sesslist.nsessions; i++) {
|
||||
menuitem = gtk_menu_item_new_with_label(sesslist.sessions[i]);
|
||||
gtk_container_add(GTK_CONTAINER(inst->sessionsmenu), menuitem);
|
||||
gtk_widget_show(menuitem);
|
||||
gtk_object_set_data(GTK_OBJECT(menuitem), "user-data",
|
||||
dupstr(sesslist.sessions[i]));
|
||||
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
|
||||
GTK_SIGNAL_FUNC(saved_session_menuitem),
|
||||
inst);
|
||||
gtk_signal_connect(GTK_OBJECT(menuitem), "destroy",
|
||||
GTK_SIGNAL_FUNC(saved_session_freedata),
|
||||
inst);
|
||||
}
|
||||
get_sesslist(&sesslist, FALSE);
|
||||
|
||||
MKMENUITEM("Saved Sessions", NULL);
|
||||
/* sessionsmenu will be updated when it's invoked */
|
||||
/* XXX is this the right way to do dynamic menus in Gtk? */
|
||||
MKMENUITEM("Saved Sessions", update_savedsess_menu);
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),
|
||||
inst->sessionsmenu);
|
||||
}
|
||||
|
Reference in New Issue
Block a user