[evolution] Bug 790632 - Option to visually wrap long lines in composer
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 790632 - Option to visually wrap long lines in composer
- Date: Mon, 4 Dec 2017 16:02:57 +0000 (UTC)
commit e9e5c2106d75c0e38fe2df50d964da7122b3b1d0
Author: Milan Crha <mcrha redhat com>
Date: Mon Dec 4 17:02:42 2017 +0100
Bug 790632 - Option to visually wrap long lines in composer
data/org.gnome.evolution.mail.gschema.xml.in | 5 ++
src/composer/e-composer-actions.c | 13 +++++
src/composer/e-composer-actions.h | 2 +
src/composer/e-composer-private.c | 6 ++
src/composer/evolution-composer.ui | 2 +
src/e-util/e-content-editor.c | 55 ++++++++++++++++++++
src/e-util/e-content-editor.h | 5 ++
src/modules/settings/e-settings-content-editor.c | 20 +++++++
src/modules/webkit-editor/e-webkit-editor.c | 51 ++++++++++++++++++
.../webkit-editor/web-extension/e-editor-page.h | 5 ++
10 files changed, 164 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index df9e06b..946e96e 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -718,6 +718,11 @@
<_summary>Show Subject above Sender in Messages column</_summary>
<_description>Whether to show Subject above Sender (From/To) in the Messages column, usually shown in
the Vertical/Wide view of the message list</_description>
</key>
+ <key name="composer-visually-wrap-long-lines" type="b">
+ <default>false</default>
+ <_summary>Visually wrap long lines in composer</_summary>
+ <_description>Whether to visually wrap long lines of text to avoid horizontal scrolling</_description>
+ </key>
<!-- The following keys are deprecated. -->
diff --git a/src/composer/e-composer-actions.c b/src/composer/e-composer-actions.c
index 0620237..3abc62e 100644
--- a/src/composer/e-composer-actions.c
+++ b/src/composer/e-composer-actions.c
@@ -541,6 +541,14 @@ static GtkToggleActionEntry toggle_entries[] = {
NULL,
N_("Toggles whether the Reply-To field is displayed"),
NULL, /* Handled by property bindings */
+ FALSE },
+
+ { "visually-wrap-long-lines",
+ NULL,
+ N_("Visually _Wrap Long Lines"),
+ NULL,
+ N_("Whether to visually wrap long lines of text to avoid horizontal scrolling"),
+ NULL,
FALSE }
};
@@ -692,6 +700,11 @@ e_composer_actions_init (EMsgComposer *composer)
e_html_editor_get_action (editor, "picture-gallery"), "sensitive",
G_BINDING_SYNC_CREATE);
+ e_binding_bind_property (
+ cnt_editor, "visually-wrap-long-lines",
+ e_html_editor_get_action (editor, "visually-wrap-long-lines"), "active",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
#if defined (ENABLE_SMIME)
visible = TRUE;
#else
diff --git a/src/composer/e-composer-actions.h b/src/composer/e-composer-actions.h
index 863cc8f..9046d00 100644
--- a/src/composer/e-composer-actions.h
+++ b/src/composer/e-composer-actions.h
@@ -76,5 +76,7 @@
E_COMPOSER_ACTION ((composer), "view-from-override")
#define E_COMPOSER_ACTION_VIEW_REPLY_TO(composer) \
E_COMPOSER_ACTION ((composer), "view-reply-to")
+#define E_COMPOSER_ACTION_VISUALLY_WRAP_LONG_LINES(composer) \
+ E_COMPOSER_ACTION ((composer), "visually-wrap-long-lines")
#endif /* E_COMPOSER_ACTIONS_H */
diff --git a/src/composer/e-composer-private.c b/src/composer/e-composer-private.c
index caeb272..24413c8 100644
--- a/src/composer/e-composer-private.c
+++ b/src/composer/e-composer-private.c
@@ -345,6 +345,12 @@ e_composer_private_constructed (EMsgComposer *composer)
G_BINDING_SYNC_CREATE);
}
+ g_settings_bind (
+ settings, "composer-visually-wrap-long-lines",
+ cnt_editor, "visually-wrap-long-lines",
+ G_SETTINGS_BIND_DEFAULT);
+
+
/* Disable actions that start asynchronous activities while an
* asynchronous activity is in progress. We enforce this with
* a simple inverted binding to EMsgComposer's "busy" property. */
diff --git a/src/composer/evolution-composer.ui b/src/composer/evolution-composer.ui
index c5aada0..55f763d 100644
--- a/src/composer/evolution-composer.ui
+++ b/src/composer/evolution-composer.ui
@@ -33,6 +33,8 @@
<menuitem action='view-bcc'/>
<separator/>
<menuitem action='picture-gallery'/>
+ <separator/>
+ <menuitem action='visually-wrap-long-lines'/>
</menu>
</placeholder>
<menu action='insert-menu'>
diff --git a/src/e-util/e-content-editor.c b/src/e-util/e-content-editor.c
index 7627aaa..45ae992 100644
--- a/src/e-util/e-content-editor.c
+++ b/src/e-util/e-content-editor.c
@@ -461,6 +461,23 @@ e_content_editor_default_init (EContentEditorInterface *iface)
G_PARAM_STATIC_STRINGS));
/**
+ * EContentEditor:visually-wrap-long-lines:
+ *
+ * Whether to visually wrap long preformatted lines.
+ *
+ * Since: 3.28
+ */
+ g_object_interface_install_property (
+ iface,
+ g_param_spec_boolean (
+ "visually-wrap-long-lines",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
* EContentEditor:paste-clipboard
*
* Emitted when user presses middle button on EContentEditor.
@@ -1389,6 +1406,44 @@ e_content_editor_get_top_signature (EContentEditor *editor)
}
/**
+ * e_content_editor_set_visually_wrap_long_lines:
+ * @editor: an #EContactEditor
+ * @value: value to set
+ *
+ * Sets whether to visually wrap long preformatted lines.
+ *
+ * Since: 3.28
+ **/
+void
+e_content_editor_set_visually_wrap_long_lines (EContentEditor *editor,
+ gboolean value)
+{
+ g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
+
+ g_object_set (G_OBJECT (editor), "visually-wrap-long-lines", value, NULL);
+}
+
+/**
+ * e_content_editor_get_visually_wrap_long_lines:
+ * @editor: an #EContactEditor
+ *
+ * Returns: Whether visually wraps long preformatted lines.
+ *
+ * Since: 3.28
+ **/
+gboolean
+e_content_editor_get_visually_wrap_long_lines (EContentEditor *editor)
+{
+ gboolean value = FALSE;
+
+ g_return_val_if_fail (E_IS_CONTENT_EDITOR (editor), FALSE);
+
+ g_object_get (G_OBJECT (editor), "visually-wrap-long-lines", &value, NULL);
+
+ return value;
+}
+
+/**
* e_content_editor_setup_editor:
* @content_editor: an #EContentEditor
* @callback: an #EContentEditorInitializedCallback function
diff --git a/src/e-util/e-content-editor.h b/src/e-util/e-content-editor.h
index e641190..dd9744e 100644
--- a/src/e-util/e-content-editor.h
+++ b/src/e-util/e-content-editor.h
@@ -525,6 +525,11 @@ void e_content_editor_set_top_signature
EThreeState value);
EThreeState e_content_editor_get_top_signature
(EContentEditor *editor);
+void e_content_editor_set_visually_wrap_long_lines
+ (EContentEditor *editor,
+ gboolean value);
+gboolean e_content_editor_get_visually_wrap_long_lines
+ (EContentEditor *editor);
/* Methods */
void e_content_editor_initialize (EContentEditor *content_editor,
diff --git a/src/modules/settings/e-settings-content-editor.c
b/src/modules/settings/e-settings-content-editor.c
index 5cb43ad..dccb531 100644
--- a/src/modules/settings/e-settings-content-editor.c
+++ b/src/modules/settings/e-settings-content-editor.c
@@ -53,6 +53,19 @@ settings_content_editor_inline_spelling_changed (ESettingsContentEditor *extensi
}
static void
+settings_content_editor_visually_wrap_long_lines_changed (ESettingsContentEditor *extension,
+ gboolean value)
+{
+ EExtensible *extensible;
+ EContentEditor *cnt_editor;
+
+ extensible = e_extension_get_extensible (E_EXTENSION (extension));
+ cnt_editor = e_html_editor_get_content_editor (E_HTML_EDITOR (extensible));
+
+ e_content_editor_set_visually_wrap_long_lines (cnt_editor, value);
+}
+
+static void
settings_content_editor_load_style (ESettingsContentEditor *extension)
{
EExtensible *extensible;
@@ -81,6 +94,8 @@ settings_content_editor_changed_cb (GSettings *settings,
if (g_strcmp0 (key, "composer-inline-spelling") == 0)
settings_content_editor_inline_spelling_changed (extension, g_settings_get_boolean
(settings, key));
+ else if (g_strcmp0 (key, "composer-visually-wrap-long-lines") == 0)
+ settings_content_editor_visually_wrap_long_lines_changed (extension,
g_settings_get_boolean (settings, key));
else
settings_content_editor_load_style (extension);
} else if (new_value) {
@@ -97,6 +112,7 @@ settings_content_editor_html_editor_realize_cb (GtkWidget *html_editor,
settings = extension->priv->settings;
settings_content_editor_inline_spelling_changed (extension, g_settings_get_boolean (settings,
"composer-inline-spelling"));
+ settings_content_editor_visually_wrap_long_lines_changed (extension, g_settings_get_boolean
(settings, "composer-visually-wrap-long-lines"));
settings_content_editor_load_style (extension);
/* Reload the web view when certain settings change. */
@@ -124,6 +140,10 @@ settings_content_editor_html_editor_realize_cb (GtkWidget *html_editor,
g_signal_connect (
settings, "changed::composer-inline-spelling",
G_CALLBACK (settings_content_editor_changed_cb), extension);
+
+ g_signal_connect (
+ settings, "changed::composer-visually-wrap-long-lines",
+ G_CALLBACK (settings_content_editor_changed_cb), extension);
}
static void
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 511503e..62ddc6d 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -50,6 +50,7 @@ enum {
PROP_SPELL_CHECKER,
PROP_START_BOTTOM,
PROP_TOP_SIGNATURE,
+ PROP_VISUALLY_WRAP_LONG_LINES,
PROP_ALIGNMENT,
PROP_BACKGROUND_COLOR,
@@ -125,6 +126,8 @@ struct _EWebKitEditorPrivate {
ESpellChecker *spell_checker;
gboolean spell_check_enabled;
+ gboolean visually_wrap_long_lines;
+
gulong owner_change_primary_clipboard_cb_id;
gulong owner_change_clipboard_cb_id;
@@ -1329,6 +1332,14 @@ webkit_editor_update_styles (EContentEditor *editor)
"}\n",
e_web_view_get_citation_color_for_level (5));
+ if (wk_editor->priv->visually_wrap_long_lines) {
+ g_string_append (
+ stylesheet,
+ "pre {\n"
+ " white-space: pre-wrap;\n"
+ "}\n");
+ }
+
if (pango_font_description_get_size (ms) < pango_font_description_get_size (vw) ||
!wk_editor->priv->html_mode)
min_size = ms;
else
@@ -2349,6 +2360,30 @@ webkit_editor_get_spell_check_enabled (EWebKitEditor *wk_editor)
return wk_editor->priv->spell_check_enabled;
}
+static void
+webkit_editor_set_visually_wrap_long_lines (EWebKitEditor *wk_editor,
+ gboolean value)
+{
+ g_return_if_fail (E_IS_WEBKIT_EDITOR (wk_editor));
+
+ if ((wk_editor->priv->visually_wrap_long_lines ? 1 : 0) == (value ? 1 : 0))
+ return;
+
+ wk_editor->priv->visually_wrap_long_lines = value;
+
+ webkit_editor_update_styles (E_CONTENT_EDITOR (wk_editor));
+
+ g_object_notify (G_OBJECT (wk_editor), "visually-wrap-long-lines");
+}
+
+static gboolean
+webkit_editor_get_visually_wrap_long_lines (EWebKitEditor *wk_editor)
+{
+ g_return_val_if_fail (E_IS_WEBKIT_EDITOR (wk_editor), FALSE);
+
+ return wk_editor->priv->visually_wrap_long_lines;
+}
+
static gboolean
webkit_editor_is_editable (EWebKitEditor *wk_editor)
{
@@ -5495,6 +5530,12 @@ webkit_editor_set_property (GObject *object,
E_WEBKIT_EDITOR (object),
g_value_get_boolean (value));
return;
+
+ case PROP_VISUALLY_WRAP_LONG_LINES:
+ webkit_editor_set_visually_wrap_long_lines (
+ E_WEBKIT_EDITOR (object),
+ g_value_get_boolean (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -5693,6 +5734,13 @@ webkit_editor_get_property (GObject *object,
webkit_editor_get_spell_checker (
E_WEBKIT_EDITOR (object)));
return;
+
+ case PROP_VISUALLY_WRAP_LONG_LINES:
+ g_value_set_boolean (
+ value,
+ webkit_editor_get_visually_wrap_long_lines (
+ E_WEBKIT_EDITOR (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -6382,6 +6430,8 @@ e_webkit_editor_class_init (EWebKitEditorClass *class)
g_object_class_override_property (
object_class, PROP_SPELL_CHECK_ENABLED, "spell-check-enabled");
g_object_class_override_property (
+ object_class, PROP_VISUALLY_WRAP_LONG_LINES, "visually-wrap-long-lines");
+ g_object_class_override_property (
object_class, PROP_SPELL_CHECKER, "spell-checker");
}
@@ -6398,6 +6448,7 @@ e_webkit_editor_init (EWebKitEditor *wk_editor)
wk_editor->priv->spell_check_enabled = TRUE;
wk_editor->priv->spell_checker = e_spell_checker_new ();
wk_editor->priv->old_settings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) g_variant_unref);
+ wk_editor->priv->visually_wrap_long_lines = FALSE;
g_signal_connect (
wk_editor, "load-changed",
diff --git a/src/modules/webkit-editor/web-extension/e-editor-page.h
b/src/modules/webkit-editor/web-extension/e-editor-page.h
index 020a18b..c6767cc 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-page.h
+++ b/src/modules/webkit-editor/web-extension/e-editor-page.h
@@ -110,6 +110,11 @@ EContentEditorAlignment
e_editor_page_get_alignment (EEditorPage *editor_page);
void e_editor_page_set_alignment (EEditorPage *editor_page,
EContentEditorAlignment value);
+gboolean e_editor_page_get_visually_wrap_long_lines
+ (EEditorPage *editor_page);
+void e_editor_page_set_visually_wrap_long_lines
+ (EEditorPage *editor_page,
+ gboolean value);
gint e_editor_page_get_word_wrap_length
(EEditorPage *editor_page);
gboolean e_editor_page_is_processing_keypress_event
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]