mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 20:42:48 -05:00
Make the configuration dialog non-modal.
Now every call to do_config_box is replaced with a call to create_config_box, which returns immediately having constructed the new GTK window object, and is passed a callback function which it will arrange to be called when the dialog terminates (whether by OK or by Cancel). That callback is now what triggers the construction of a session window after 'Open' is pressed in the initial config box, or the actual mid-session reconfiguration action after 'Apply' is pressed in a Change Settings box. We were already prepared to ignore the re-selection of 'Change Settings' from the context menu of a window that already had a Change Settings box open (and not accidentally create a second config box for the same window); but now we do slightly better, by finding the existing config box and un-minimising and raising it, in case the user had forgotten it was there. That's a useful featurelet, but not the main purpose of this change. The mani point, of course, is that now the multi-window GtkApplication based front ends now don't do anything confusing to the nesting of gtk_main() when config boxes are involved. Whether you're changing the settings of one (or more than one) of your already-running sessions, preparing to start up a new PuTTY connection, or both at once, we stay in the same top-level instance of gtk_main() and all sessions' top- level callbacks continue to run sensibly.
This commit is contained in:
@ -296,8 +296,6 @@ static void version(FILE *fp) {
|
||||
sfree(buildinfo_text);
|
||||
}
|
||||
|
||||
static struct gui_data *the_inst;
|
||||
|
||||
static const char *geometry_string;
|
||||
|
||||
int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
|
||||
@ -540,10 +538,35 @@ GtkWidget *make_gtk_toplevel_window(void *frontend)
|
||||
return gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
}
|
||||
|
||||
extern int cfgbox(Conf *conf);
|
||||
|
||||
const int buildinfo_gtk_relevant = TRUE;
|
||||
|
||||
struct post_initial_config_box_ctx {
|
||||
Conf *conf;
|
||||
const char *geometry_string;
|
||||
};
|
||||
|
||||
static void post_initial_config_box(void *vctx, int result)
|
||||
{
|
||||
struct post_initial_config_box_ctx ctx =
|
||||
*(struct post_initial_config_box_ctx *)vctx;
|
||||
sfree(vctx);
|
||||
|
||||
if (result) {
|
||||
new_session_window(ctx.conf, ctx.geometry_string);
|
||||
} else {
|
||||
/* In this main(), which only runs one session in total, a
|
||||
* negative result from the initial config box means we simply
|
||||
* terminate. */
|
||||
conf_free(ctx.conf);
|
||||
gtk_main_quit();
|
||||
}
|
||||
}
|
||||
|
||||
void session_window_closed(void)
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Conf *conf;
|
||||
@ -614,21 +637,28 @@ int main(int argc, char **argv)
|
||||
need_config_box = (!allow_launch || !conf_launchable(conf));
|
||||
}
|
||||
|
||||
/*
|
||||
* Put up the config box.
|
||||
*/
|
||||
if (need_config_box && !cfgbox(conf))
|
||||
exit(0); /* config box hit Cancel */
|
||||
|
||||
/*
|
||||
* Create the main session window. We don't really need to keep
|
||||
* the return value - the fact that it'll be linked from a zillion
|
||||
* GTK and glib bits and bobs known to the main loop will be
|
||||
* sufficient to make everything actually happen - but we stash it
|
||||
* in a global variable anyway, so that it'll be easy to find in a
|
||||
* debugger.
|
||||
*/
|
||||
the_inst = new_session_window(conf, geometry_string);
|
||||
if (need_config_box) {
|
||||
/*
|
||||
* Put up the initial config box, which will pass the provided
|
||||
* parameters (with conf updated) to new_session_window() when
|
||||
* (if) the user selects Open. Or it might close without
|
||||
* creating a session window, if the user selects Cancel. Or
|
||||
* it might just create the session window immediately if this
|
||||
* is a pterm-style app which doesn't have an initial config
|
||||
* box at all.
|
||||
*/
|
||||
struct post_initial_config_box_ctx *ctx =
|
||||
snew(struct post_initial_config_box_ctx);
|
||||
ctx->conf = conf;
|
||||
ctx->geometry_string = geometry_string;
|
||||
initial_config_box(conf, post_initial_config_box, ctx);
|
||||
} else {
|
||||
/*
|
||||
* No initial config needed; just create the session window
|
||||
* now.
|
||||
*/
|
||||
new_session_window(conf, geometry_string);
|
||||
}
|
||||
|
||||
gtk_main();
|
||||
|
||||
|
Reference in New Issue
Block a user