mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-31 00:40:28 -05:00
Expand the dialog registering/unregistering system.
Now it has several 'slots', each named for a particular class of subsidiary dialog box that a session window can have at most one of, and register_network_prompt_dialog has a more general name and takes an enum-typed argument identifying a slot. This lets me avoid writing a zillion annoyingly similar function pairs and corresponding snippets of cleanup code in delete_inst.
This commit is contained in:
parent
f212e2cbea
commit
86741a1b09
@ -3553,7 +3553,7 @@ static void verify_ssh_host_key_result_callback(void *vctx, int result)
|
|||||||
* Clean up this context structure, whether or not a result was
|
* Clean up this context structure, whether or not a result was
|
||||||
* ever actually delivered from the dialog box.
|
* ever actually delivered from the dialog box.
|
||||||
*/
|
*/
|
||||||
unregister_network_prompt_dialog(ctx->frontend);
|
unregister_dialog(ctx->frontend, DIALOG_SLOT_NETWORK_PROMPT);
|
||||||
|
|
||||||
sfree(ctx->host);
|
sfree(ctx->host);
|
||||||
sfree(ctx->keytype);
|
sfree(ctx->keytype);
|
||||||
@ -3628,7 +3628,7 @@ int verify_ssh_host_key(void *frontend, char *host, int port,
|
|||||||
msgbox = create_message_box(
|
msgbox = create_message_box(
|
||||||
mainwin, "PuTTY Security Alert", text, string_width(fingerprint), TRUE,
|
mainwin, "PuTTY Security Alert", text, string_width(fingerprint), TRUE,
|
||||||
&buttons_hostkey, verify_ssh_host_key_result_callback, result_ctx);
|
&buttons_hostkey, verify_ssh_host_key_result_callback, result_ctx);
|
||||||
register_network_prompt_dialog(frontend, msgbox);
|
register_dialog(frontend, DIALOG_SLOT_NETWORK_PROMPT, msgbox);
|
||||||
|
|
||||||
sfree(text);
|
sfree(text);
|
||||||
|
|
||||||
@ -3653,7 +3653,7 @@ static void simple_network_prompt_result_callback(void *vctx, int result)
|
|||||||
* Clean up this context structure, whether or not a result was
|
* Clean up this context structure, whether or not a result was
|
||||||
* ever actually delivered from the dialog box.
|
* ever actually delivered from the dialog box.
|
||||||
*/
|
*/
|
||||||
unregister_network_prompt_dialog(ctx->frontend);
|
unregister_dialog(ctx->frontend, DIALOG_SLOT_NETWORK_PROMPT);
|
||||||
sfree(ctx);
|
sfree(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3685,7 +3685,7 @@ int askalg(void *frontend, const char *algtype, const char *algname,
|
|||||||
mainwin, "PuTTY Security Alert", text,
|
mainwin, "PuTTY Security Alert", text,
|
||||||
string_width("Reasonably long line of text as a width template"),
|
string_width("Reasonably long line of text as a width template"),
|
||||||
FALSE, &buttons_yn, simple_network_prompt_result_callback, result_ctx);
|
FALSE, &buttons_yn, simple_network_prompt_result_callback, result_ctx);
|
||||||
register_network_prompt_dialog(frontend, msgbox);
|
register_dialog(frontend, DIALOG_SLOT_NETWORK_PROMPT, msgbox);
|
||||||
|
|
||||||
sfree(text);
|
sfree(text);
|
||||||
|
|
||||||
@ -3720,7 +3720,7 @@ int askhk(void *frontend, const char *algname, const char *betteralgs,
|
|||||||
string_width("is ecdsa-nistp521, which is below the configured"
|
string_width("is ecdsa-nistp521, which is below the configured"
|
||||||
" warning threshold."),
|
" warning threshold."),
|
||||||
FALSE, &buttons_yn, simple_network_prompt_result_callback, result_ctx);
|
FALSE, &buttons_yn, simple_network_prompt_result_callback, result_ctx);
|
||||||
register_network_prompt_dialog(frontend, msgbox);
|
register_dialog(frontend, DIALOG_SLOT_NETWORK_PROMPT, msgbox);
|
||||||
|
|
||||||
sfree(text);
|
sfree(text);
|
||||||
|
|
||||||
|
@ -130,8 +130,7 @@ struct gui_data {
|
|||||||
Conf *conf;
|
Conf *conf;
|
||||||
void *eventlogstuff;
|
void *eventlogstuff;
|
||||||
guint32 input_event_time; /* Timestamp of the most recent input event. */
|
guint32 input_event_time; /* Timestamp of the most recent input event. */
|
||||||
GtkWidget *reconfigure_dialog;
|
GtkWidget *dialogs[DIALOG_SLOT_LIMIT];
|
||||||
GtkWidget *network_prompt_dialog;
|
|
||||||
#if GTK_CHECK_VERSION(3,4,0)
|
#if GTK_CHECK_VERSION(3,4,0)
|
||||||
gdouble cumulative_scroll;
|
gdouble cumulative_scroll;
|
||||||
#endif
|
#endif
|
||||||
@ -313,17 +312,19 @@ GtkWidget *get_window(void *frontend)
|
|||||||
* network code wanting to ask an asynchronous user question (e.g.
|
* network code wanting to ask an asynchronous user question (e.g.
|
||||||
* 'what about this dodgy host key, then?').
|
* 'what about this dodgy host key, then?').
|
||||||
*/
|
*/
|
||||||
void register_network_prompt_dialog(void *frontend, GtkWidget *dialog)
|
void register_dialog(void *frontend, enum DialogSlot slot, GtkWidget *dialog)
|
||||||
{
|
{
|
||||||
struct gui_data *inst = (struct gui_data *)frontend;
|
struct gui_data *inst = (struct gui_data *)frontend;
|
||||||
assert(!inst->network_prompt_dialog);
|
assert(slot < DIALOG_SLOT_LIMIT);
|
||||||
inst->network_prompt_dialog = dialog;
|
assert(!inst->dialogs[slot]);
|
||||||
|
inst->dialogs[slot] = dialog;
|
||||||
}
|
}
|
||||||
void unregister_network_prompt_dialog(void *frontend)
|
void unregister_dialog(void *frontend, enum DialogSlot slot)
|
||||||
{
|
{
|
||||||
struct gui_data *inst = (struct gui_data *)frontend;
|
struct gui_data *inst = (struct gui_data *)frontend;
|
||||||
assert(inst->network_prompt_dialog);
|
assert(slot < DIALOG_SLOT_LIMIT);
|
||||||
inst->network_prompt_dialog = NULL;
|
assert(inst->dialogs[slot]);
|
||||||
|
inst->dialogs[slot] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2039,13 +2040,12 @@ void notify_remote_exit(void *frontend)
|
|||||||
|
|
||||||
static void delete_inst(struct gui_data *inst)
|
static void delete_inst(struct gui_data *inst)
|
||||||
{
|
{
|
||||||
if (inst->reconfigure_dialog) {
|
int dialog_slot;
|
||||||
gtk_widget_destroy(inst->reconfigure_dialog);
|
for (dialog_slot = 0; dialog_slot < DIALOG_SLOT_LIMIT; dialog_slot++) {
|
||||||
inst->reconfigure_dialog = NULL;
|
if (inst->dialogs[dialog_slot]) {
|
||||||
}
|
gtk_widget_destroy(inst->dialogs[dialog_slot]);
|
||||||
if (inst->network_prompt_dialog) {
|
inst->dialogs[dialog_slot] = NULL;
|
||||||
gtk_widget_destroy(inst->network_prompt_dialog);
|
}
|
||||||
inst->network_prompt_dialog = NULL;
|
|
||||||
}
|
}
|
||||||
if (inst->window) {
|
if (inst->window) {
|
||||||
gtk_widget_destroy(inst->window);
|
gtk_widget_destroy(inst->window);
|
||||||
@ -4005,17 +4005,18 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
|
|||||||
{
|
{
|
||||||
struct gui_data *inst = (struct gui_data *)data;
|
struct gui_data *inst = (struct gui_data *)data;
|
||||||
struct after_change_settings_dialog_ctx *ctx;
|
struct after_change_settings_dialog_ctx *ctx;
|
||||||
|
GtkWidget *dialog;
|
||||||
char *title;
|
char *title;
|
||||||
|
|
||||||
if (inst->reconfigure_dialog) {
|
if ((dialog = inst->dialogs[DIALOG_SLOT_RECONFIGURE]) != NULL) {
|
||||||
/*
|
/*
|
||||||
* If this window already had a Change Settings box open, just
|
* If this window already had a Change Settings box open, just
|
||||||
* find it and try to make it more prominent.
|
* find it and try to make it more prominent.
|
||||||
*/
|
*/
|
||||||
#if GTK_CHECK_VERSION(2,0,0)
|
#if GTK_CHECK_VERSION(2,0,0)
|
||||||
gtk_window_deiconify(GTK_WINDOW(inst->reconfigure_dialog));
|
gtk_window_deiconify(GTK_WINDOW(dialog));
|
||||||
#endif
|
#endif
|
||||||
gdk_window_raise(gtk_widget_get_window(inst->reconfigure_dialog));
|
gdk_window_raise(gtk_widget_get_window(dialog));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4025,10 +4026,11 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data)
|
|||||||
ctx->inst = inst;
|
ctx->inst = inst;
|
||||||
ctx->newconf = conf_copy(inst->conf);
|
ctx->newconf = conf_copy(inst->conf);
|
||||||
|
|
||||||
inst->reconfigure_dialog = create_config_box(
|
dialog = create_config_box(
|
||||||
title, ctx->newconf, 1,
|
title, ctx->newconf, 1,
|
||||||
inst->back ? inst->back->cfg_info(inst->backhandle) : 0,
|
inst->back ? inst->back->cfg_info(inst->backhandle) : 0,
|
||||||
after_change_settings_dialog, ctx);
|
after_change_settings_dialog, ctx);
|
||||||
|
register_dialog(inst, DIALOG_SLOT_RECONFIGURE, dialog);
|
||||||
|
|
||||||
sfree(title);
|
sfree(title);
|
||||||
}
|
}
|
||||||
@ -4058,7 +4060,7 @@ static void after_change_settings_dialog(void *vctx, int retval)
|
|||||||
|
|
||||||
assert(lenof(ww) == NCFGCOLOURS);
|
assert(lenof(ww) == NCFGCOLOURS);
|
||||||
|
|
||||||
inst->reconfigure_dialog = NULL;
|
unregister_dialog(inst, DIALOG_SLOT_RECONFIGURE);
|
||||||
|
|
||||||
if (retval) {
|
if (retval) {
|
||||||
inst->conf = newconf;
|
inst->conf = newconf;
|
||||||
|
@ -149,8 +149,13 @@ long get_windowid(void *frontend);
|
|||||||
/* Things gtkdlg.c needs from pterm.c */
|
/* Things gtkdlg.c needs from pterm.c */
|
||||||
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
||||||
GtkWidget *get_window(void *frontend);
|
GtkWidget *get_window(void *frontend);
|
||||||
void register_network_prompt_dialog(void *frontend, GtkWidget *dialog);
|
enum DialogSlot {
|
||||||
void unregister_network_prompt_dialog(void *frontend);
|
DIALOG_SLOT_RECONFIGURE,
|
||||||
|
DIALOG_SLOT_NETWORK_PROMPT,
|
||||||
|
DIALOG_SLOT_LIMIT /* must remain last */
|
||||||
|
};
|
||||||
|
void register_dialog(void *frontend, enum DialogSlot slot, GtkWidget *dialog);
|
||||||
|
void unregister_dialog(void *frontend, enum DialogSlot slot);
|
||||||
#endif
|
#endif
|
||||||
void post_main(void); /* called after any subsidiary gtk_main() */
|
void post_main(void); /* called after any subsidiary gtk_main() */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user