Implement Warn On Close.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 11 Apr 2003 18:15:47 +0000 (18:15 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 11 Apr 2003 18:15:47 +0000 (18:15 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@3099 cda61777-01e9-0310-a592-d414129be87e

unix/gtkdlg.c
unix/pterm.c
unix/unix.h

index 68adec9..000fe04 100644 (file)
@@ -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)
 {
index 1fa1f99..a2074a3 100644 (file)
@@ -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;
 }
 
index fca0799..bb35a11 100644 (file)
@@ -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);