diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 88b438a5..00e07485 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -131,6 +131,7 @@ struct gui_data { void *eventlogstuff; guint32 input_event_time; /* Timestamp of the most recent input event. */ GtkWidget *reconfigure_dialog; + GtkWidget *network_prompt_dialog; #if GTK_CHECK_VERSION(3,4,0) gdouble cumulative_scroll; #endif @@ -301,12 +302,30 @@ static Mouse_Button translate_button(Mouse_Button button) * Return the top-level GtkWindow associated with a particular * front end instance. */ -void *get_window(void *frontend) +GtkWidget *get_window(void *frontend) { struct gui_data *inst = (struct gui_data *)frontend; return inst->window; } +/* + * Set and clear a pointer to a dialog box created as a result of the + * network code wanting to ask an asynchronous user question (e.g. + * 'what about this dodgy host key, then?'). + */ +void register_network_prompt_dialog(void *frontend, GtkWidget *dialog) +{ + struct gui_data *inst = (struct gui_data *)frontend; + assert(!inst->network_prompt_dialog); + inst->network_prompt_dialog = dialog; +} +void unregister_network_prompt_dialog(void *frontend) +{ + struct gui_data *inst = (struct gui_data *)frontend; + assert(inst->network_prompt_dialog); + inst->network_prompt_dialog = NULL; +} + /* * Minimise or restore the window in response to a server-side * request. @@ -2025,6 +2044,10 @@ static void delete_inst(struct gui_data *inst) gtk_widget_destroy(inst->reconfigure_dialog); inst->reconfigure_dialog = NULL; } + if (inst->network_prompt_dialog) { + gtk_widget_destroy(inst->network_prompt_dialog); + inst->network_prompt_dialog = NULL; + } if (inst->window) { gtk_widget_destroy(inst->window); inst->window = NULL; diff --git a/unix/unix.h b/unix/unix.h index a9bd71f4..979fe448 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -147,7 +147,11 @@ int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */ long get_windowid(void *frontend); /* Things gtkdlg.c needs from pterm.c */ -void *get_window(void *frontend); /* void * to avoid depending on gtk.h */ +#ifdef MAY_REFER_TO_GTK_IN_HEADERS +GtkWidget *get_window(void *frontend); +void register_network_prompt_dialog(void *frontend, GtkWidget *dialog); +void unregister_network_prompt_dialog(void *frontend); +#endif void post_main(void); /* called after any subsidiary gtk_main() */ /* Things pterm.c needs from gtkdlg.c */