[evolution] EWebView, EHTMLEditorView - Improve citations look
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EWebView, EHTMLEditorView - Improve citations look
- Date: Wed, 4 Feb 2015 13:11:39 +0000 (UTC)
commit 9dab83ed71e9afedea003307161a18797fb091e3
Author: Tomas Popela <tpopela redhat com>
Date: Wed Feb 4 13:38:39 2015 +0100
EWebView, EHTMLEditorView - Improve citations look
Draw a color line (different for each level) on left and right side of citation
even in mail preview. Also make the citations more compact (in preview
and in editor).
e-util/e-html-editor-view.c | 54 +++++++-----------------------
e-util/e-web-view.c | 78 +++++++++++++++++++++++++++++++++++++++++++
e-util/e-web-view.h | 2 +
3 files changed, 92 insertions(+), 42 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 60c6d37..30aacb1 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -7937,36 +7937,6 @@ e_html_editor_view_paste_clipboard_quoted (EHTMLEditorView *view)
class->paste_clipboard_quoted (view);
}
-static const gchar *
-citation_color_level_1 (void)
-{
- return "rgb(114,159,207)"; /* Sky Blue 1 */
-}
-
-static const gchar *
-citation_color_level_2 (void)
-{
- return "rgb(173,127,168)"; /* Plum 1 */
-}
-
-static const gchar *
-citation_color_level_3 (void)
-{
- return "rgb(138,226,52)"; /* Chameleon 1 */
-}
-
-static const gchar *
-citation_color_level_4 (void)
-{
- return "rgb(252,175,62)"; /* Orange 1 */
-}
-
-static const gchar *
-citation_color_level_5 (void)
-{
- return "rgb(233,185,110)"; /* Chocolate 1 */
-}
-
/**
* e_html_editor_view_update_fonts:
* @view: an #EHTMLEditorView
@@ -8231,7 +8201,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" color: %s;\n"
"}\n",
- citation_color_level_1 ());
+ e_web_view_get_citation_color_for_level (1));
g_string_append_printf (
stylesheet,
@@ -8240,7 +8210,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" color: %s;\n"
"}\n",
- citation_color_level_2 ());
+ e_web_view_get_citation_color_for_level (2));
g_string_append_printf (
stylesheet,
@@ -8250,7 +8220,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" color: %s;\n"
"}\n",
- citation_color_level_3 ());
+ e_web_view_get_citation_color_for_level (3));
g_string_append_printf (
stylesheet,
@@ -8261,7 +8231,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" color: %s;\n"
"}\n",
- citation_color_level_4 ());
+ e_web_view_get_citation_color_for_level (4));
g_string_append_printf (
stylesheet,
@@ -8273,14 +8243,14 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" color: %s;\n"
"}\n",
- citation_color_level_5 ());
+ e_web_view_get_citation_color_for_level (5));
g_string_append (
stylesheet,
"blockquote[type=cite]:not(.-x-evo-plaintext-quoted) "
"{\n"
- " padding: 0.4ex 1ex;\n"
- " margin: 1ex;\n"
+ " padding: 0ch 1ch 0ch 1ch;\n"
+ " margin: 0ch;\n"
" border-width: 0px 2px 0px 2px;\n"
" border-style: none solid none solid;\n"
" border-radius: 2px;\n"
@@ -8294,7 +8264,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" border-color: %s;\n"
"}\n",
- citation_color_level_1 ());
+ e_web_view_get_citation_color_for_level (1));
g_string_append_printf (
stylesheet,
@@ -8303,7 +8273,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" border-color: %s;\n"
"}\n",
- citation_color_level_2 ());
+ e_web_view_get_citation_color_for_level (2));
g_string_append_printf (
stylesheet,
@@ -8313,7 +8283,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" border-color: %s;\n"
"}\n",
- citation_color_level_3 ());
+ e_web_view_get_citation_color_for_level (3));
g_string_append_printf (
stylesheet,
@@ -8324,7 +8294,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" border-color: %s;\n"
"}\n",
- citation_color_level_4 ());
+ e_web_view_get_citation_color_for_level (4));
g_string_append_printf (
stylesheet,
@@ -8336,7 +8306,7 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"{\n"
" border-color: %s;\n"
"}\n",
- citation_color_level_5 ());
+ e_web_view_get_citation_color_for_level (5));
gdk_color_free (link);
gdk_color_free (visited);
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index b9044ca..2a57505 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -2575,6 +2575,22 @@ e_web_view_get_selection_html (EWebView *web_view)
return NULL;
}
+const gchar *
+e_web_view_get_citation_color_for_level (gint level)
+{
+ static const gchar *citation_color_levels[5] = {
+ "rgb(233,185,110)", /* level 5 - Chocolate 1 */
+ "rgb(114,159,207)", /* level 1 - Sky Blue 1 */
+ "rgb(173,127,168)", /* level 2 - Plum 1 */
+ "rgb(138,226,52)", /* level 3 - Chameleon 1 */
+ "rgb(252,175,62)", /* level 4 - Orange 1 */
+ };
+
+ g_return_val_if_fail (level > 0, citation_color_levels[1]);
+
+ return citation_color_levels[level % 5];
+}
+
void
e_web_view_update_fonts (EWebView *web_view)
{
@@ -2709,6 +2725,68 @@ e_web_view_update_fonts (EWebView *web_view)
gdk_color_free (link);
gdk_color_free (visited);
+ g_string_append (
+ stylesheet,
+ "blockquote[type=cite] "
+ "{\n"
+ " padding: 0ch 1ch 0ch 1ch;\n"
+ " margin: 0ch;\n"
+ " border-width: 0px 2px 0px 2px;\n"
+ " border-style: none solid none solid;\n"
+ " border-radius: 2px;\n"
+ "}\n");
+
+ /* Block quote border colors are borrowed from Thunderbird. */
+ g_string_append_printf (
+ stylesheet,
+ "blockquote[type=cite] "
+ "{\n"
+ " border-color: %s;\n"
+ "}\n",
+ e_web_view_get_citation_color_for_level (1));
+
+ g_string_append_printf (
+ stylesheet,
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "{\n"
+ " border-color: %s;\n"
+ "}\n",
+ e_web_view_get_citation_color_for_level (2));
+
+ g_string_append_printf (
+ stylesheet,
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "{\n"
+ " border-color: %s;\n"
+ "}\n",
+ e_web_view_get_citation_color_for_level (3));
+
+ g_string_append_printf (
+ stylesheet,
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "{\n"
+ " border-color: %s;\n"
+ "}\n",
+ e_web_view_get_citation_color_for_level (4));
+
+ g_string_append_printf (
+ stylesheet,
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "blockquote[type=cite] "
+ "{\n"
+ " border-color: %s;\n"
+ "}\n",
+ e_web_view_get_citation_color_for_level (5));
+
base64 = g_base64_encode ((guchar *) stylesheet->str, stylesheet->len);
g_string_free (stylesheet, TRUE);
diff --git a/e-util/e-web-view.h b/e-util/e-web-view.h
index 1836f70..be338fe 100644
--- a/e-util/e-web-view.h
+++ b/e-util/e-web-view.h
@@ -215,6 +215,8 @@ void element_remove_class (WebKitDOMElement *element,
const gchar* class);
void remove_node (WebKitDOMNode *node);
void remove_node_if_empty (WebKitDOMNode *node);
+const gchar * e_web_view_get_citation_color_for_level
+ (gint level);
G_END_DECLS
#endif /* E_WEB_VIEW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]