Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.399
diff -p -u -r1.399 e-msg-composer.c
--- composer/e-msg-composer.c	7 Jul 2003 21:33:14 -0000	1.399
+++ composer/e-msg-composer.c	15 Jul 2003 10:32:01 -0000
@@ -1248,11 +1248,20 @@ autosave_save_draft (EMsgComposer *compo
 	CamelStream *stream;
 	char *file;
 	int fd, camelfd;
+	CORBA_Environment ev;
+	gboolean rv = FALSE;
 	gboolean success = TRUE;
 	
-	if (!e_msg_composer_is_dirty (composer))
-		return TRUE;
-	
+	if (!composer->has_changed_autosave) {
+		CORBA_exception_init (&ev);
+		rv = GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "is-autosaved", &ev);
+		CORBA_exception_free (&ev);
+
+		if (rv) {
+			return TRUE;
+		}
+	}
+
 	fd = composer->autosave_fd;
 	file = composer->autosave_file;
 	
@@ -1301,6 +1310,12 @@ autosave_save_draft (EMsgComposer *compo
 			  _("Error autosaving message: %s\n %s"), file, strerror(errno));
 		
 		success = FALSE;
+	} else {
+		CORBA_exception_init (&ev);
+		GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "autosaved", &ev);
+		CORBA_exception_free (&ev);
+
+		composer->has_changed_autosave = FALSE;
 	}
 	
 	camel_object_unref (stream);
@@ -1915,14 +1930,19 @@ menu_changed_charset_cb (BonoboUICompone
 			 const char                  *state,
 			 gpointer                     user_data)
 {
+	EMsgComposer *composer = E_MSG_COMPOSER (user_data);
+
 	if (type != Bonobo_UIComponent_STATE_CHANGED)
 		return;
 	
 	if (atoi (state)) {
 		/* Charset menu names are "Charset-%s" where %s is the charset name */
-		g_free (E_MSG_COMPOSER (user_data)->charset);
-		E_MSG_COMPOSER (user_data)->charset = g_strdup (path + strlen ("Charset-"));
+		g_free (composer->charset);
+		composer->charset = g_strdup (path + strlen ("Charset-"));
 	}
+	
+	/* Mark the composer as changed so it prompts about unsaved changes on close */
+	e_msg_composer_set_changed (composer);
 }
 
 
@@ -2239,6 +2259,9 @@ subject_changed_cb (EMsgComposerHdrs *hd
 	composer = E_MSG_COMPOSER (data);
 	
 	gtk_window_set_title (GTK_WINDOW (composer), subject[0] ? subject : _("Compose a message"));
+	
+	/* Mark the composer as changed so it prompts about unsaved changes on close */
+	e_msg_composer_set_changed (composer);
 }
 
 static void
@@ -2381,6 +2404,9 @@ from_changed_cb (EMsgComposerHdrs *hdrs,
 	
 	set_editor_signature (composer);
 	e_msg_composer_show_sig_file (composer);
+	
+	/* Mark the composer as changed so it prompts about unsaved changes on close */
+	e_msg_composer_set_changed (composer);
 }
 
 
@@ -2689,6 +2715,7 @@ init (EMsgComposer *composer)
 	composer->smime_encrypt            = FALSE;
 	
 	composer->has_changed              = FALSE;
+	composer->has_changed_autosave     = TRUE;
 	
 	composer->redirect                 = FALSE;
 	
@@ -4865,6 +4892,7 @@ e_msg_composer_set_changed (EMsgComposer
 	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 	
 	composer->has_changed = TRUE;
+	composer->has_changed_autosave = TRUE;
 }
 
 
Index: composer/e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.83
diff -p -u -r1.83 e-msg-composer.h
--- composer/e-msg-composer.h	20 May 2003 18:26:09 -0000	1.83
+++ composer/e-msg-composer.h	15 Jul 2003 10:32:01 -0000
@@ -94,6 +94,7 @@ struct _EMsgComposer {
 	guint32 view_cc                : 1;
 	guint32 view_subject           : 1;
 	guint32 has_changed            : 1;
+	guint32 has_changed_autosave   : 1;
 	
 	guint32 mode_post              : 1;
 	
