[evolution/wip/webkit-composer: 582/966] Preliminary port of composer to EEditor.



commit bc7c069719667cbad1d3a39e1d79429b09792d78
Author: Dan Vrátil <dvratil redhat com>
Date:   Tue Aug 28 18:18:22 2012 +0200

    Preliminary port of composer to EEditor.

 composer/e-composer-actions.c       |   33 ++--
 composer/e-composer-actions.h       |   86 ++++-----
 composer/e-composer-activity.c      |  191 ++++++++++++++++++
 composer/e-composer-private.c       |  156 ++++++++++-----
 composer/e-msg-composer.c           |  363 +++++++++++++++++++++++++---------
 composer/e-msg-composer.h           |   11 +-
 modules/mail/e-mail-shell-backend.c |    4 +-
 modules/mail/em-composer-prefs.c    |    2 +-
 8 files changed, 626 insertions(+), 220 deletions(-)
---
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index cda2906..2f8d6df 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -82,7 +82,7 @@ action_pgp_encrypt_cb (GtkToggleAction *action,
        EEditor *editor;
        EEditorWidget *editor_widget;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        e_editor_widget_set_changed (editor_widget, TRUE);
 }
@@ -94,7 +94,7 @@ action_pgp_sign_cb (GtkToggleAction *action,
        EEditor *editor;
        EEditorWidget *editor_widget;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        e_editor_widget_set_changed (editor_widget, TRUE);
 }
