From abb6895f8e13fb0fda3b6567a2b36b590ea7bfda Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 11 Apr 2003 18:15:47 +0000 Subject: [PATCH] Implement Warn On Close. git-svn-id: svn://svn.tartarus.org/sgt/putty@3099 cda61777-01e9-0310-a592-d414129be87e --- unix/gtkdlg.c | 13 +++++++++++++ unix/pterm.c | 9 +++++---- unix/unix.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index 68adec94..000fe04a 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -2269,6 +2269,19 @@ static int string_width(char *text) return req.width; } +int reallyclose(void *frontend) +{ + char *title = dupcat(appname, " Exit Confirmation", NULL); + int ret = messagebox(GTK_WIDGET(get_window(frontend)), + title, "Are you sure you want to close this session?", + string_width("Most of the width of the above text"), + "Yes", 'y', +1, 1, + "No", 'n', -1, 0, + NULL); + sfree(title); + return ret; +} + void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype, char *keystr, char *fingerprint) { diff --git a/unix/pterm.c b/unix/pterm.c index 1fa1f992..a2074a36 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -349,10 +349,11 @@ char *get_window_title(void *frontend, int icon) gint delete_window(GtkWidget *widget, GdkEvent *event, gpointer data) { - /* - * We could implement warn-on-close here if we really wanted - * to. - */ + struct gui_data *inst = (struct gui_data *)data; + if (inst->cfg.warn_on_close) { + if (!reallyclose(inst->term)) + return TRUE; + } return FALSE; } diff --git a/unix/unix.h b/unix/unix.h index fca07999..bb35a116 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -65,6 +65,7 @@ void about_box(void *window); void *eventlogstuff_new(void); void showeventlog(void *estuff, void *parentwin); void logevent_dlg(void *estuff, char *string); +int reallyclose(void *frontend); /* Things pterm.c needs from {ptermm,uxputty}.c */ char *make_default_wintitle(char *hostname); -- 2.11.0