[evolution/webkit-composer] Convert EEditorWidget::Mode property to boolean
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer] Convert EEditorWidget::Mode property to boolean
- Date: Sun, 4 Nov 2012 17:22:43 +0000 (UTC)
commit 5ea3ab9ab21655586c6a8a3c99949cb2b684c56a
Author: Dan VrÃtil <dvratil redhat com>
Date: Sun Nov 4 18:22:27 2012 +0100
Convert EEditorWidget::Mode property to boolean
composer/e-composer-actions.c | 2 +-
composer/e-composer-private.c | 8 ++--
composer/e-msg-composer.c | 23 +++++------
mail/em-composer-utils.c | 4 +-
modules/mail/e-mail-shell-backend.c | 6 +--
widgets/editor/e-editor-actions.c | 20 ++++-----
widgets/editor/e-editor-test.c | 6 +--
widgets/editor/e-editor-widget.c | 64 +++++++++++++++----------------
widgets/editor/e-editor-widget.h | 12 +----
widgets/misc/e-mail-signature-editor.c | 7 +--
widgets/misc/e-mail-signature-manager.c | 6 +--
11 files changed, 65 insertions(+), 93 deletions(-)
---
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index 1692e44..2dfc13b 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -530,7 +530,7 @@ e_composer_actions_init (EMsgComposer *composer)
ACTION (SAVE_DRAFT), "short-label", _("Save Draft"), NULL);
g_object_bind_property (
- editor_widget, "mode",
+ editor_widget, "html-mode",
ACTION (PICTURE_GALLERY), "sensitive",
G_BINDING_SYNC_CREATE);
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 18e1878..21908da 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -67,16 +67,16 @@ composer_update_gallery_visibility (EMsgComposer *composer)
EEditorWidget *editor_widget;
GtkToggleAction *toggle_action;
gboolean gallery_active;
- EEditorWidgetMode mode;
+ gboolean is_html;
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);
+ is_html = e_editor_widget_get_html_mode (editor_widget);
toggle_action = GTK_TOGGLE_ACTION (ACTION (PICTURE_GALLERY));
gallery_active = gtk_toggle_action_get_active (toggle_action);
- if ((mode == E_EDITOR_WIDGET_MODE_HTML) && gallery_active) {
+ if (is_html && gallery_active) {
gtk_widget_show (composer->priv->gallery_scrolled_window);
gtk_widget_show (composer->priv->gallery_icon_view);
} else {
@@ -646,7 +646,7 @@ e_composer_paste_image (EMsgComposer *composer,
* In text mode, add the image to the attachment store. */
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
- if (e_editor_widget_get_mode (editor_widget) == E_EDITOR_WIDGET_MODE_HTML) {
+ if (e_editor_widget_get_html_mode (editor_widget)) {
EEditorSelection *selection;
selection = e_editor_widget_get_selection (editor_widget);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 5635349..d728dd0 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1686,11 +1686,10 @@ msg_composer_paste_clipboard_targets_cb (GtkClipboard *clipboard,
{
EEditor *editor;
EEditorWidget *editor_widget;
- EEditorWidgetMode mode;
+ gboolean is_html;
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. */
@@ -1701,7 +1700,7 @@ msg_composer_paste_clipboard_targets_cb (GtkClipboard *clipboard,
}
/* Only paste HTML content in HTML mode. */
- if (mode == E_EDITOR_WIDGET_MODE_HTML) {
+ if (e_editor_widget_get_html_mode (editor_widget)) {
if (e_targets_include_html (targets, n_targets)) {
e_composer_paste_html (composer, clipboard);
return;
@@ -1798,14 +1797,12 @@ msg_composer_drag_data_received_cb (GtkWidget *widget,
EAttachmentView *view;
EEditor *editor;
EEditorWidget *editor_widget;
- EEditorWidgetMode mode;
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);
/* HTML mode has a few special cases for drops... */
- if (mode == E_EDITOR_WIDGET_MODE_HTML) {
+ if (e_editor_widget_get_html_mode (editor_widget)) {
/* If we're receiving an image, we want the image to be
* inserted in the message body. Let GtkHtml handle it. */
@@ -3316,11 +3313,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) {
- e_editor_widget_set_mode (
- editor_widget, E_EDITOR_WIDGET_MODE_HTML);
+ e_editor_widget_set_html_mode (
+ editor_widget, TRUE);
} else if (g_ascii_strcasecmp (flags[i], "text/plain") == 0) {
- e_editor_widget_set_mode (
- editor_widget, E_EDITOR_WIDGET_MODE_PLAIN_TEXT);
+ e_editor_widget_set_html_mode (
+ editor_widget, FALSE);
} else if (g_ascii_strcasecmp (flags[i], "pgp-sign") == 0) {
action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
gtk_toggle_action_set_active (action, TRUE);
@@ -4311,7 +4308,7 @@ e_msg_composer_set_body (EMsgComposer *composer,
set_editor_text (composer, buff, FALSE);
g_free (buff);
- e_editor_widget_set_mode (editor_widget, E_EDITOR_WIDGET_MODE_PLAIN_TEXT);
+ e_editor_widget_set_html_mode (editor_widget, FALSE);
webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), FALSE);
g_free (priv->mime_body);
@@ -4689,7 +4686,7 @@ e_msg_composer_get_message (EMsgComposer *composer,
g_simple_async_result_set_check_cancellable (simple, cancellable);
- if (e_editor_widget_get_mode (editor_widget) == E_EDITOR_WIDGET_MODE_HTML) {
+ if (e_editor_widget_get_html_mode (editor_widget)) {
flags |= COMPOSER_FLAG_HTML_CONTENT;
}
@@ -4830,7 +4827,7 @@ e_msg_composer_get_message_draft (EMsgComposer *composer,
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
- if (e_editor_widget_get_mode (editor_widget) == E_EDITOR_WIDGET_MODE_HTML) {
+ if (e_editor_widget_get_html_mode (editor_widget)) {
flags |= COMPOSER_FLAG_HTML_CONTENT;
}
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 5648e2a..9e4a1bf 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -472,7 +472,6 @@ composer_presend_check_unwanted_html (EMsgComposer *composer,
EComposerHeaderTable *table;
GSettings *settings;
gboolean check_passed = TRUE;
- EEditorWidgetMode html_mode;
gboolean send_html;
gboolean confirm_html;
gint ii;
@@ -483,7 +482,6 @@ composer_presend_check_unwanted_html (EMsgComposer *composer,
recipients = e_composer_header_table_get_destinations (table);
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
- html_mode = e_editor_widget_get_mode (editor_widget);
send_html = g_settings_get_boolean (settings, "composer-send-html");
confirm_html = g_settings_get_boolean (settings, "prompt-on-unwanted-html");
@@ -491,7 +489,7 @@ composer_presend_check_unwanted_html (EMsgComposer *composer,
/* Only show this warning if our default is to send html. If it
* isn't, we've manually switched into html mode in the composer
* and (presumably) had a good reason for doing this. */
- if (html_mode == E_EDITOR_WIDGET_MODE_HTML && send_html &&
+ if (e_editor_widget_get_html_mode (editor_widget) && send_html &&
confirm_html && recipients != NULL) {
gboolean html_problem = FALSE;
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 1839f35..2cc2271 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -399,11 +399,7 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
shell_settings, "composer-format-html");
}
- e_editor_widget_set_mode (
- editor_widget,
- active ?
- E_EDITOR_WIDGET_MODE_HTML :
- E_EDITOR_WIDGET_MODE_PLAIN_TEXT);
+ e_editor_widget_set_html_mode (editor_widget, active);
}
if (E_IS_MSG_COMPOSER (window)) {
diff --git a/widgets/editor/e-editor-actions.c b/widgets/editor/e-editor-actions.c
index 03b9275..2f06a3a 100644
--- a/widgets/editor/e-editor-actions.c
+++ b/widgets/editor/e-editor-actions.c
@@ -635,14 +635,12 @@ mode_changed (struct _ModeChanged *data)
GtkActionGroup *action_group;
EEditor *editor = data->editor;
EEditorWidget *widget;
- EEditorWidgetMode mode;
gboolean is_html;
widget = e_editor_get_editor_widget (editor);
- mode = gtk_radio_action_get_current_value (data->action);
- is_html = (mode == E_EDITOR_WIDGET_MODE_HTML);
+ is_html = gtk_radio_action_get_current_value (data->action);
- if (mode == e_editor_widget_get_mode (widget)) {
+ if (is_html == e_editor_widget_get_html_mode (widget)) {
goto exit;
}
@@ -669,7 +667,7 @@ mode_changed (struct _ModeChanged *data)
NULL);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL) {
gtk_radio_action_set_current_value (
- data->action, E_EDITOR_WIDGET_MODE_HTML);
+ data->action, TRUE);
gtk_widget_destroy (dialog);
goto exit;
}
@@ -700,8 +698,8 @@ mode_changed (struct _ModeChanged *data)
gtk_action_set_sensitive (ACTION (STYLE_H6), is_html);
gtk_action_set_sensitive (ACTION (STYLE_ADDRESS), is_html);
- e_editor_widget_set_mode (
- e_editor_get_editor_widget (editor), mode);
+ e_editor_widget_set_html_mode (
+ e_editor_get_editor_widget (editor), is_html);
exit:
g_clear_object (&data->editor);
@@ -1143,14 +1141,14 @@ static GtkRadioActionEntry core_mode_entries[] = {
N_("_HTML"),
NULL,
N_("HTML editing mode"),
- E_EDITOR_WIDGET_MODE_HTML },
+ TRUE }, /* e_editor_widget_set_html_mode */
{ "mode-plain",
NULL,
N_("Plain _Text"),
NULL,
N_("Plain text editing mode"),
- E_EDITOR_WIDGET_MODE_PLAIN_TEXT }
+ FALSE } /* e_editor_widget_set_html_mode */
};
static GtkRadioActionEntry core_style_entries[] = {
@@ -1829,7 +1827,7 @@ editor_actions_init (EEditor *editor)
gtk_action_group_add_radio_actions (
action_group, core_mode_entries,
G_N_ELEMENTS (core_mode_entries),
- E_EDITOR_WIDGET_MODE_HTML,
+ TRUE,
G_CALLBACK (action_mode_cb), editor);
gtk_action_group_add_radio_actions (
action_group, core_style_entries,
@@ -1839,7 +1837,7 @@ editor_actions_init (EEditor *editor)
gtk_ui_manager_insert_action_group (manager, action_group, 0);
/* Synchronize wiget mode with the button */
- e_editor_widget_set_mode (editor_widget, E_EDITOR_WIDGET_MODE_HTML);
+ e_editor_widget_set_html_mode (editor_widget, TRUE);
/* Face Action */
action = e_emoticon_action_new (
diff --git a/widgets/editor/e-editor-test.c b/widgets/editor/e-editor-test.c
index a34b4f4..93a7301 100644
--- a/widgets/editor/e-editor-test.c
+++ b/widgets/editor/e-editor-test.c
@@ -228,8 +228,7 @@ action_save_cb (GtkAction *action,
return;
filename = e_editor_get_filename (editor);
- as_html = (e_editor_widget_get_mode (
- e_editor_get_editor_widget (editor)) == E_EDITOR_WIDGET_MODE_HTML);
+ as_html = (e_editor_widget_get_html_mode (e_editor_get_editor_widget (editor)));
e_editor_save (editor, filename, as_html, &error);
handle_error (&error);
@@ -247,8 +246,7 @@ action_save_as_cb (GtkAction *action,
return;
filename = e_editor_get_filename (editor);
- as_html = (e_editor_widget_get_mode (
- e_editor_get_editor_widget (editor)) == E_EDITOR_WIDGET_MODE_HTML);
+ as_html = (e_editor_widget_get_html_mode (e_editor_get_editor_widget (editor)));
e_editor_save (editor, filename, as_html, &error);
handle_error (&error);
diff --git a/widgets/editor/e-editor-widget.c b/widgets/editor/e-editor-widget.c
index 2e1c82c..e781c72 100644
--- a/widgets/editor/e-editor-widget.c
+++ b/widgets/editor/e-editor-widget.c
@@ -40,11 +40,10 @@ struct _EEditorWidgetPrivate {
gint can_redo : 1;
gint can_undo : 1;
gint reload_in_progress : 1;
+ gint html_mode : 1;
EEditorSelection *selection;
- EEditorWidgetMode mode;
-
/* FIXME WEBKIT Is this in widget's competence? */
GList *spelling_langs;
@@ -62,7 +61,7 @@ G_DEFINE_TYPE (
enum {
PROP_0,
PROP_CHANGED,
- PROP_MODE,
+ PROP_HTML_MODE,
PROP_INLINE_SPELLING,
PROP_MAGIC_LINKS,
PROP_MAGIC_SMILEYS,
@@ -462,7 +461,7 @@ editor_widget_key_release_event (GtkWidget *gtk_widget,
range = editor_widget_get_dom_range (widget);
if (widget->priv->magic_smileys &&
- widget->priv->mode == E_EDITOR_WIDGET_MODE_HTML) {
+ widget->priv->html_mode) {
editor_widget_check_magic_smileys (widget, range);
}
@@ -569,9 +568,9 @@ e_editor_widget_get_property (GObject *object,
{
switch (property_id) {
- case PROP_MODE:
- g_value_set_int (
- value, e_editor_widget_get_mode (
+ case PROP_HTML_MODE:
+ g_value_set_boolean (
+ value, e_editor_widget_get_html_mode (
E_EDITOR_WIDGET (object)));
return;
@@ -635,10 +634,10 @@ e_editor_widget_set_property (GObject *object,
{
switch (property_id) {
- case PROP_MODE:
- e_editor_widget_set_mode (
+ case PROP_HTML_MODE:
+ e_editor_widget_set_html_mode (
E_EDITOR_WIDGET (object),
- g_value_get_int (value));
+ g_value_get_boolean (value));
return;
case PROP_INLINE_SPELLING:
@@ -702,14 +701,12 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
g_object_class_install_property (
object_class,
- PROP_MODE,
- g_param_spec_int (
- "mode",
- "Mode",
+ PROP_HTML_MODE,
+ g_param_spec_boolean (
+ "html-mode",
+ "HTML Mode",
"Edit HTML or plain text",
- E_EDITOR_WIDGET_MODE_PLAIN_TEXT,
- E_EDITOR_WIDGET_MODE_HTML,
- E_EDITOR_WIDGET_MODE_PLAIN_TEXT,
+ FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
@@ -944,33 +941,27 @@ e_editor_widget_set_changed (EEditorWidget *widget,
g_object_notify (G_OBJECT (widget), "changed");
}
-EEditorWidgetMode
-e_editor_widget_get_mode (EEditorWidget *widget)
+gboolean
+e_editor_widget_get_html_mode (EEditorWidget *widget)
{
g_return_val_if_fail (E_IS_EDITOR_WIDGET (widget), FALSE);
- return widget->priv->mode;
+ return widget->priv->html_mode;
}
void
-e_editor_widget_set_mode (EEditorWidget *widget,
- EEditorWidgetMode mode)
+e_editor_widget_set_html_mode (EEditorWidget *widget,
+ gboolean html_mode)
{
g_return_if_fail (E_IS_EDITOR_WIDGET (widget));
- if (widget->priv->mode == mode)
+ if ((widget->priv->html_mode ? 1 : 0) == (html_mode ? 1 : 0)) {
return;
+ }
- widget->priv->mode = mode;
-
- if (widget->priv->mode == E_EDITOR_WIDGET_MODE_PLAIN_TEXT) {
- gchar *plain;
+ widget->priv->html_mode = html_mode;
- plain = e_editor_widget_get_text_plain (widget);
- e_editor_widget_set_text_plain (widget, plain);
-
- g_free (plain);
- } else {
+ if (widget->priv->html_mode) {
gchar *plain_text, *html;
plain_text = e_editor_widget_get_text_plain (widget);
@@ -990,9 +981,16 @@ e_editor_widget_set_mode (EEditorWidget *widget,
g_free (plain_text);
g_free (html);
+ } else {
+ gchar *plain;
+
+ plain = e_editor_widget_get_text_plain (widget);
+ e_editor_widget_set_text_plain (widget, plain);
+
+ g_free (plain);
}
- g_object_notify (G_OBJECT (widget), "mode");
+ g_object_notify (G_OBJECT (widget), "html-mode");
}
gboolean
diff --git a/widgets/editor/e-editor-widget.h b/widgets/editor/e-editor-widget.h
index 8e065da..9ef7298 100644
--- a/widgets/editor/e-editor-widget.h
+++ b/widgets/editor/e-editor-widget.h
@@ -45,11 +45,6 @@
G_BEGIN_DECLS
typedef enum {
- E_EDITOR_WIDGET_MODE_PLAIN_TEXT,
- E_EDITOR_WIDGET_MODE_HTML,
-} EEditorWidgetMode;
-
-typedef enum {
E_EDITOR_WIDGET_REPLACE_ANSWER_REPLACE,
E_EDITOR_WIDGET_REPLACE_ANSWER_REPLACE_ALL,
E_EDITOR_WIDGET_REPLACE_ANSWER_CANCEL,
@@ -87,10 +82,9 @@ gboolean e_editor_widget_get_changed (EEditorWidget *widget);
void e_editor_widget_set_changed (EEditorWidget *widget,
gboolean changed);
-EEditorWidgetMode
- e_editor_widget_get_mode (EEditorWidget *widget);
-void e_editor_widget_set_mode (EEditorWidget *widget,
- EEditorWidgetMode mode);
+gboolean e_editor_widget_get_html_mode (EEditorWidget *widget);
+void e_editor_widget_set_html_mode (EEditorWidget *widget,
+ gboolean html_mode);
gboolean e_editor_widget_get_inline_spelling
(EEditorWidget *widget);
diff --git a/widgets/misc/e-mail-signature-editor.c b/widgets/misc/e-mail-signature-editor.c
index bd9028d..6804366 100644
--- a/widgets/misc/e-mail-signature-editor.c
+++ b/widgets/misc/e-mail-signature-editor.c
@@ -156,8 +156,7 @@ mail_signature_editor_loaded_cb (GObject *object,
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (object));
editor_widget = e_editor_get_editor_widget (editor);
- e_editor_widget_set_mode (editor_widget,
- (is_html) ? E_EDITOR_WIDGET_MODE_HTML : E_EDITOR_WIDGET_MODE_PLAIN_TEXT);
+ e_editor_widget_set_html_mode (editor_widget, is_html);
editor_selection = e_editor_widget_get_selection (editor_widget);
if (is_html) {
@@ -816,7 +815,6 @@ e_mail_signature_editor_commit (EMailSignatureEditor *window,
gchar *contents;
EEditor *editor;
EEditorWidget *editor_widget;
- EEditorWidgetMode mode;
g_return_if_fail (E_IS_MAIL_SIGNATURE_EDITOR (window));
@@ -824,9 +822,8 @@ e_mail_signature_editor_commit (EMailSignatureEditor *window,
source = e_mail_signature_editor_get_source (window);
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
editor_widget = e_editor_get_editor_widget (editor);
- mode = e_editor_widget_get_mode (editor_widget);
- if (mode == E_EDITOR_WIDGET_MODE_HTML) {
+ if (e_editor_widget_get_html_mode (editor_widget)) {
mime_type = "text/html";
contents = e_editor_widget_get_text_html (editor_widget);
} else {
diff --git a/widgets/misc/e-mail-signature-manager.c b/widgets/misc/e-mail-signature-manager.c
index d4661c8..4bf3ad0 100644
--- a/widgets/misc/e-mail-signature-manager.c
+++ b/widgets/misc/e-mail-signature-manager.c
@@ -410,11 +410,7 @@ mail_signature_manager_add_signature (EMailSignatureManager *manager)
editor = e_mail_signature_editor_new (registry, NULL);
editor_widget = e_mail_signature_editor_get_editor_widget (
E_MAIL_SIGNATURE_EDITOR (editor));
- e_editor_widget_set_mode (
- editor_widget,
- manager->priv->prefer_html ?
- E_EDITOR_WIDGET_MODE_HTML :
- E_EDITOR_WIDGET_MODE_PLAIN_TEXT);
+ e_editor_widget_set_html_mode (editor_widget, manager->priv->prefer_html);
mail_signature_manager_emit_editor_created (manager, editor);
gtk_widget_grab_focus (manager->priv->tree_view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]