@@ -153,7 +153,7 @@ action_save_cb (GtkAction *action,
        gint fd;
        GError *error = NULL;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        filename = e_editor_get_filename (editor);
        if (filename == NULL) {
                gtk_action_activate (ACTION (SAVE_AS));
@@ -225,7 +225,7 @@ action_save_as_cb (GtkAction *action,
        if (response != GTK_RESPONSE_OK)
                goto exit;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
        e_editor_set_filename (editor, filename);
        g_free (filename);
@@ -257,7 +257,7 @@ action_smime_encrypt_cb (GtkToggleAction *action,
        EEditor *editor;
        EEditorWidget *editor_widget;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        e_editor_widget_set_changed (editor_widget, TRUE);
 }
@@ -269,7 +269,7 @@ action_smime_sign_cb (GtkToggleAction *action,
        EEditor *editor;
        EEditorWidget *editor_widget;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        e_editor_widget_set_changed (editor_widget, TRUE);
 }
@@ -460,7 +460,7 @@ e_composer_actions_init (EMsgComposer *composer)
 
        g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        ui_manager = e_editor_get_ui_manager (editor);
 
@@ -506,33 +506,24 @@ e_composer_actions_init (EMsgComposer *composer)
                ACTION (SAVE_DRAFT), "short-label", _("Save Draft"), NULL);
 
        g_object_bind_property (
-               editor_widget, "html-mode",
+               editor_widget, "mode",
                ACTION (PICTURE_GALLERY), "sensitive",
                G_BINDING_SYNC_CREATE);
 
+       /* FIXME WEBKIT Make sure this works */
        g_object_bind_property (
                editor_widget, "editable",
-               e_editor_get_action (editor, "edit-menu"), "sensitive",
+               e_editor_get_action (editor, "edit"), "sensitive",
                G_BINDING_SYNC_CREATE);
 
        g_object_bind_property (
                editor_widget, "editable",
-               e_editor_get_action (editor, "format-menu"), "sensitive",
+               e_editor_get_action (editor, "format"), "sensitive",
                G_BINDING_SYNC_CREATE);
 
        g_object_bind_property (
                editor_widget, "editable",
-               e_editor_get_action (editor, "insert-menu"), "sensitive",
-               G_BINDING_SYNC_CREATE);
-
-       g_object_bind_property (
-               editor_widget, "editable",
-               e_editor_get_action (editor, "options-menu"), "sensitive",
-               G_BINDING_SYNC_CREATE);
-
-       g_object_bind_property (
-               editor_widget, "editable",
-               e_editor_get_action (editor, "picture-gallery"), "sensitive",
+               e_editor_get_action (editor, "insert"), "sensitive",
                G_BINDING_SYNC_CREATE);
 
 #if defined (HAVE_NSS)
diff --git a/composer/e-composer-actions.h b/composer/e-composer-actions.h
index 0c49d74..4eef032 100644
--- a/composer/e-composer-actions.h
+++ b/composer/e-composer-actions.h
@@ -17,50 +17,48 @@
 #ifndef E_COMPOSER_ACTIONS_H
 #define E_COMPOSER_ACTIONS_H
 
-#define E_COMPOSER_ACTION(composer, name) \
-       (e_editor_get_action ( \
-               e_msg_composer_get_editor ( \
-               E_MSG_COMPOSER (composer)), (name)))
+#define E_COMPOSER_ACTION(editor, name) \
+       (e_editor_get_action (E_EDITOR (editor), (name)))
 
-#define E_COMPOSER_ACTION_ATTACH(composer) \
-       E_COMPOSER_ACTION ((composer), "attach")
-#define E_COMPOSER_ACTION_CLOSE(composer) \
-       E_COMPOSER_ACTION ((composer), "close")
-#define E_COMPOSER_ACTION_PGP_ENCRYPT(composer) \
-       E_COMPOSER_ACTION ((composer), "pgp-encrypt")
-#define E_COMPOSER_ACTION_PGP_SIGN(composer) \
-       E_COMPOSER_ACTION ((composer), "pgp-sign")
-#define E_COMPOSER_ACTION_PICTURE_GALLERY(composer) \
-       E_COMPOSER_ACTION ((composer), "picture-gallery")
-#define E_COMPOSER_ACTION_PRINT(composer) \
-       E_COMPOSER_ACTION ((composer), "print")
-#define E_COMPOSER_ACTION_PRINT_PREVIEW(composer) \
-       E_COMPOSER_ACTION ((composer), "print-preview")
-#define E_COMPOSER_ACTION_PRIORITIZE_MESSAGE(composer) \
-       E_COMPOSER_ACTION ((composer), "prioritize-message")
-#define E_COMPOSER_ACTION_REQUEST_READ_RECEIPT(composer) \
-       E_COMPOSER_ACTION ((composer), "request-read-receipt")
-#define E_COMPOSER_ACTION_SAVE(composer) \
-       E_COMPOSER_ACTION ((composer), "save")
-#define E_COMPOSER_ACTION_SAVE_AS(composer) \
-       E_COMPOSER_ACTION ((composer), "save-as")
-#define E_COMPOSER_ACTION_SAVE_DRAFT(composer) \
-       E_COMPOSER_ACTION ((composer), "save-draft")
-#define E_COMPOSER_ACTION_SECURITY_MENU(composer) \
-       E_COMPOSER_ACTION ((composer), "security-menu")
-#define E_COMPOSER_ACTION_SEND(composer) \
-       E_COMPOSER_ACTION ((composer), "send")
-#define E_COMPOSER_ACTION_NEW_MESSAGE(composer) \
-       E_COMPOSER_ACTION ((composer), "new-message")
-#define E_COMPOSER_ACTION_SMIME_ENCRYPT(composer) \
-       E_COMPOSER_ACTION ((composer), "smime-encrypt")
-#define E_COMPOSER_ACTION_SMIME_SIGN(composer) \
-       E_COMPOSER_ACTION ((composer), "smime-sign")
-#define E_COMPOSER_ACTION_VIEW_BCC(composer) \
-       E_COMPOSER_ACTION ((composer), "view-bcc")
-#define E_COMPOSER_ACTION_VIEW_CC(composer) \
-       E_COMPOSER_ACTION ((composer), "view-cc")
-#define E_COMPOSER_ACTION_VIEW_REPLY_TO(composer) \
-       E_COMPOSER_ACTION ((composer), "view-reply-to")
+#define E_COMPOSER_ACTION_ATTACH(editor) \
+       E_COMPOSER_ACTION ((editor), "attach")
+#define E_COMPOSER_ACTION_CLOSE(editor) \
+       E_COMPOSER_ACTION ((editor), "close")
+#define E_COMPOSER_ACTION_PGP_ENCRYPT(editor) \
+       E_COMPOSER_ACTION ((editor), "pgp-encrypt")
+#define E_COMPOSER_ACTION_PGP_SIGN(editor) \
+       E_COMPOSER_ACTION ((editor), "pgp-sign")
+#define E_COMPOSER_ACTION_PICTURE_GALLERY(editor) \
+       E_COMPOSER_ACTION ((editor), "picture-gallery")
+#define E_COMPOSER_ACTION_PRINT(editor) \
+       E_COMPOSER_ACTION ((editor), "print")
+#define E_COMPOSER_ACTION_PRINT_PREVIEW(editor) \
+       E_COMPOSER_ACTION ((editor), "print-preview")
+#define E_COMPOSER_ACTION_PRIORITIZE_MESSAGE(editor) \
+       E_COMPOSER_ACTION ((editor), "prioritize-message")
+#define E_COMPOSER_ACTION_REQUEST_READ_RECEIPT(editor) \
+       E_COMPOSER_ACTION ((editor), "request-read-receipt")
+#define E_COMPOSER_ACTION_SAVE(editor) \
+       E_COMPOSER_ACTION ((editor), "save")
+#define E_COMPOSER_ACTION_SAVE_AS(editor) \
+       E_COMPOSER_ACTION ((editor), "save-as")
+#define E_COMPOSER_ACTION_SAVE_DRAFT(editor) \
+       E_COMPOSER_ACTION ((editor), "save-draft")
+#define E_COMPOSER_ACTION_SECURITY_MENU(editor) \
+       E_COMPOSER_ACTION ((editor), "security-menu")
+#define E_COMPOSER_ACTION_SEND(editor) \
+       E_COMPOSER_ACTION ((editor), "send")
+#define E_COMPOSER_ACTION_NEW_MESSAGE(editor) \
+       E_COMPOSER_ACTION ((editor), "new-message")
+#define E_COMPOSER_ACTION_SMIME_ENCRYPT(editor) \
+       E_COMPOSER_ACTION ((editor), "smime-encrypt")
+#define E_COMPOSER_ACTION_SMIME_SIGN(editor) \
+       E_COMPOSER_ACTION ((editor), "smime-sign")
+#define E_COMPOSER_ACTION_VIEW_BCC(editor) \
+       E_COMPOSER_ACTION ((editor), "view-bcc")
+#define E_COMPOSER_ACTION_VIEW_CC(editor) \
+       E_COMPOSER_ACTION ((editor), "view-cc")
+#define E_COMPOSER_ACTION_VIEW_REPLY_TO(editor) \
+       E_COMPOSER_ACTION ((editor), "view-reply-to")
 
 #endif /* E_COMPOSER_ACTIONS_H */
diff --git a/composer/e-composer-activity.c b/composer/e-composer-activity.c
new file mode 100644
index 0000000..98ca646
--- /dev/null
+++ b/composer/e-composer-activity.c
@@ -0,0 +1,191 @@
+/*
+ * e-composer-activity.c
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-composer-private.h"
+
+#define E_COMPOSER_ACTIVITY_GET_PRIVATE(obj) \
+       (G_TYPE_INSTANCE_GET_PRIVATE \
+       ((obj), E_TYPE_COMPOSER_ACTIVITY, EComposerActivityPrivate))
+
+struct _EComposerActivityPrivate {
+       EMsgComposer *composer;
+       gboolean saved_editable;
+};
+
+enum {
+       PROP_0,
+       PROP_COMPOSER
+};
+
+G_DEFINE_TYPE (
+       EComposerActivity,
+       e_composer_activity,
+       E_TYPE_ACTIVITY)
+
+static void
+composer_activity_lock_interface (EComposerActivity *activity)
+{
+       GtkActionGroup *action_group;
+       EMsgComposer *composer;
+       EEditor *editor;
+       EEditorWidget *editor_widget;
+       gboolean editable;
+
+       composer = e_composer_activity_get_composer (activity);
+
+       editor = e_msg_composer_get_editor (composer);
+       editor_widget = e_editor_get_editor_widget (editor);
+       editable = webkit_web_view_get_editable (WEBKIT_WEB_VIEW (editor_widget));
+       webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), FALSE);
+       activity->priv->saved_editable = editable;
+
+       action_group = composer->priv->async_actions;
+       gtk_action_group_set_sensitive (action_group, FALSE);
+}
+
+static void
+composer_activity_unlock_interface (EComposerActivity *activity)
+{
+       GtkActionGroup *action_group;
+       EMsgComposer *composer;
+       EEditor *editor;
+       EEditorWidget *editor_widget;
+       gboolean editable;
+
+       composer = e_composer_activity_get_composer (activity);
+
+       editable = activity->priv->saved_editable;
+       editor = e_msg_composer_get_editor (composer);
+       editor_widget = e_editor_get_editor_widget (editor);
+       webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), editable);
+
+       action_group = composer->priv->async_actions;
+       gtk_action_group_set_sensitive (action_group, TRUE);
+}
+
+static void
+composer_activity_set_composer (EComposerActivity *activity,
+                                EMsgComposer *composer)
+{
+       g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+       g_return_if_fail (activity->priv->composer == NULL);
+
+       activity->priv->composer = g_object_ref (composer);
+
+       composer_activity_lock_interface (activity);
+}
+
+static void
+composer_activity_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+       switch (property_id) {
+               case PROP_COMPOSER:
+                       composer_activity_set_composer (
+                               E_COMPOSER_ACTIVITY (object),
+                               g_value_get_object (value));
+                       return;
+       }
+
+       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+composer_activity_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec)
+{
+       switch (property_id) {
+               case PROP_COMPOSER:
+                       g_value_set_object (
+                               value, e_composer_activity_get_composer (
+                               E_COMPOSER_ACTIVITY (object)));
+                       return;
+       }
+
+       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+composer_activity_dispose (GObject *object)
+{
+       EComposerActivity *activity;
+
+       activity = E_COMPOSER_ACTIVITY (object);
+
+       if (activity->priv->composer != NULL) {
+               composer_activity_unlock_interface (activity);
+               g_object_unref (activity->priv->composer);
+               activity->priv->composer = NULL;
+       }
+
+       /* Chain up to parent's dispose() method. */
+       G_OBJECT_CLASS (e_composer_activity_parent_class)->dispose (object);
+}
+
+static void
+e_composer_activity_class_init (EComposerActivityClass *class)
+{
+       GObjectClass *object_class;
+
+       g_type_class_add_private (class, sizeof (EComposerActivityPrivate));
+
+       object_class = G_OBJECT_CLASS (class);
+       object_class->set_property = composer_activity_set_property;
+       object_class->get_property = composer_activity_get_property;
+       object_class->dispose = composer_activity_dispose;
+
+       g_object_class_install_property (
+               object_class,
+               PROP_COMPOSER,
+               g_param_spec_object (
+                       "composer",
+                       NULL,
+                       NULL,
+                       E_TYPE_MSG_COMPOSER,
+                       G_PARAM_READWRITE |
+                       G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+e_composer_activity_init (EComposerActivity *activity)
+{
+       activity->priv = E_COMPOSER_ACTIVITY_GET_PRIVATE (activity);
+}
+
+EActivity *
+e_composer_activity_new (EMsgComposer *composer)
+{
+       return g_object_new (
+               E_TYPE_COMPOSER_ACTIVITY,
+               "composer", composer, NULL);
+}
+
+EMsgComposer *
+e_composer_activity_get_composer (EComposerActivity *activity)
+{
+       g_return_val_if_fail (E_IS_COMPOSER_ACTIVITY (activity), NULL);
+
+       return activity->priv->composer;
+}
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 16ee22f..44ee0e7 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -32,13 +32,13 @@
 static void
 composer_setup_charset_menu (EMsgComposer *composer)
 {
-       EEditor *editor;
+       EEditor *editor;
        GtkUIManager *ui_manager;
        const gchar *path;
        GList *list;
        guint merge_id;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        ui_manager = e_editor_get_ui_manager (editor);
        path = "/main-menu/options-menu/charset-menu";
        merge_id = gtk_ui_manager_new_merge_id (ui_manager);
@@ -61,6 +61,50 @@ composer_setup_charset_menu (EMsgComposer *composer)
        gtk_ui_manager_ensure_update (ui_manager);
 }
 
+/* FIXME WEBKIT We don't need to control this anymore....
+static void
+msg_composer_url_requested_cb (GtkHTML *html,
+                               const gchar *uri,
+                               GtkHTMLStream *stream,
+                               EMsgComposer *composer)
+{
+       GByteArray *array;
+       GHashTable *hash_table;
+       CamelDataWrapper *wrapper;
+       CamelStream *camel_stream;
+       CamelMimePart *mime_part;
+
+       hash_table = composer->priv->inline_images_by_url;
+       mime_part = g_hash_table_lookup (hash_table, uri);
+
+       if (mime_part == NULL) {
+               hash_table = composer->priv->inline_images;
+               mime_part = g_hash_table_lookup (hash_table, uri);
+       }
+
+       // If this is not an inline image request,
+       // allow the signal emission to continue. 
+       if (mime_part == NULL)
+               return;
+
+       array = g_byte_array_new ();
+       camel_stream = camel_stream_mem_new_with_byte_array (array);
+       wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
+       camel_data_wrapper_decode_to_stream_sync (
+               wrapper, camel_stream, NULL, NULL);
+
+       gtk_html_write (html, stream, (gchar *) array->data, array->len);
+
+       gtk_html_end (html, stream, GTK_HTML_STREAM_OK);
+
+       g_object_unref (camel_stream);
+
+       // gtk_html_end() destroys the GtkHTMLStream, so we need to
+       // stop the signal emission so nothing else tries to use it.
+       g_signal_stop_emission_by_name (html, "url-requested");
+}
+*/
+
 static void
 composer_update_gallery_visibility (EMsgComposer *composer)
 {
@@ -68,16 +112,16 @@ composer_update_gallery_visibility (EMsgComposer *composer)
        EEditorWidget *editor_widget;
        GtkToggleAction *toggle_action;
        gboolean gallery_active;
-       gboolean is_html;
+       EEditorWidgetMode mode;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
-       is_html = e_editor_widget_get_html_mode (editor_widget);
+       mode = e_editor_widget_get_mode (editor_widget);
 
        toggle_action = GTK_TOGGLE_ACTION (ACTION (PICTURE_GALLERY));
        gallery_active = gtk_toggle_action_get_active (toggle_action);
 
-       if (is_html && gallery_active) {
+       if ((mode == E_EDITOR_WIDGET_MODE_HTML) && gallery_active) {
                gtk_widget_show (composer->priv->gallery_scrolled_window);
                gtk_widget_show (composer->priv->gallery_icon_view);
        } else {
@@ -108,7 +152,7 @@ e_composer_private_constructed (EMsgComposer *composer)
        gint ii;
        GError *error = NULL;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        ui_manager = e_editor_get_ui_manager (editor);
        editor_widget = e_editor_get_editor_widget (editor);
 
@@ -172,9 +216,8 @@ e_composer_private_constructed (EMsgComposer *composer)
 
        priv->focus_tracker = focus_tracker;
 
-       widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-       gtk_container_add (GTK_CONTAINER (composer), widget);
-       gtk_widget_show (widget);
+       container = gtk_hbox_new (FALSE, 0);
+       e_editor_window_pack_above (E_EDITOR_WINDOW (composer), container);
 
        container = widget;
 
@@ -225,7 +268,7 @@ e_composer_private_constructed (EMsgComposer *composer)
 
        g_object_bind_property (
                editor_widget, "editable",
-               widget, "sensitive",
+               widget, "editable",
                G_BINDING_SYNC_CREATE);
 
        container = e_attachment_paned_get_content_area (
@@ -248,13 +291,6 @@ e_composer_private_constructed (EMsgComposer *composer)
        priv->gallery_scrolled_window = g_object_ref (widget);
        gtk_widget_show (widget);
 
-       /* Reparent the scrolled window containing the web view
-        * widget into the content area of the top attachment pane. */
-
-       widget = GTK_WIDGET (editor_widget);
-       widget = gtk_widget_get_parent (widget);
-       gtk_widget_reparent (widget, container);
-
        /* Construct the picture gallery. */
 
        container = priv->gallery_scrolled_window;
@@ -275,8 +311,10 @@ e_composer_private_constructed (EMsgComposer *composer)
                ACTION (PICTURE_GALLERY), "toggled",
                G_CALLBACK (composer_update_gallery_visibility), composer);
 
-       /* Initial sync */
-       composer_update_gallery_visibility (composer);
+       /* XXX What is this for? */
+       /* FIXME WEBKIT Yes, what is this for?
+       g_object_set_data (G_OBJECT (composer), "vbox", editor->vbox);
+       */
 
        /* Bind headers to their corresponding actions. */
 
@@ -322,11 +360,19 @@ e_composer_private_constructed (EMsgComposer *composer)
         * asynchronous activity is in progress.  We enforce this with
         * a simple inverted binding to EEditor's "busy" property. */
 
-       g_object_bind_property (
-               editor, "busy",
-               priv->async_actions, "sensitive",
-               G_BINDING_SYNC_CREATE |
-               G_BINDING_INVERT_BOOLEAN);
+       /* XXX We no longer use GtkhtmlEditor::uri-requested because it
+        *     conflicts with EWebView's url_requested() method, which
+        *     unconditionally launches an async operation.  I changed
+        *     GtkHTML::url-requested to be a G_SIGNAL_RUN_LAST so that
+        *     our handler runs first.  If we can handle the request
+        *     we'll stop the signal emission to prevent EWebView from
+        *     launching an async operation.  Messy, but works until we
+        *     switch to WebKit.  --mbarnes */
+       /* FIXME WEBKIT So...we don't need this anymore, right?
+       g_signal_connect (
+               web_view, "url-requested",
+               G_CALLBACK (msg_composer_url_requested_cb), composer);
+       */
 
        g_object_unref (settings);
 }
@@ -480,7 +526,7 @@ e_composer_paste_html (EMsgComposer *composer,
        html = e_clipboard_wait_for_html (clipboard);
        g_return_val_if_fail (html != NULL, FALSE);
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        editor_selection = e_editor_widget_get_selection (editor_widget);
        e_editor_selection_insert_html (editor_selection, html);
@@ -536,9 +582,9 @@ e_composer_paste_image (EMsgComposer *composer,
 
        /* In HTML mode, paste the image into the message body.
         * In text mode, add the image to the attachment store. */
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
-       if (e_editor_widget_get_html_mode (editor_widget)) {
+       if (e_editor_widget_get_mode (editor_widget) == E_EDITOR_WIDGET_MODE_HTML) {
                EEditorSelection *selection;
 
                selection = e_editor_widget_get_selection (editor_widget);
@@ -584,13 +630,11 @@ e_composer_paste_text (EMsgComposer *composer,
        text = gtk_clipboard_wait_for_text (clipboard);
        g_return_val_if_fail (text != NULL, FALSE);
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        editor_selection = e_editor_widget_get_selection (editor_widget);
        e_editor_selection_insert_text (editor_selection, text);
 
-       e_editor_widget_check_magic_links (editor_widget, FALSE);
-
        g_free (text);
 
        return TRUE;
@@ -973,6 +1017,8 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
                             GAsyncResult *result,
                             EMsgComposer *composer)
 {
+       /* FIXME WEBKIT Uuuhm, yeah...we don't support signatures yet */
+#if 0
        GString *html_buffer = NULL;
        gchar *contents = NULL;
        gsize length = 0;
@@ -991,15 +1037,15 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
        e_mail_signature_combo_box_load_selected_finish (
                combo_box, result, &contents, &length, &is_html, &error);
 
-       /* FIXME Use an EAlert here. */
+       // FIXME Use an EAlert here.
        if (error != NULL) {
                g_warning ("%s: %s", G_STRFUNC, error->message);
                g_error_free (error);
                goto exit;
        }
 
-       /* "Edit as New Message" sets "priv->is_from_message".
-        * Always put the signature at the bottom for that case. */
+       // "Edit as New Message" sets "priv->is_from_message".
+       //Always put the signature at the bottom for that case. 
        top_signature =
                use_top_signature (composer) &&
                !composer->priv->is_from_message &&
@@ -1028,7 +1074,7 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
 
        html_buffer = g_string_sized_new (1024);
 
-       /* The combo box active ID is the signature's ESource UID. */
+       // The combo box active ID is the signature's ESource UID.
        active_id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (combo_box));
 
        g_string_append_printf (
@@ -1039,10 +1085,9 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
        if (!is_html)
                g_string_append (html_buffer, "<PRE>\n");
 
-       /* The signature dash convention ("-- \n") is specified
-        * in the "Son of RFC 1036", section 4.3.2.
-        * http://www.chemie.fu-berlin.de/outerspace/netnews/son-of-1036.html
-        */
+       // The signature dash convention ("-- \n") is specified
+       //in the "Son of RFC 1036", section 4.3.2.
+       //http://www.chemie.fu-berlin.de/outerspace/netnews/son-of-1036.html
        if (add_signature_delimiter (composer)) {
                const gchar *delim;
                const gchar *delim_nl;
@@ -1055,11 +1100,11 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
                        delim_nl = "\n-- \n";
                }
 
-               /* Skip the delimiter if the signature already has one. */
+               // Skip the delimiter if the signature already has one.
                if (g_ascii_strncasecmp (contents, delim, strlen (delim)) == 0)
-                       ;  /* skip */
+                       ;  // skip
                else if (e_util_strstrcase (contents, delim_nl) != NULL)
-                       ;  /* skip */
+                       ;  // skip
                else
                        g_string_append (html_buffer, delim);
        }
@@ -1073,7 +1118,7 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
        g_free (contents);
 
 insert:
-       /* Remove the old signature and insert the new one. */
+       // Remove the old signature and insert the new one.
 
        editor = e_msg_composer_get_editor (composer);
        editor_widget = e_editor_get_editor_widget (editor);
@@ -1100,10 +1145,9 @@ insert:
                        composer->priv->set_signature_from_message = FALSE;
                }
 
-               if (id && (strlen (id) == 1) && (*id == '1')) {
-                       /* We have to remove the div containing the span with signature */
-                       WebKitDOMNode *next_sibling;
-                       WebKitDOMNode *parent;
+       // This prevents our command before/after callbacks from
+          screwing around with the signature as we insert it.
+       composer->priv->in_signature_insert = TRUE;
 
                        parent = webkit_dom_node_get_parent_node (node);
                        next_sibling = webkit_dom_node_get_next_sibling (parent);
@@ -1171,12 +1215,18 @@ insert:
                }
 
                g_string_free (html_buffer, TRUE);
+
+       } else if (top_signature) {
+               // Insert paragraph after the signature ClueFlow stuff. 
+               if (gtkhtml_editor_run_command (editor, "cursor-forward"))
+                       gtkhtml_editor_run_command (editor, "insert-paragraph");
        }
 
        composer_move_caret (composer);
 
 exit:
        g_object_unref (composer);
+#endif
 }
 
 static void
@@ -1202,6 +1252,7 @@ composer_web_view_load_status_changed_cb (WebKitWebView *webkit_web_view,
 void
 e_composer_update_signature (EMsgComposer *composer)
 {
+       /* FIXME WEBKIT As said above...no signatures yet
        EComposerHeaderTable *table;
        EMailSignatureComboBox *combo_box;
        EEditor *editor;
@@ -1210,7 +1261,7 @@ e_composer_update_signature (EMsgComposer *composer)
 
        g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 
-       /* Do nothing if we're redirecting a message. */
+       // Do nothing if we're redirecting a message.
        if (composer->priv->redirect)
                return;
 
@@ -1232,13 +1283,14 @@ e_composer_update_signature (EMsgComposer *composer)
                return;
        }
 
-       /* XXX Signature files should be local and therefore load quickly,
-        *     so while we do load them asynchronously we don't allow for
-        *     user cancellation and we keep the composer alive until the
-        *     asynchronous loading is complete. */
+       //XXX Signature files should be local and therefore load quickly,
+       //      so while we do load them asynchronously we don't allow for
+       //      user cancellation and we keep the composer alive until the
+       //      asynchronous loading is complete.
        e_mail_signature_combo_box_load_selected (
                combo_box, G_PRIORITY_DEFAULT, NULL,
                (GAsyncReadyCallback) composer_load_signature_cb,
                g_object_ref (composer));
+       */
 }
 
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 028d994..5ecb3ce 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -43,6 +43,8 @@
 #include <em-format/e-mail-parser.h>
 #include <em-format/e-mail-formatter-quote.h>
 
+#include <e-util/e-spell-checker.h>
+
 #include <shell/e-shell.h>
 
 typedef struct _AsyncContext AsyncContext;
@@ -153,7 +155,9 @@ static void handle_multipart_signed         (EMsgComposer *composer,
 G_DEFINE_TYPE_WITH_CODE (
        EMsgComposer,
        e_msg_composer,
-       GTK_TYPE_WINDOW,
+       E_TYPE_EDITOR_WINDOW,
+       G_IMPLEMENT_INTERFACE (
+               E_TYPE_ALERT_SINK, e_msg_composer_alert_sink_init)
        G_IMPLEMENT_INTERFACE (E_TYPE_EXTENSIBLE, NULL))
 
 static void
@@ -1267,7 +1271,7 @@ composer_build_message (EMsgComposer *composer,
                EEditor *editor;
                EEditorWidget *editor_widget;
 
-               editor = e_msg_composer_get_editor (composer);
+               editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
                editor_widget = e_editor_get_editor_widget (editor);
                data = g_byte_array_new ();
                text = e_editor_widget_get_text_plain (editor_widget);
@@ -1339,12 +1343,16 @@ composer_build_message (EMsgComposer *composer,
                gboolean pre_encode;
                EEditor *editor;
                EEditorWidget *editor_widget;
-               GList *inline_images;
 
-               editor = e_msg_composer_get_editor (composer);
-               editor_widget = e_editor_get_editor_widget (editor);
-               inline_images = e_editor_widget_get_parts_for_inline_images (editor_widget);
+               clear_current_images (composer);
+
+               /* FIXME WEBKIT Can this go away?
+               if (flags & COMPOSER_FLAG_SAVE_OBJECT_DATA)
+                       gtkhtml_editor_run_command (editor, "save-data-on");
+               */
 
+               editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
+               editor_widget = e_editor_get_editor_widget (editor);
                data = g_byte_array_new ();
                text = e_editor_widget_get_text_html (editor_widget);
                length = strlen (text);
@@ -1352,6 +1360,11 @@ composer_build_message (EMsgComposer *composer,
                pre_encode = text_requires_quoted_printable (text, length);
                g_free (text);
 
+               /* FIXME WEBKIT And this as well?
+               if (flags & COMPOSER_FLAG_SAVE_OBJECT_DATA)
+                       gtkhtml_editor_run_command (editor, "save-data-off");
+               */
+
                mem_stream = camel_stream_mem_new_with_byte_array (data);
                stream = camel_stream_filter_new (mem_stream);
                g_object_unref (mem_stream);
@@ -1548,6 +1561,7 @@ set_editor_text (EMsgComposer *composer,
                  const gchar *text,
                  gboolean set_signature)
 {
+       gchar *body = NULL;
        EEditor *editor;
        EEditorWidget *editor_widget;
 
@@ -1584,6 +1598,10 @@ set_editor_text (EMsgComposer *composer,
                e_editor_widget_set_text_html (editor_widget, text);
        }
 
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
+       editor_widget = e_editor_get_editor_widget (editor);
+       e_editor_widget_set_text_html (editor_widget, body);
+
        if (set_signature)
                e_composer_update_signature (composer);
 
@@ -1599,11 +1617,9 @@ attachment_store_changed_cb (EMsgComposer *composer)
 
        /* Mark the editor as changed so it prompts about unsaved
         * changes on close. */
-       editor = e_msg_composer_get_editor (composer);
-       if (editor) {
-               editor_widget = e_editor_get_editor_widget (editor);
-               e_editor_widget_set_changed (editor_widget, TRUE);
-       }
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
+       editor_widget = e_editor_get_editor_widget (editor);
+       e_editor_widget_set_changed (editor_widget, TRUE);
 }
 
 static void
@@ -1700,9 +1716,11 @@ msg_composer_paste_clipboard_targets_cb (GtkClipboard *clipboard,
 {
        EEditor *editor;
        EEditorWidget *editor_widget;
+       EEditorWidgetMode mode;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
+       mode = e_editor_widget_get_mode (editor_widget);
 
        /* Order is important here to ensure common use cases are
         * handled correctly.  See GNOME bug #603715 for details. */
@@ -1713,7 +1731,7 @@ msg_composer_paste_clipboard_targets_cb (GtkClipboard *clipboard,
        }
 
        /* Only paste HTML content in HTML mode. */
-       if (e_editor_widget_get_html_mode (editor_widget)) {
+       if (mode == E_EDITOR_WIDGET_MODE_HTML) {
                if (e_targets_include_html (targets, n_targets)) {
                        e_composer_paste_html (composer, clipboard);
                        return;
@@ -1746,6 +1764,39 @@ msg_composer_paste_clipboard_cb (EEditorWidget *web_view,
        g_signal_stop_emission_by_name (web_view, "paste-clipboard");
 }
 
+/* FIXME WEBKIT Is this still valid problem? */
+static void
+msg_composer_realize_gtkhtml_cb (GtkWidget *widget,
+                                 EMsgComposer *composer)
+{
+       EAttachmentView *view;
+       GtkTargetList *target_list;
+       GtkTargetEntry *targets;
+       gint n_targets;
+
+       /* XXX GtkHTML doesn't set itself up as a drag destination until
+        *     it's realized, and we need to amend to its target list so
+        *     it will accept the same drag targets as the attachment bar.
+        *     Do this any earlier and GtkHTML will just overwrite us. */
+
+       /* When redirecting a message, the message body is not
+        * editable and therefore cannot be a drag destination. */
+       /*
+       if (!e_web_view_gtkhtml_get_editable (E_WEB_VIEW_GTKHTML (widget)))
+               return;
+       */
+
+       view = e_msg_composer_get_attachment_view (composer);
+
+       target_list = e_attachment_view_get_target_list (view);
+       targets = gtk_target_table_new_from_list (target_list, &n_targets);
+
+       target_list = gtk_drag_dest_get_target_list (widget);
+       gtk_target_list_add_table (target_list, targets, n_targets);
+
+       gtk_target_table_free (targets, n_targets);
+}
+
 static gboolean
 msg_composer_drag_motion_cb (GtkWidget *widget,
                              GdkDragContext *context,
@@ -1802,11 +1853,14 @@ msg_composer_drag_data_received_cb (GtkWidget *widget,
        EAttachmentView *view;
        EEditor *editor;
        EEditorWidget *editor_widget;
-       EEditorSelection *editor_selection;
+       EEditorWidgetMode mode;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
-       editor_selection = e_editor_widget_get_selection (editor_widget);
+       mode = e_editor_widget_get_mode (editor_widget);
+
+       /* HTML mode has a few special cases for drops... */
+       if (mode == E_EDITOR_WIDGET_MODE_HTML) {
 
        /* HTML mode has a few special cases for drops... */
        if (e_editor_widget_get_html_mode (editor_widget)) {
@@ -1878,9 +1932,9 @@ msg_composer_notify_header_cb (EMsgComposer *composer)
        EEditor *editor;
        EEditorWidget *editor_widget;
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
-       e_editor_widget_set_changed (editor_widget, TRUE);
+       e_editor_widget_set_changed(editor_widget, TRUE);
 }
 
 static gboolean
@@ -2061,7 +2115,7 @@ msg_composer_constructed (GObject *object)
 
        e_composer_private_constructed (composer);
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        ui_manager = e_editor_get_ui_manager (editor);
        view = e_msg_composer_get_attachment_view (composer);
@@ -2111,6 +2165,10 @@ msg_composer_constructed (GObject *object)
        /* Drag-and-Drop Support */
 
        g_signal_connect (
+               editor_widget, "realize",
+               G_CALLBACK (msg_composer_realize_gtkhtml_cb), composer);
+
+       g_signal_connect (
                editor_widget, "drag-motion",
                G_CALLBACK (msg_composer_drag_motion_cb), composer);
 
@@ -2166,12 +2224,6 @@ msg_composer_constructed (GObject *object)
        /* Initialization may have tripped the "changed" state. */
        e_editor_widget_set_changed (editor_widget, FALSE);
 
-       gtk_drag_dest_set (
-               GTK_WIDGET (editor_widget),
-               GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
-               drag_dest_targets, G_N_ELEMENTS (drag_dest_targets),
-               GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
-
        id = "org.gnome.evolution.composer";
        e_plugin_ui_register_manager (ui_manager, id, composer);
        e_plugin_ui_enable_manager (ui_manager, id);
@@ -2245,6 +2297,7 @@ msg_composer_map (GtkWidget *widget)
        }
 
        /* Jump to the editor as a last resort. */
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (widget));
        editor_widget = e_editor_get_editor_widget (editor);
        gtk_widget_grab_focus (GTK_WIDGET (editor_widget));
 }
@@ -2259,7 +2312,7 @@ msg_composer_key_press_event (GtkWidget *widget,
        EEditorWidget *editor_widget;
 
        composer = E_MSG_COMPOSER (widget);
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
 
        input_widget =
@@ -2299,9 +2352,36 @@ msg_composer_key_press_event (GtkWidget *widget,
  * when inserting signature, right?..or when is this usefull ?? */
 #if 0  /* WEBKIT-COMPOSER */
 static void
+msg_composer_cut_clipboard (EMsgComposer *composer)
+{
+       /* Do nothing.  EFocusTracker handles this. */
+}
+
+static void
+msg_composer_copy_clipboard (EMsgComposer *composer)
+{
+       /* Do nothing.  EFocusTracker handles this. */
+}
+
+static void
+msg_composer_paste_clipboard (EMsgComposer *composer)
+{
+       /* Do nothing.  EFocusTracker handles this. */
+}
+
+static void
+msg_composer_select_all (EMsgComposer *composer)
+{
+       /* Do nothing.  EFocusTracker handles this. */
+}
+
+/* FIXME WEBKIT We can effectively hack around this by DOM manipulation
+ * when inserting signature, right?..or when is this usefull ?? */
+static void
 msg_composer_command_before (EMsgComposer *composer,
                              const gchar *command)
 {
+       /*
        EMsgComposer *composer;
        const gchar *data;
 
@@ -2325,12 +2405,14 @@ msg_composer_command_before (EMsgComposer *composer,
                gtkhtml_editor_run_command (editor, "text-default-color");
                gtkhtml_editor_run_command (editor, "italic-off");
        }
+       */
 }
 
 static void
 msg_composer_command_after (EMsgComposer *composer,
                             const gchar *command)
 {
+       /*
        EMsgComposer *composer;
        const gchar *data;
 
@@ -2353,7 +2435,7 @@ msg_composer_command_after (EMsgComposer *composer,
        if (data == NULL || *data != '1')
                return;
 
-       /* Clear the signature. */
+       // Clear the signature.
        if (gtkhtml_editor_is_paragraph_empty (editor))
                gtkhtml_editor_set_paragraph_data (editor, "signature" ,"0");
 
@@ -2366,8 +2448,68 @@ msg_composer_command_after (EMsgComposer *composer,
 
        gtkhtml_editor_run_command (editor, "text-default-color");
        gtkhtml_editor_run_command (editor, "italic-off");
+       */
+}
+
+static gchar *
+msg_composer_image_uri (EMsgComposer *composer,
+                        const gchar *uri)
+{
+       GHashTable *hash_table;
+       CamelMimePart *part;
+       const gchar *cid;
+
+       hash_table = composer->priv->inline_images_by_url;
+       part = g_hash_table_lookup (hash_table, uri);
+
+       if (part == NULL && g_str_has_prefix (uri, "file:"))
+               part = e_msg_composer_add_inline_image_from_file (
+                       composer, uri + 5);
+
+       if (part == NULL && g_str_has_prefix (uri, "cid:")) {
+               hash_table = composer->priv->inline_images;
+               part = g_hash_table_lookup (hash_table, uri);
+       }
+
+       if (part == NULL)
+               return NULL;
+
+       composer->priv->current_images =
+               g_list_prepend (composer->priv->current_images, part);
+
+       cid = camel_mime_part_get_content_id (part);
+       if (cid == NULL)
+               return NULL;
+
+       return g_strconcat ("cid:", cid, NULL);
+}
+
+/* FIXME WEBKIT We don't need this, do we? */
+static void
+msg_composer_object_deleted (EMsgComposer *composer)
+{
+       /*
+       const gchar *data;
+
+       if (!gtkhtml_editor_is_paragraph_empty (editor))
+               return;
+
+       data = gtkhtml_editor_get_paragraph_data (editor, "orig");
+       if (data != NULL && *data == '1') {
+               gtkhtml_editor_set_paragraph_data (editor, "orig", "0");
+               gtkhtml_editor_run_command (editor, "indent-zero");
+               gtkhtml_editor_run_command (editor, "style-normal");
+               gtkhtml_editor_run_command (editor, "text-default-color");
+               gtkhtml_editor_run_command (editor, "italic-off");
+               gtkhtml_editor_run_command (editor, "insert-paragraph");
+               gtkhtml_editor_run_command (editor, "delete-back");
+       }
+
+       data = gtkhtml_editor_get_paragraph_data (editor, "signature");
+       if (data != NULL && *data == '1')
+               gtkhtml_editor_set_paragraph_data (editor, "signature", "0");
+       */
 }
-#endif /* WEBKIT-COMPOSER */
 
 static gboolean
 msg_composer_presend (EMsgComposer *composer)
@@ -2392,25 +2534,25 @@ msg_composer_accumulator_false_abort (GSignalInvocationHint *ihint,
 }
 
 static void
-e_msg_composer_class_init (EMsgComposerClass *class)
+e_msg_composer_class_init (EMsgComposerClass *klass)
 {
        GObjectClass *object_class;
        GtkWidgetClass *widget_class;
 
-       g_type_class_add_private (class, sizeof (EMsgComposerPrivate));
+       g_type_class_add_private (klass, sizeof (EMsgComposerPrivate));
 
-       object_class = G_OBJECT_CLASS (class);
+       object_class = G_OBJECT_CLASS (klass);
        object_class->set_property = msg_composer_set_property;
        object_class->get_property = msg_composer_get_property;
        object_class->dispose = msg_composer_dispose;
        object_class->finalize = msg_composer_finalize;
        object_class->constructed = msg_composer_constructed;
 
-       widget_class = GTK_WIDGET_CLASS (class);
+       widget_class = GTK_WIDGET_CLASS (klass);
        widget_class->map = msg_composer_map;
        widget_class->key_press_event = msg_composer_key_press_event;
 
-       class->presend = msg_composer_presend;
+       klass->presend = msg_composer_presend;
 
        g_object_class_install_property (
                object_class,
@@ -2435,7 +2577,7 @@ e_msg_composer_class_init (EMsgComposerClass *class)
 
        signals[PRESEND] = g_signal_new (
                "presend",
-               G_OBJECT_CLASS_TYPE (class),
+               G_OBJECT_CLASS_TYPE (klass),
                G_SIGNAL_RUN_LAST,
                G_STRUCT_OFFSET (EMsgComposerClass, presend),
                msg_composer_accumulator_false_abort,
@@ -2445,7 +2587,7 @@ e_msg_composer_class_init (EMsgComposerClass *class)
 
        signals[SEND] = g_signal_new (
                "send",
-               G_OBJECT_CLASS_TYPE (class),
+               G_OBJECT_CLASS_TYPE (klass),
                G_SIGNAL_RUN_LAST,
                G_STRUCT_OFFSET (EMsgComposerClass, send),
                NULL, NULL,
@@ -2456,7 +2598,7 @@ e_msg_composer_class_init (EMsgComposerClass *class)
 
        signals[SAVE_TO_DRAFTS] = g_signal_new (
                "save-to-drafts",
-               G_OBJECT_CLASS_TYPE (class),
+               G_OBJECT_CLASS_TYPE (klass),
                G_SIGNAL_RUN_LAST,
                G_STRUCT_OFFSET (EMsgComposerClass, save_to_drafts),
                NULL, NULL,
@@ -2467,7 +2609,7 @@ e_msg_composer_class_init (EMsgComposerClass *class)
 
        signals[SAVE_TO_OUTBOX] = g_signal_new (
                "save-to-outbox",
-               G_OBJECT_CLASS_TYPE (class),
+               G_OBJECT_CLASS_TYPE (klass),
                G_SIGNAL_RUN_LAST,
                G_STRUCT_OFFSET (EMsgComposerClass, save_to_outbox),
                NULL, NULL,
@@ -2478,7 +2620,7 @@ e_msg_composer_class_init (EMsgComposerClass *class)
 
        signals[PRINT] = g_signal_new (
                "print",
-               G_OBJECT_CLASS_TYPE (class),
+               G_OBJECT_CLASS_TYPE (klass),
                G_SIGNAL_RUN_LAST,
                0, NULL, NULL,
                e_marshal_VOID__ENUM_OBJECT_OBJECT,
@@ -2514,22 +2656,6 @@ e_msg_composer_new (EShell *shell)
                "shell", shell, NULL);
 }
 
-/**
- * e_msg_composer_get_editor:
- * @composer: an #EMsgComposer
- *
- * Returns @composer's internal #EEditor instance.
- *
- * Returns: an #EEditor
- **/
-EEditor *
-e_msg_composer_get_editor (EMsgComposer *composer)
-{
-       g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
-
-       return composer->priv->editor;
-}
-
 EFocusTracker *
 e_msg_composer_get_focus_tracker (EMsgComposer *composer)
 {
@@ -3027,10 +3153,8 @@ handle_multipart (EMsgComposer *composer,
 static void
 set_signature_gui (EMsgComposer *composer)
 {
-       EEditor *editor;
-       EEditorWidget *widget;
-       WebKitDOMDocument *document;
-       WebKitDOMNodeList *nodes;
+       /*FIXME WEBKIT We don't support signatures yet....
+       GtkhtmlEditor *editor;
        EComposerHeaderTable *table;
        EMailSignatureComboBox *combo_box;
        gchar *uid;
@@ -3062,11 +3186,11 @@ set_signature_gui (EMsgComposer *composer)
                g_free (id);
        }
 
-       /* The combo box active ID is the signature's ESource UID. */
-       if (uid != NULL) {
-               gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), uid);
-               g_free (uid);
-       }
+       // The combo box active ID is the signature's ESource UID.
+       uid = e_composer_decode_clue_value (data + 4);
+       gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), uid);
+       g_free (uid);
+       */
 }
 
 static void
@@ -3172,6 +3296,7 @@ e_msg_composer_new_with_message (EShell *shell,
        priv = E_MSG_COMPOSER_GET_PRIVATE (composer);
        editor = e_msg_composer_get_editor (composer);
        table = e_msg_composer_get_header_table (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
 
        if (postto) {
@@ -3307,21 +3432,11 @@ e_msg_composer_new_with_message (EShell *shell,
                flags = g_strsplit (format, ", ", 0);
                for (i = 0; flags[i]; i++) {
                        if (g_ascii_strcasecmp (flags[i], "text/html") == 0) {
-                               if (g_ascii_strcasecmp (composer_mode, "text/html") == 0) {
-                                       e_editor_widget_set_html_mode (
-                                               editor_widget, TRUE);
-                               } else {
-                                       e_editor_widget_set_html_mode (
-                                               editor_widget, FALSE);
-                               }
+                               e_editor_widget_set_mode (
+                                       editor_widget, E_EDITOR_WIDGET_MODE_HTML);
                        } else if (g_ascii_strcasecmp (flags[i], "text/plain") == 0) {
-                               if (g_ascii_strcasecmp (composer_mode, "text/html") == 0) {
-                                       e_editor_widget_set_html_mode (
-                                               editor_widget, TRUE);
-                               } else {
-                                       e_editor_widget_set_html_mode (
-                                               editor_widget, FALSE);
-                               }
+                               e_editor_widget_set_mode (
+                                       editor_widget, E_EDITOR_WIDGET_MODE_PLAIN_TEXT);
                        } else if (g_ascii_strcasecmp (flags[i], "pgp-sign") == 0) {
                                action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
                                gtk_toggle_action_set_active (action, TRUE);
@@ -3501,7 +3616,7 @@ e_msg_composer_new_redirect (EShell *shell,
        e_composer_header_table_set_identity_uid (table, identity_uid);
        e_composer_header_table_set_subject (table, subject);
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), FALSE);
 
@@ -3554,6 +3669,22 @@ e_msg_composer_get_shell (EMsgComposer *composer)
        return E_SHELL (composer->priv->shell);
 }
 
+/**
+ * e_msg_composer_get_editor:
+ * @composer: an #EMsgComposer
+ *
+ * Returns the #EEditor widget in @composer.
+ *
+ * Returns: the #EEditor
+ **/
+EEditor *
+e_msg_composer_get_editor (EMsgComposer *composer)
+{
+       g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
+
+       return e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
+}
+
 static void
 msg_composer_send_cb (EMsgComposer *composer,
                       GAsyncResult *result,
@@ -3594,7 +3725,7 @@ msg_composer_send_cb (EMsgComposer *composer,
        g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 
        /* The callback can set editor 'changed' if anything failed. */
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        e_editor_widget_set_changed (editor_widget, TRUE);
 
@@ -3693,7 +3824,7 @@ msg_composer_save_to_drafts_cb (EMsgComposer *composer,
        g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 
        /* The callback can set editor 'changed' if anything failed. */
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        e_editor_widget_set_changed (editor_widget, FALSE);
 
@@ -3782,7 +3913,7 @@ msg_composer_save_to_outbox_cb (EMsgComposer *composer,
 
        async_context_free (context);
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        e_editor_widget_set_changed (editor_widget, FALSE);
 }
@@ -4268,7 +4399,7 @@ e_msg_composer_set_body (EMsgComposer *composer,
 
        g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
        table = e_msg_composer_get_header_table (composer);
 
@@ -4282,7 +4413,7 @@ e_msg_composer_set_body (EMsgComposer *composer,
        set_editor_text (composer, buff, FALSE);
        g_free (buff);
 
-       e_editor_widget_set_html_mode (editor_widget, FALSE);
+       e_editor_widget_set_mode (editor_widget, E_EDITOR_WIDGET_MODE_PLAIN_TEXT);
        webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), FALSE);
 
        g_free (priv->mime_body);
@@ -4547,7 +4678,7 @@ e_msg_composer_get_message (EMsgComposer *composer,
 
        g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
 
        simple = g_simple_async_result_new (
@@ -4556,7 +4687,7 @@ e_msg_composer_get_message (EMsgComposer *composer,
 
        g_simple_async_result_set_check_cancellable (simple, cancellable);
 
-       if (e_editor_widget_get_html_mode (editor_widget))
+       if (e_editor_widget_get_mode (editor_widget) == E_EDITOR_WIDGET_MODE_HTML)
                flags |= COMPOSER_FLAG_HTML_CONTENT;
 
        action = ACTION (PRIORITIZE_MESSAGE);
@@ -4687,13 +4818,10 @@ e_msg_composer_get_message_draft (EMsgComposer *composer,
 
        g_simple_async_result_set_check_cancellable (simple, cancellable);
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
-       /* We need to remember composer mode */
-       if (e_editor_widget_get_html_mode (editor_widget))
-               flags |= COMPOSER_FLAG_HTML_MODE;
-       /* We want to save HTML content everytime when we save as draft */
-       flags |= COMPOSER_FLAG_SAVE_DRAFT;
+       if (e_editor_widget_get_mode (editor_widget) == E_EDITOR_WIDGET_MODE_HTML)
+               flags |= COMPOSER_FLAG_HTML_CONTENT;
 
        action = ACTION (PRIORITIZE_MESSAGE);
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
@@ -4829,7 +4957,7 @@ e_msg_composer_get_raw_message_text (EMsgComposer *composer)
 
        g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
 
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
 
        array = g_byte_array_new ();
@@ -4876,7 +5004,7 @@ e_msg_composer_can_close (EMsgComposer *composer,
        gint response;
 
        widget = GTK_WIDGET (composer);
-       editor = e_msg_composer_get_editor (composer);
+       editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
        editor_widget = e_editor_get_editor_widget (editor);
 
        /* this means that there is an async operation running,
@@ -4923,8 +5051,8 @@ e_msg_composer_can_close (EMsgComposer *composer,
 void
 e_msg_composer_reply_indent (EMsgComposer *composer)
 {
-#if 0  /* FIXME WEBKIT We already have indentation implementation.
-        *              Why is this done? */
+       /* FIXME WEBKIT We already have indentation implementation. Why
+        * is this done? 
        GtkhtmlEditor *editor;
 
        g_return_if_fail (E_IS_MSG_COMPOSER (composer));
@@ -4946,7 +5074,7 @@ e_msg_composer_reply_indent (EMsgComposer *composer)
        gtkhtml_editor_run_command (editor, "indent-zero");
        gtkhtml_editor_run_command (editor, "text-default-color");
        gtkhtml_editor_run_command (editor, "italic-off");
-#endif
+       */
 }
 
 EComposerHeaderTable *
@@ -4965,6 +5093,49 @@ e_msg_composer_get_attachment_view (EMsgComposer *composer)
        return E_ATTACHMENT_VIEW (composer->priv->attachment_paned);
 }
 
+GList *
+e_load_spell_languages (ESpellChecker *spell_checker)
+{
+       GSettings *settings;
+       GList *spell_dicts = NULL;
+       gchar **strv;
+       gint ii;
+
+       /* Ask GSettings for a list of spell check language codes. */
+       settings = g_settings_new ("org.gnome.evolution.mail");
+       strv = g_settings_get_strv (settings, "composer-spell-languages");
+       g_object_unref (settings);
+
+       /* Convert the codes to spell language structs. */
+       for (ii = 0; strv[ii] != NULL; ii++) {
+               gchar *language_code = strv[ii];
+               ESpellDictionary *dict;
+
+               dict = e_spell_checker_lookup_dictionary (spell_checker, language_code);
+               if (dict != NULL)
+                       spell_dicts = g_list_prepend (
+                               spell_dicts, (gpointer) dict);
+       }
+
+       g_strfreev (strv);
+
+       spell_dicts = g_list_reverse (spell_dicts);
+
+       /* Pick a default spell language if it came back empty. */
+       if (spell_dicts == NULL) {
+               ESpellDictionary *dict;
+
+               dict = e_spell_checker_lookup_dictionary (spell_checker, NULL);
+
+               if (dict) {
+                       spell_dicts = g_list_prepend (
+                               spell_dicts, (gpointer) dict);
+               }
+       }
+
+       return spell_dicts;
+}
+
 void
 e_save_spell_languages (const GList *spell_dicts)
 {
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 35864d5..d1b8089 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -56,12 +56,12 @@ typedef struct _EMsgComposerClass EMsgComposerClass;
 typedef struct _EMsgComposerPrivate EMsgComposerPrivate;
 
 struct _EMsgComposer {
-       GtkWindow parent;
+       EEditorWindow parent;
        EMsgComposerPrivate *priv;
 };
 
 struct _EMsgComposerClass {
-       GtkWindowClass parent_class;
+       EEditorWindowClass parent_class;
 
        /* Signals */
        gboolean        (*presend)              (EMsgComposer *composer);
@@ -97,6 +97,8 @@ EFocusTracker *       e_msg_composer_get_focus_tracker
                                                (EMsgComposer *composer);
 CamelSession * e_msg_composer_ref_session      (EMsgComposer *composer);
 EShell *       e_msg_composer_get_shell        (EMsgComposer *composer);
+EEditor *
+               e_msg_composer_get_editor       (EMsgComposer *composer);
 
 void           e_msg_composer_send             (EMsgComposer *composer);
 void           e_msg_composer_save_to_drafts   (EMsgComposer *composer);
@@ -188,10 +190,9 @@ GByteArray *       e_msg_composer_get_raw_message_text
 
 gboolean       e_msg_composer_is_exiting       (EMsgComposer *composer);
 
+GList *                e_load_spell_languages          (ESpellChecker *spell_checker);
 void           e_save_spell_languages          (const GList *spell_languages);
-void           e_msg_composer_is_from_new_message
-                                               (EMsgComposer *composer,
-                                                gboolean is_from_new_message);
+
 G_END_DECLS
 
 #endif /* E_MSG_COMPOSER_H */
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 33b5913..e69c55f 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -492,13 +492,15 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
        if (E_IS_EDITOR_WINDOW (window)) {
                EEditor *editor;
                EEditorWidget *editor_widget;
+               ESpellChecker *spell_checker;
                GSettings *settings;
                gboolean active = TRUE;
 
                editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
                editor_widget = e_editor_get_editor_widget (editor);
 
-               spell_languages = e_load_spell_languages ();
+               spell_checker = e_editor_widget_get_spell_checker (editor_widget);
+               spell_languages = e_load_spell_languages (spell_checker);
 
                e_editor_widget_set_spell_languages (editor_widget, spell_languages);
                g_list_free (spell_languages);
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index 47113ad..1636a68 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -146,7 +146,7 @@ spell_setup (EMComposerPrefs *prefs)
        available_languages =
                e_spell_checker_list_available_dicts (prefs->spell_checker);
 
-       list = e_spell_checker_list_available_dicts (prefs->spell_checker);
+       active_languages = e_load_spell_languages (prefs->spell_checker);
 
        /* Populate the GtkListStore. */
        while (available_languages != NULL) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]