Index: gedit/gedit-file.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-file.c,v
retrieving revision 1.59
diff -u -p -r1.59 gedit-file.c
--- gedit/gedit-file.c	31 Dec 2003 00:44:22 -0000	1.59
+++ gedit/gedit-file.c	7 Jan 2004 22:52:49 -0000
@@ -37,11 +37,13 @@
 #include <libgnomevfs/gnome-vfs.h>
 
 #include <eel/eel-vfs-extensions.h>
+#include <eel/eel-alert-dialog.h>
 #include <eel/eel-string.h>
 
 #include "gedit2.h"
 #include "gedit-file.h"
 #include "gedit-debug.h"
+#include "gedit-document.h"
 #include "gedit-utils.h"
 #include "gedit-mdi.h"
 #include "gedit-recent.h" 
@@ -51,6 +53,8 @@
 #include "gedit-prefs-manager-app.h"
 #include "gedit-metadata-manager.h"
 
+#include "dialogs/gedit-dialogs.h"
+
 static gchar 	*get_dirname_from_uri 		(const char *uri);
 static gboolean  gedit_file_open_real 		(const gchar* file_name, 
 						 const GeditEncoding *encoding,
@@ -80,7 +84,6 @@ get_dirname_from_uri (const char *uri)
 	return name;
 }
 
-
 void 
 gedit_file_new (void)
 {
@@ -549,14 +552,15 @@ gedit_file_save_as_real (const gchar* fi
 	}
 }
 
-
 gboolean
 gedit_file_close_all (void)
 {
-	gboolean ret;
+//	gboolean ret;
 	gedit_debug (DEBUG_FILE, "");
 
-	ret = bonobo_mdi_remove_all (BONOBO_MDI (gedit_mdi), FALSE);
+	gedit_close_all_confirmation_dialog (gedit_mdi);
+
+/*	ret = bonobo_mdi_remove_all (BONOBO_MDI (gedit_mdi), FALSE);
 
 	if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) == NULL)
 	{
@@ -565,6 +569,8 @@ gedit_file_close_all (void)
 	}
 
 	return ret;
+*/
+	return TRUE;
 }
 
 void
Index: gedit/gedit-mdi.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-mdi.c,v
retrieving revision 1.77
diff -u -p -r1.77 gedit-mdi.c
--- gedit/gedit-mdi.c	6 Jan 2004 18:31:56 -0000	1.77
+++ gedit/gedit-mdi.c	7 Jan 2004 22:52:51 -0000
@@ -59,8 +59,7 @@
 #include "recent-files/egg-recent-view-gtk.h"
 #include "recent-files/egg-recent-model.h"
 #include "gedit-languages-manager.h"
-
-#include <eel/eel-alert-dialog.h>
+#include "dialogs/gedit-dialogs.h"
 
 #include <bonobo/bonobo-ui-util.h>
 #include <bonobo/bonobo-control.h>
@@ -958,94 +957,9 @@ gedit_mdi_remove_child_handler (BonoboMD
 	doc = GEDIT_MDI_CHILD (child)->document;
 
 	if (gedit_document_get_modified (doc) || gedit_document_get_deleted (doc))
-	{
-		GtkWidget *msgbox, *w;
-		gchar *fname = NULL; 
-		gchar *msg = NULL;
-		gint ret;
-		gboolean exiting;
-
-		w = GTK_WIDGET (g_list_nth_data (bonobo_mdi_child_get_views (child), 0));
-			
-		if(w != NULL)
-		{
-			GtkWindow *window;
-
-			window = GTK_WINDOW (bonobo_mdi_get_window_from_view (w));
-			gtk_window_present (window);
-			
-			bonobo_mdi_set_active_view (mdi, w);
-		}
-
-		if (gedit_close_x_button_pressed)
-			exiting = FALSE;
-		else if (gedit_exit_button_pressed)
-			exiting = TRUE;
-		else
-		{
-			/* Delete event generated */
-			if (g_list_length (bonobo_mdi_get_windows (BONOBO_MDI (gedit_mdi))) == 1)
-				exiting = TRUE;
-			else
-				exiting = FALSE;
-		}
-
-		fname = gedit_document_get_short_name (doc);
-		msg = g_strdup_printf (_("Do you want to save the changes you made to the document \"%s\"?"),
-					fname);
-
-		msgbox = eel_alert_dialog_new (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)),
-				GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-				GTK_MESSAGE_QUESTION,
-				GTK_BUTTONS_NONE,
-				msg,
-				_("Your changes will be lost if you don't save them."),
-				NULL);
-		g_free (msg);
-		g_free (fname);
-
-#if 0		
-		if (exiting)
-			gedit_dialog_add_button (GTK_DIALOG (msgbox),
-					_("_Don't quit"), GTK_STOCK_NO,
-                	             	GTK_RESPONSE_NO);
-		else
-			gedit_dialog_add_button (GTK_DIALOG (msgbox),
-					_("_Don't close"), GTK_STOCK_NO,
-                	             	GTK_RESPONSE_NO);
-#endif
-		gedit_dialog_add_button (GTK_DIALOG (msgbox),
-				_("Do_n't save"), GTK_STOCK_NO,
-				GTK_RESPONSE_NO);
-
-		gtk_dialog_add_buttons (GTK_DIALOG (msgbox),
-					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-					GTK_STOCK_SAVE, GTK_RESPONSE_YES, NULL);
-
-		gtk_dialog_set_default_response	(GTK_DIALOG (msgbox), GTK_RESPONSE_YES);
-
-		/* gtk_widget_show (msgbox); */
-		gtk_window_present (GTK_WINDOW (msgbox));
-
-		ret = gtk_dialog_run (GTK_DIALOG (msgbox));
-		
-		switch (ret)
-		{
-			case GTK_RESPONSE_YES:
-				close = gedit_file_save (GEDIT_MDI_CHILD (child), TRUE);
-				break;
-			case GTK_RESPONSE_NO:
-				close = TRUE;
-				break;
-			default:
-				close = FALSE;
-		}
-
-		gtk_widget_destroy (msgbox);
+		close = gedit_close_confirmation_dialog (GEDIT_MDI (mdi),
+							 GEDIT_MDI_CHILD (child));
 
