--- composer/e-msg-composer.c.orig	Fri Apr  8 13:37:59 2005
+++ composer/e-msg-composer.c	Mon May 30 23:04:24 2005
@@ -2527,6 +2527,8 @@
 	g_hash_table_destroy (composer->inline_images);
 	g_hash_table_destroy (composer->inline_images_by_url);
 	
+	g_free (composer->editor_oafiid);
+
 	g_free (composer->charset);
 	g_free (composer->mime_type);
 	g_free (composer->mime_body);
@@ -3116,6 +3118,7 @@
 e_msg_composer_load_config (EMsgComposer *composer, int visible_mask)
 {
 	GConfClient *gconf;
+	GError *err = NULL;
 	
 	gconf = gconf_client_get_default ();
 	
@@ -3133,6 +3136,16 @@
 		gconf, "/apps/evolution/mail/composer/view/Bcc", NULL);
 	composer->view_subject = gconf_client_get_bool (
 		gconf, "/apps/evolution/mail/composer/view/Subject", NULL);
+	composer->editor_oafiid = gconf_client_get_string (
+		gconf, "/apps/evolution/mail/composer/editor_oafiid", &err);
+	/* if any error occurs reading the editor key, or if key is empty, fallback to GtkHTML */
+	if (err || composer->editor_oafiid == NULL || !composer->editor_oafiid[0]) {
+        if (composer->editor_oafiid) {
+            g_free (composer->editor_oafiid);
+        }
+		composer->editor_oafiid = g_strdup (GNOME_GTKHTML_EDITOR_CONTROL_ID);
+		g_error_free (err);
+	}
 	
 	/* if we're mailing, you cannot disable to so it should appear checked */
 	if (visible_mask & E_MSG_COMPOSER_VISIBLE_TO)
@@ -3234,7 +3247,7 @@
 static int
 composer_key_pressed (EMsgComposer *composer, GdkEventKey *event, void *user_data)
 {
-	if (event->keyval == GDK_Escape) {
+	if (event->keyval == GDK_Escape && composer->catch_escape) {
 		do_exit (composer);
 		g_signal_stop_emission_by_name (composer, "key-press-event");
 		return TRUE;
@@ -3372,6 +3385,7 @@
 	int vis;
 	GList *icon_list;
 	BonoboControlFrame *control_frame;
+    gboolean editor_needs_escape = FALSE;
 	
 	composer = g_object_new (E_TYPE_MSG_COMPOSER, "win_name", _("Compose a message"), NULL);
 	gtk_window_set_title ((GtkWindow *) composer, _("Compose a message"));
@@ -3427,8 +3441,18 @@
 
 	/* Editor component.  */
 	composer->editor = bonobo_widget_new_control (
-		GNOME_GTKHTML_EDITOR_CONTROL_ID,
+		composer->editor_oafiid,
 		bonobo_ui_component_get_container (composer->uic));
+
+ 	/* if activation of alternate editor failed, try falling back to the GtkHTML editor */
+ 	if (!composer->editor && composer->editor_oafiid && strcmp (GNOME_GTKHTML_EDITOR_CONTROL_ID, composer->editor_oafiid)) {
+ 		composer->editor = bonobo_widget_new_control (
+ 			GNOME_GTKHTML_EDITOR_CONTROL_ID,
+ 			bonobo_ui_component_get_container (composer->uic));
+ 	}
+
+ 	/* if activation still failed, display the error message from the
+ 	 * _original_ activation attempt. */
 	if (!composer->editor) {
 		e_error_run (GTK_WINDOW (composer), "mail-composer:no-editor-control", NULL);
 		gtk_object_destroy (GTK_OBJECT (composer));
@@ -3542,7 +3566,10 @@
 	autosave_manager_register (am, composer);
 
 	composer->has_changed = FALSE;
-	
+
+	bonobo_widget_get_property (BONOBO_WIDGET (composer->editor), "EditorNeedsEscape", TC_CORBA_boolean, &editor_needs_escape, NULL);
+	composer->catch_escape = !editor_needs_escape;
+
 	return composer;
 }
 
--- composer/e-msg-composer.h.orig	Tue Jul 27 11:52:17 2004
+++ composer/e-msg-composer.h	Mon May 30 23:03:13 2005
@@ -74,6 +74,8 @@
 	
 	GtkWidget *address_dialog;
 	
+	char                    *editor_oafiid;
+	gboolean                 catch_escape;
 	Bonobo_PersistFile       persist_file_interface;
 	Bonobo_PersistStream     persist_stream_interface;
 	GNOME_GtkHTML_Editor_Engine  editor_engine;
--- mail/evolution-mail.schemas.in.in.orig	Mon Feb 28 09:15:06 2005
+++ mail/evolution-mail.schemas.in.in	Mon May 30 22:17:02 2005
@@ -74,6 +74,21 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/evolution/mail/composer/editor_oafiid</key>
+      <applyto>/apps/evolution/mail/composer/editor_oafiid</applyto>
+      <owner>evolution-mail</owner>
+      <type>string</type>
+      <default></default>
+      <locale name="C">
+         <short>Activation ID (OAFIID) of editor control.</short>
+         <long>
+          Evolution uses the GtkHTML editor by default.  Change this
+          ID to use an alternate (compatible) editor.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/evolution/mail/composer/view/From</key>
       <applyto>/apps/evolution/mail/composer/view/From</applyto>
       <owner>evolution-mail</owner>

