aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer/e-composer-actions.c21
-rw-r--r--composer/e-composer-activity.c48
-rw-r--r--composer/e-composer-private.c15
-rw-r--r--composer/e-msg-composer.c80
-rw-r--r--composer/e-msg-composer.h2
-rw-r--r--plugins/external-editor/external-editor.c14
6 files changed, 121 insertions, 59 deletions
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index 13fe48495e..b47b60241a 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -401,11 +401,15 @@ e_composer_actions_init (EMsgComposer *composer)
{
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
+ GtkhtmlEditor *editor;
+ EWebView *web_view;
gboolean visible;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
- ui_manager = gtkhtml_editor_get_ui_manager (GTKHTML_EDITOR (composer));
+ editor = GTKHTML_EDITOR (composer);
+ web_view = e_msg_composer_get_web_view (composer);
+ ui_manager = gtkhtml_editor_get_ui_manager (editor);
/* Composer Actions */
action_group = composer->priv->composer_actions;
@@ -445,6 +449,21 @@ e_composer_actions_init (EMsgComposer *composer)
g_object_set (
ACTION (SAVE_DRAFT), "short-label", _("Save Draft"), NULL);
+ g_object_bind_property (
+ web_view, "editable",
+ GTKHTML_EDITOR_ACTION_EDIT_MENU (editor), "sensitive",
+ G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (
+ web_view, "editable",
+ GTKHTML_EDITOR_ACTION_FORMAT_MENU (editor), "sensitive",
+ G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (
+ web_view, "editable",
+ GTKHTML_EDITOR_ACTION_INSERT_MENU (editor), "sensitive",
+ G_BINDING_SYNC_CREATE);
+
#if defined (HAVE_NSS)
visible = TRUE;
#else
diff --git a/composer/e-composer-activity.c b/composer/e-composer-activity.c
index d565bbc1fb..e0e159704c 100644
--- a/composer/e-composer-activity.c
+++ b/composer/e-composer-activity.c
@@ -24,6 +24,7 @@
struct _EComposerActivityPrivate {
EMsgComposer *composer;
+ gboolean saved_editable;
};
enum {
@@ -37,13 +38,40 @@ G_DEFINE_TYPE (
E_TYPE_ACTIVITY)
static void
-composer_activity_set_sensitive (EMsgComposer *composer,
- gboolean sensitive)
+composer_activity_lock_interface (EComposerActivity *activity)
{
GtkActionGroup *action_group;
+ EMsgComposer *composer;
+ EWebView *web_view;
+ gboolean editable;
+
+ composer = e_composer_activity_get_composer (activity);
+
+ web_view = e_msg_composer_get_web_view (composer);
+ editable = e_web_view_get_editable (web_view);
+ e_web_view_set_editable (web_view, 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;
+ EWebView *web_view;
+ gboolean editable;
+
+ composer = e_composer_activity_get_composer (activity);
+
+ editable = activity->priv->saved_editable;
+ web_view = e_msg_composer_get_web_view (composer);
+ e_web_view_set_editable (web_view, editable);
action_group = composer->priv->async_actions;
- gtk_action_group_set_sensitive (action_group, sensitive);
+ gtk_action_group_set_sensitive (action_group, TRUE);
}
static void
@@ -55,7 +83,7 @@ composer_activity_set_composer (EComposerActivity *activity,
activity->priv->composer = g_object_ref (composer);
- composer_activity_set_sensitive (composer, FALSE);
+ composer_activity_lock_interface (activity);
}
static void
@@ -95,14 +123,14 @@ composer_activity_get_property (GObject *object,
static void
composer_activity_dispose (GObject *object)
{
- EComposerActivityPrivate *priv;
+ EComposerActivity *activity;
- priv = E_COMPOSER_ACTIVITY_GET_PRIVATE (object);
+ activity = E_COMPOSER_ACTIVITY (object);
- if (priv->composer != NULL) {
- composer_activity_set_sensitive (priv->composer, TRUE);
- g_object_unref (priv->composer);
- priv->composer = NULL;
+ 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. */
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 99e83ae138..f9840bd929 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -128,8 +128,9 @@ void
e_composer_private_constructed (EMsgComposer *composer)
{
EMsgComposerPrivate *priv = composer->priv;
- EShell *shell;
EFocusTracker *focus_tracker;
+ EShell *shell;
+ EWebView *web_view;
GtkhtmlEditor *editor;
GtkUIManager *ui_manager;
GtkAction *action;
@@ -137,7 +138,6 @@ e_composer_private_constructed (EMsgComposer *composer)
GtkWidget *widget;
GtkWidget *send_widget;
GtkWindow *window;
- GtkHTML *html;
const gchar *path;
gboolean small_screen_mode;
gchar *filename;
@@ -145,10 +145,10 @@ e_composer_private_constructed (EMsgComposer *composer)
GError *error = NULL;
editor = GTKHTML_EDITOR (composer);
- html = gtkhtml_editor_get_html (editor);
ui_manager = gtkhtml_editor_get_ui_manager (editor);
shell = e_msg_composer_get_shell (composer);
+ web_view = e_msg_composer_get_web_view (composer);
small_screen_mode = e_shell_get_small_screen_mode (shell);
if (small_screen_mode) {
@@ -294,6 +294,11 @@ e_composer_private_constructed (EMsgComposer *composer)
priv->attachment_paned = g_object_ref (widget);
gtk_widget_show (widget);
+ g_object_bind_property (
+ web_view, "editable",
+ widget, "editable",
+ G_BINDING_SYNC_CREATE);
+
if (small_screen_mode) {
GtkWidget *tmp, *tmp1, *tmp_box, *container;
GtkWidget *combo;
@@ -354,7 +359,7 @@ e_composer_private_constructed (EMsgComposer *composer)
/* Reparent the scrolled window containing the GtkHTML widget
* into the content area of the top attachment pane. */
- widget = GTK_WIDGET (gtkhtml_editor_get_html (editor));
+ widget = GTK_WIDGET (web_view);
widget = gtk_widget_get_parent (widget);
container = e_attachment_paned_get_content_area (
E_ATTACHMENT_PANED (priv->attachment_paned));
@@ -416,7 +421,7 @@ e_composer_private_constructed (EMsgComposer *composer)
* switch to WebKit. --mbarnes */
g_signal_connect (
- html, "url-requested",
+ web_view, "url-requested",
G_CALLBACK (msg_composer_url_requested_cb), composer);
}
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index cc4b3c3b08..a30a48263b 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1981,9 +1981,9 @@ msg_composer_constructed (GObject *object)
EAttachmentView *view;
EAttachmentStore *store;
EComposerHeaderTable *table;
+ EWebView *web_view;
GtkUIManager *ui_manager;
GtkToggleAction *action;
- GtkHTML *html;
GArray *array;
const gchar *id;
gboolean active;
@@ -2002,7 +2002,7 @@ msg_composer_constructed (GObject *object)
e_composer_private_constructed (composer);
- html = gtkhtml_editor_get_html (editor);
+ web_view = e_msg_composer_get_web_view (composer);
ui_manager = gtkhtml_editor_get_ui_manager (editor);
view = e_msg_composer_get_attachment_view (composer);
table = E_COMPOSER_HEADER_TABLE (composer->priv->header_table);
@@ -2051,21 +2051,21 @@ msg_composer_constructed (GObject *object)
/* Clipboard Support */
g_signal_connect (
- html, "paste-clipboard",
+ web_view, "paste-clipboard",
G_CALLBACK (msg_composer_paste_clipboard_cb), composer);
/* Drag-and-Drop Support */
g_signal_connect (
- html, "realize",
+ web_view, "realize",
G_CALLBACK (msg_composer_realize_gtkhtml_cb), composer);
g_signal_connect (
- html, "drag-motion",
+ web_view, "drag-motion",
G_CALLBACK (msg_composer_drag_motion_cb), composer);
g_signal_connect (
- html, "drag-data-received",
+ web_view, "drag-data-received",
G_CALLBACK (msg_composer_drag_data_received_cb), composer);
/* Configure Headers */
@@ -2193,10 +2193,11 @@ msg_composer_key_press_event (GtkWidget *widget,
EMsgComposer *composer = E_MSG_COMPOSER (widget);
GtkWidget *input_widget;
GtkhtmlEditor *editor;
- GtkHTML *html;
+ EWebView *web_view;
editor = GTKHTML_EDITOR (widget);
- html = gtkhtml_editor_get_html (editor);
+ composer = E_MSG_COMPOSER (widget);
+ web_view = e_msg_composer_get_web_view (composer);
input_widget =
e_composer_header_table_get_header (
@@ -2221,7 +2222,7 @@ msg_composer_key_press_event (GtkWidget *widget,
}
if (event->keyval == GDK_KEY_ISO_Left_Tab &&
- gtk_widget_is_focus (GTK_WIDGET (html))) {
+ gtk_widget_is_focus (GTK_WIDGET (web_view))) {
gtk_widget_grab_focus (input_widget);
return TRUE;
}
@@ -3369,30 +3370,6 @@ e_msg_composer_new_with_message (EShell *shell,
return composer;
}
-static void
-disable_editor (EMsgComposer *composer)
-{
- GtkhtmlEditor *editor;
- GtkAction *action;
-
- g_return_if_fail (E_IS_MSG_COMPOSER (composer));
-
- editor = GTKHTML_EDITOR (composer);
-
- gtkhtml_editor_run_command (editor, "editable-off");
-
- action = GTKHTML_EDITOR_ACTION_EDIT_MENU (composer);
- gtk_action_set_sensitive (action, FALSE);
-
- action = GTKHTML_EDITOR_ACTION_FORMAT_MENU (composer);
- gtk_action_set_sensitive (action, FALSE);
-
- action = GTKHTML_EDITOR_ACTION_INSERT_MENU (composer);
- gtk_action_set_sensitive (action, FALSE);
-
- gtk_widget_set_sensitive (composer->priv->attachment_paned, FALSE);
-}
-
/**
* e_msg_composer_new_redirect:
* @shell: an #EShell
@@ -3410,6 +3387,7 @@ e_msg_composer_new_redirect (EShell *shell,
{
EMsgComposer *composer;
EComposerHeaderTable *table;
+ EWebView *web_view;
const gchar *subject;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -3427,7 +3405,8 @@ e_msg_composer_new_redirect (EShell *shell,
e_composer_header_table_set_account_name (table, resent_from);
e_composer_header_table_set_subject (table, subject);
- disable_editor (composer);
+ web_view = e_msg_composer_get_web_view (composer);
+ e_web_view_set_editable (web_view, FALSE);
return composer;
}
@@ -3475,6 +3454,30 @@ e_msg_composer_get_shell (EMsgComposer *composer)
return E_SHELL (composer->priv->shell);
}
+/**
+ * e_msg_composer_get_web_view:
+ * @composer: an #EMsgComposer
+ *
+ * Returns the #EWebView widget in @composer.
+ *
+ * Returns: the #EWebView
+ **/
+EWebView *
+e_msg_composer_get_web_view (EMsgComposer *composer)
+{
+ GtkHTML *html;
+ GtkhtmlEditor *editor;
+
+ g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
+
+ /* This is a convenience function to avoid
+ * repeating this awkwardness everywhere */
+ editor = GTKHTML_EDITOR (composer);
+ html = gtkhtml_editor_get_html (editor);
+
+ return E_WEB_VIEW (html);
+}
+
static void
msg_composer_send_cb (EMsgComposer *composer,
GAsyncResult *result,
@@ -3951,8 +3954,7 @@ e_msg_composer_set_body_text (EMsgComposer *composer,
* @body: the data to initialize the composer with
* @mime_type: the MIME type of data
*
- * Loads the given data ginto the composer as the message body.
- * This function should only be used by the CORBA composer factory.
+ * Loads the given data into the composer as the message body.
**/
void
e_msg_composer_set_body (EMsgComposer *composer,
@@ -3961,6 +3963,7 @@ e_msg_composer_set_body (EMsgComposer *composer,
{
EMsgComposerPrivate *p = composer->priv;
EComposerHeaderTable *table;
+ EWebView *web_view;
gchar *buff;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
@@ -3972,8 +3975,11 @@ e_msg_composer_set_body (EMsgComposer *composer,
"message body, which cannot be edited."));
set_editor_text (composer, buff, FALSE);
g_free (buff);
+
gtkhtml_editor_set_html_mode (GTKHTML_EDITOR (composer), FALSE);
- disable_editor (composer);
+
+ web_view = e_msg_composer_get_web_view (composer);
+ e_web_view_set_editable (web_view, FALSE);
g_free (p->mime_body);
p->mime_body = g_strdup (body);
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 5cf781022e..7b782c2c3a 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -30,6 +30,7 @@
#include <gtkhtml-editor.h>
#include <misc/e-attachment-view.h>
#include <misc/e-focus-tracker.h>
+#include <misc/e-web-view.h>
#include <shell/e-shell.h>
#include "e-composer-header-table.h"
@@ -96,6 +97,7 @@ EFocusTracker * e_msg_composer_get_focus_tracker
(EMsgComposer *composer);
CamelSession * e_msg_composer_get_session (EMsgComposer *composer);
EShell * e_msg_composer_get_shell (EMsgComposer *composer);
+EWebView * e_msg_composer_get_web_view (EMsgComposer *composer);
void e_msg_composer_send (EMsgComposer *composer);
void e_msg_composer_save_draft (EMsgComposer *composer);
diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c
index b55623a0ce..5e0de2f285 100644
--- a/plugins/external-editor/external-editor.c
+++ b/plugins/external-editor/external-editor.c
@@ -451,7 +451,7 @@ gboolean
e_plugin_ui_init (GtkUIManager *manager, EMsgComposer *composer)
{
GtkhtmlEditor *editor;
- GtkHTML *html;
+ EWebView *web_view;
editor = GTKHTML_EDITOR (composer);
@@ -460,13 +460,15 @@ e_plugin_ui_init (GtkUIManager *manager, EMsgComposer *composer)
gtkhtml_editor_get_action_group (editor, "composer"),
entries, G_N_ELEMENTS (entries), composer);
- html = gtkhtml_editor_get_html (editor);
+ web_view = e_msg_composer_get_web_view (composer);
- g_signal_connect (G_OBJECT(html), "key_press_event",
- G_CALLBACK (key_press_cb), composer);
+ g_signal_connect (
+ web_view, "key_press_event",
+ G_CALLBACK (key_press_cb), composer);
- g_signal_connect (G_OBJECT(composer), "delete-event",
- G_CALLBACK (delete_cb), composer);
+ g_signal_connect (
+ web_view, "delete-event",
+ G_CALLBACK (delete_cb), composer);
return TRUE;
}