-		gedit_debug (DEBUG_MDI, "CLOSE: %s", close ? "TRUE" : "FALSE");
-	}
-	
 	/* FIXME: there is a bug if you "close all" >1 docs, don't save the document
 	 * and then don't close the last one.
 	 */
@@ -1853,3 +1767,34 @@ void gedit_mdi_update_languages_menu (Bo
 	g_free (verb_name);
 }
 
+GList *
+gedit_mdi_get_unsaved_children (GeditMDI *mdi)
+{
+	GList *ret = NULL;
+	GList *children;
+	GList *list;
+
+	children = bonobo_mdi_get_children (BONOBO_MDI (mdi));
+
+	for (list = children; list; list = list->next)
+	{
+		GeditDocument *doc;
+
+		doc = GEDIT_MDI_CHILD (list->data)->document;
+		if (!doc)
+		{
+			g_warning ("Child without doc!");
+			continue;
+		}
+
+		if (gedit_document_get_modified (doc) ||
+		    gedit_document_get_deleted (doc))
+			ret = g_list_prepend (ret, list->data);
+	}
+
+	ret = g_list_reverse (ret);
+
+	return ret;
+}
+
+
Index: gedit/gedit-mdi.h
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-mdi.h,v
retrieving revision 1.10
diff -u -p -r1.10 gedit-mdi.h
--- gedit/gedit-mdi.h	6 May 2003 14:39:03 -0000	1.10
+++ gedit/gedit-mdi.h	7 Jan 2004 22:52:51 -0000
@@ -76,5 +76,7 @@ void 		gedit_mdi_clear_active_window_sta
 EggRecentView	*gedit_mdi_get_recent_view_from_window (BonoboWindow* win);
 GtkWidget 	*gedit_mdi_get_output_window_from_window (BonoboWindow *win);
 
+GList *gedit_mdi_get_unsaved_children (GeditMDI *mdi);
+
 #endif /* __GEDIT_MDI_H__ */
 
Index: gedit/dialogs/Makefile.am
===================================================================
RCS file: /cvs/gnome/gedit/gedit/dialogs/Makefile.am,v
retrieving revision 1.34
diff -u -p -r1.34 Makefile.am
--- gedit/dialogs/Makefile.am	23 Nov 2003 23:01:51 -0000	1.34
+++ gedit/dialogs/Makefile.am	7 Jan 2004 22:52:52 -0000
@@ -16,7 +16,7 @@ endif
 
 noinst_LTLIBRARIES = libdialogs.la
 
-libdialogs_la_SOURCES = 			\
+libdialogs_la_SOURCES = 		\
 	gedit-dialog-uri.c		\
 	gedit-dialog-goto-line.c	\
 	gedit-dialog-replace.c		\
@@ -33,6 +33,7 @@ libdialogs_la_SOURCES = 			\
 	gedit-encodings-dialog.h	\
 	gedit-page-setup-dialog.c	\
 	gedit-page-setup-dialog.h	\
+	gedit-close-confirmation-dialog.c \
 	gedit-dialogs.h		
 
 glade_DATA =				\
@@ -43,7 +44,8 @@ glade_DATA =				\
 	gedit-preferences.glade2	\
 	program-location-dialog.glade2	\
 	gedit-encodings-dialog.glade2	\
-	page-setup-dialog.glade2
+	page-setup-dialog.glade2	\
+	close-confirmation.glade2
 
 EXTRA_DIST = $(glade_DATA) 
 
Index: gedit/dialogs/gedit-dialogs.h
===================================================================
RCS file: /cvs/gnome/gedit/gedit/dialogs/gedit-dialogs.h,v
retrieving revision 1.8
diff -u -p -r1.8 gedit-dialogs.h
--- gedit/dialogs/gedit-dialogs.h	26 Sep 2003 15:19:23 -0000	1.8
+++ gedit/dialogs/gedit-dialogs.h	7 Jan 2004 22:52:52 -0000
@@ -33,6 +33,8 @@
 #define __GEDIT_DIALOGS_H__
 
 #include <gtk/gtkwindow.h>
+#include "gedit-mdi.h"
+#include "gedit-mdi-child.h"
 
 GQuark gedit_was_wrap_around_quark (void);
 
@@ -48,4 +50,8 @@ gchar *gedit_plugin_program_location_dia
 					     const gchar *gconf_key,
 					     const gchar *help_id);
 
+gboolean gedit_close_confirmation_dialog (GeditMDI *mdi, GeditMDIChild *child);
+gboolean gedit_close_all_confirmation_dialog (GeditMDI *mdi);
+
+
 #endif /* __GEDIT_DIALOGS_H__ */
