Index: gnome-terminal.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/gnome-terminal.schemas.in,v
retrieving revision 1.32
diff -U5 -r1.32 gnome-terminal.schemas.in
--- gnome-terminal.schemas.in	30 May 2003 05:09:51 -0000	1.32
+++ gnome-terminal.schemas.in	30 Jun 2003 05:29:34 -0000
@@ -89,10 +89,24 @@
           means to display the encoding of the current locale.
          </long>
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/gnome-terminal/global/confirm_window_close</key>
+      <applyto>/apps/gnome-terminal/global/confirm_window_close</applyto>
+      <owner>gnome-terminal</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Whether to ask for confirmation when closing terminal windows</short>
+         <long>
+	 Whether to ask for confirmation when closing a terminal window which has
+	 more than one open tab.
+         </long>
+      </locale>
+    </schema>
 
 
 
     <!-- Per-profile settings -->
 
Index: terminal-window.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-window.c,v
retrieving revision 1.74
diff -U5 -r1.74 terminal-window.c
--- terminal-window.c	29 Jun 2003 04:29:43 -0000	1.74
+++ terminal-window.c	30 Jun 2003 05:29:35 -0000
@@ -101,10 +101,14 @@
 static void terminal_window_init        (TerminalWindow      *window);
 static void terminal_window_class_init  (TerminalWindowClass *klass);
 static void terminal_window_finalize    (GObject             *object);
 static void terminal_window_destroy     (GtkObject           *object);
 
+static gboolean terminal_window_delete_event (GtkWidget *widget,
+                                              GdkEvent *event,
+                                              gpointer data);
+
 static void       screen_set_scrollbar (TerminalScreen *screen,
                                         GtkWidget      *scrollbar);
 static void       screen_set_hbox      (TerminalScreen *screen,
                                         GtkWidget      *hbox);
 static void       screen_set_label     (TerminalScreen *screen,
@@ -205,10 +209,12 @@
 static gboolean find_smaller_zoom_factor (double  current,
                                           double *found);
 
 static void terminal_window_show (GtkWidget *widget);
 
+static gboolean confirm_close_window (TerminalWindow *window);
+
 static gpointer parent_class;
 
 GType
 terminal_window_get_type (void)
 {
@@ -702,12 +708,15 @@
   GtkWidget *menu;
   GtkAccelGroup *accel_group;
   GtkWidget *copy_image, *paste_image, *contents_image, *about_image;
   GError *error;
   gboolean use_image;
-
   
+  g_signal_connect (G_OBJECT (window), "delete_event", 
+                    G_CALLBACK(terminal_window_delete_event),
+                    NULL);
+
   gtk_window_set_title (GTK_WINDOW (window), _("Terminal"));
   client = gconf_client_get_default();
   
   window->priv = g_new0 (TerminalWindowPrivate, 1);
   window->priv->terms = NULL;
@@ -1039,10 +1048,18 @@
   window->priv->encoding_menuitem = NULL;
   
   GTK_OBJECT_CLASS (parent_class)->destroy (object);  
 }
 
+static gboolean
+terminal_window_delete_event (GtkWidget *widget,
+                              GdkEvent *event,
+                              gpointer data)
+{
+   return !confirm_close_window (TERMINAL_WINDOW (widget));
+}
+
 static void
 sn_error_trap_push (SnDisplay *display,
                     Display   *xdisplay)
 {
   gdk_error_trap_push ();
@@ -2215,15 +2232,45 @@
                                  FALSE, FALSE, NULL, NULL, NULL, dir, NULL, 1.0,
                                  NULL, NULL, -1);
     }
 }
 
+static gboolean
+confirm_close_window (TerminalWindow *window)
+{
+  GtkWidget *dialog;
+  GError *error;
+  gboolean result;
+
+  if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) <= 1)
+    return TRUE;
+
+  client = gconf_client_get_default();
+  error = NULL;
+  if (!gconf_client_get_bool (client, CONF_GLOBAL_PREFIX "/confirm_window_close", &error))
+    return TRUE;
+
+  dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_WARNING,
+                                   GTK_BUTTONS_NONE,
+                                   _("Do you really want to close this window?"));
+  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_YES);
+
+  result = gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES;
+  gtk_widget_destroy (dialog);
+
+  return result;
+}
+
 static void
 close_window_callback (GtkWidget      *menuitem,
                        TerminalWindow *window)
 {
-  gtk_widget_destroy (GTK_WIDGET (window));
+  if (confirm_close_window (window))
+    gtk_widget_destroy (GTK_WIDGET (window));
 }
 
 static void
 close_tab_callback (GtkWidget      *menuitem,
                     TerminalWindow *window)
