diff options
Diffstat (limited to 'em-format')
-rw-r--r-- | em-format/e-mail-formatter-error.c | 6 | ||||
-rw-r--r-- | em-format/e-mail-formatter-headers.c | 8 | ||||
-rw-r--r-- | em-format/e-mail-formatter-message-rfc822.c | 4 | ||||
-rw-r--r-- | em-format/e-mail-formatter-print.c | 13 | ||||
-rw-r--r-- | em-format/e-mail-formatter-source.c | 10 | ||||
-rw-r--r-- | em-format/e-mail-formatter-text-enriched.c | 6 | ||||
-rw-r--r-- | em-format/e-mail-formatter-text-html.c | 4 | ||||
-rw-r--r-- | em-format/e-mail-formatter-text-plain.c | 10 | ||||
-rw-r--r-- | em-format/e-mail-formatter.c | 106 | ||||
-rw-r--r-- | em-format/e-mail-formatter.h | 16 |
10 files changed, 93 insertions, 90 deletions
diff --git a/em-format/e-mail-formatter-error.c b/em-format/e-mail-formatter-error.c index 6decb6409b..d5fd64b50d 100644 --- a/em-format/e-mail-formatter-error.c +++ b/em-format/e-mail-formatter-error.c @@ -66,13 +66,13 @@ emfe_error_format (EMailFormatterExtension *extension, "<tr valign=\"top\"><td width=50>" "<img src=\"gtk-stock://%s/?size=%d\" /></td>\n" "<td style=\"color: red;\">", - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_FRAME)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_BODY)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_TEXT)), GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG); diff --git a/em-format/e-mail-formatter-headers.c b/em-format/e-mail-formatter-headers.c index ef86c21fc5..ab22e1a353 100644 --- a/em-format/e-mail-formatter-headers.c +++ b/em-format/e-mail-formatter-headers.c @@ -516,10 +516,10 @@ emfe_headers_format (EMailFormatterExtension *extension, buffer = g_string_new (""); if (context->mode == E_MAIL_FORMATTER_MODE_PRINTING) { - GdkColor white = { 0, G_MAXUINT16, G_MAXUINT16, G_MAXUINT16 }; - bg_color = e_color_to_value (&white); + GdkRGBA white = { 1.0, 1.0, 1.0, 1.0}; + bg_color = e_rgba_to_value (&white); } else { - bg_color = e_color_to_value ((GdkColor *) + bg_color = e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_BODY)); } @@ -531,7 +531,7 @@ emfe_headers_format (EMailFormatterExtension *extension, "<tr><td valign=\"top\" width=\"16\">\n", bg_color, part->id, - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_HEADER))); diff --git a/em-format/e-mail-formatter-message-rfc822.c b/em-format/e-mail-formatter-message-rfc822.c index f6e1a18cfc..8059e55e76 100644 --- a/em-format/e-mail-formatter-message-rfc822.c +++ b/em-format/e-mail-formatter-message-rfc822.c @@ -217,10 +217,10 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, " id=\"%s.iframe\" " " frameborder=\"0\" src=\"%s\" name=\"%s\"></iframe>" "</div>", - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_FRAME)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_BODY)), part->id, uri, part->id); diff --git a/em-format/e-mail-formatter-print.c b/em-format/e-mail-formatter-print.c index 7e15b93e0f..4d6487d526 100644 --- a/em-format/e-mail-formatter-print.c +++ b/em-format/e-mail-formatter-print.c @@ -175,22 +175,21 @@ mail_formatter_print_run (EMailFormatter *formatter, } static void -mail_formatter_set_style (EMailFormatter *formatter, - GtkStyle *style, - GtkStateType state) +mail_formatter_update_style (EMailFormatter *formatter, + GtkStateFlags state) { EMailFormatterClass *formatter_class; /* White background */ - GdkColor body_color = { 0, G_MAXUINT16, G_MAXUINT16, G_MAXUINT16 }; + GdkRGBA body_color = { 1.0, 1.0, 1.0, 1.0 }; /* Black text */ - GdkColor text_color = { 0, 0, 0, 0 }; + GdkRGBA text_color = { 0.0, 0.0, 0.0, 0.0 }; g_object_freeze_notify (G_OBJECT (formatter)); /* Set the other colors */ formatter_class = E_MAIL_FORMATTER_CLASS (e_mail_formatter_print_parent_class); - formatter_class->set_style (formatter, style, state); + formatter_class->update_style (formatter, state); e_mail_formatter_set_color ( formatter, E_MAIL_FORMATTER_COLOR_FRAME, &body_color); @@ -225,7 +224,7 @@ e_mail_formatter_print_class_init (EMailFormatterPrintClass *class) formatter_class = E_MAIL_FORMATTER_CLASS (class); formatter_class->run = mail_formatter_print_run; - formatter_class->set_style = mail_formatter_set_style; + formatter_class->update_style = mail_formatter_update_style; object_class = G_OBJECT_CLASS (class); object_class->finalize = e_mail_formatter_print_finalize; diff --git a/em-format/e-mail-formatter-source.c b/em-format/e-mail-formatter-source.c index fed444e0f1..faa4c76521 100644 --- a/em-format/e-mail-formatter-source.c +++ b/em-format/e-mail-formatter-source.c @@ -72,10 +72,10 @@ emfe_source_format (EMailFormatterExtension *extension, buffer, "<div class=\"part-container\" " "style=\"border: 0; background: #%06x; color: #%06x;\" >", - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_BODY)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_TEXT))); } else { @@ -84,13 +84,13 @@ emfe_source_format (EMailFormatterExtension *extension, "<div class=\"part-container\" " "style=\"border-color: #%06x; background: #%06x; color: #%06x;\">" "<div class=\"part-container-inner-margin pre\">\n", - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_FRAME)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_BODY)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_TEXT))); } diff --git a/em-format/e-mail-formatter-text-enriched.c b/em-format/e-mail-formatter-text-enriched.c index 988579e7cd..3859558aaf 100644 --- a/em-format/e-mail-formatter-text-enriched.c +++ b/em-format/e-mail-formatter-text-enriched.c @@ -76,11 +76,11 @@ emfe_text_enriched_format (EMailFormatterExtension *extension, "<div class=\"part-container\" style=\"border-color: #%06x; " "background-color: #%06x; color: #%06x;\">" "<div class=\"part-container-inner-margin\">\n", - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color (formatter, E_MAIL_FORMATTER_COLOR_FRAME)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color (formatter, E_MAIL_FORMATTER_COLOR_CONTENT)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color (formatter, E_MAIL_FORMATTER_COLOR_TEXT))); camel_stream_write_string (stream, buffer->str, cancellable, NULL); diff --git a/em-format/e-mail-formatter-text-html.c b/em-format/e-mail-formatter-text-html.c index 8e9a6a6d0e..2b8eb567ee 100644 --- a/em-format/e-mail-formatter-text-html.c +++ b/em-format/e-mail-formatter-text-html.c @@ -331,10 +331,10 @@ emfe_text_html_format (EMailFormatterExtension *extension, uri, part->id, part->id, - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_FRAME)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_CONTENT))); diff --git a/em-format/e-mail-formatter-text-plain.c b/em-format/e-mail-formatter-text-plain.c index bf83e166dd..122c566cf0 100644 --- a/em-format/e-mail-formatter-text-plain.c +++ b/em-format/e-mail-formatter-text-plain.c @@ -93,7 +93,7 @@ emfe_text_plain_format (EMailFormatterExtension *extension, && !g_ascii_strcasecmp (format, "flowed")) flags |= CAMEL_MIME_FILTER_TOHTML_FORMAT_FLOWED; - rgb = e_color_to_value ((GdkColor *) + rgb = e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_CITATION)); @@ -107,10 +107,10 @@ emfe_text_plain_format (EMailFormatterExtension *extension, "<div class=\"part-container pre\" style=\"" "border: none; padding: 8px; margin: 0; " "background-color: #%06x; color: #%06x;\">\n", - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_CONTENT)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_TEXT))); @@ -164,10 +164,10 @@ emfe_text_plain_format (EMailFormatterExtension *extension, "</iframe>" "</div>", part->id, part->id, uri, - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_FRAME)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_CONTENT))); diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c index ad62320eee..95eacaaed7 100644 --- a/em-format/e-mail-formatter.c +++ b/em-format/e-mail-formatter.c @@ -466,34 +466,42 @@ mail_formatter_run (EMailFormatter *formatter, } static void -mail_formatter_set_style (EMailFormatter *formatter, - GtkStyle *style, - GtkStateType state) +mail_formatter_update_style (EMailFormatter *formatter, + GtkStateFlags state) { - GdkColor *color; - EMailFormatterColorType type; + GtkStyleContext *style_context; + GtkWidgetPath *widget_path; + GdkRGBA rgba; g_object_freeze_notify (G_OBJECT (formatter)); - color = &style->bg[state]; - type = E_MAIL_FORMATTER_COLOR_BODY; - e_mail_formatter_set_color (formatter, type, color); + /* derive colors from top-level window */ + style_context = gtk_style_context_new (); + widget_path = gtk_widget_path_new (); + gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW); + gtk_style_context_set_path (style_context, widget_path); - color = &style->base[GTK_STATE_NORMAL]; - type = E_MAIL_FORMATTER_COLOR_CONTENT; - e_mail_formatter_set_color (formatter, type, color); + gtk_style_context_get_background_color (style_context, state, &rgba); + e_mail_formatter_set_color (formatter, E_MAIL_FORMATTER_COLOR_BODY, &rgba); - color = &style->dark[state]; - type = E_MAIL_FORMATTER_COLOR_FRAME; - e_mail_formatter_set_color (formatter, type, color); + rgba.red *= 0.8; + rgba.green *= 0.8; + rgba.blue *= 0.8; + e_mail_formatter_set_color (formatter, E_MAIL_FORMATTER_COLOR_FRAME, &rgba); - color = &style->fg[state]; - type = E_MAIL_FORMATTER_COLOR_HEADER; - e_mail_formatter_set_color (formatter, type, color); + gtk_style_context_get_color (style_context, state, &rgba); + e_mail_formatter_set_color (formatter, E_MAIL_FORMATTER_COLOR_HEADER, &rgba); - color = &style->text[state]; - type = E_MAIL_FORMATTER_COLOR_TEXT; - e_mail_formatter_set_color (formatter, type, color); + gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_ENTRY); + + gtk_style_context_get_background_color (style_context, state | GTK_STATE_FLAG_FOCUSED, &rgba); + e_mail_formatter_set_color (formatter, E_MAIL_FORMATTER_COLOR_CONTENT, &rgba); + + gtk_style_context_get_color (style_context, state | GTK_STATE_FLAG_FOCUSED, &rgba); + e_mail_formatter_set_color (formatter, E_MAIL_FORMATTER_COLOR_TEXT, &rgba); + + gtk_widget_path_free (widget_path); + g_object_unref (style_context); g_object_thaw_notify (G_OBJECT (formatter)); } @@ -542,7 +550,7 @@ static void e_mail_formatter_class_init (EMailFormatterClass *class) { GObjectClass *object_class; - GdkColor *color; + GdkRGBA *rgba; e_mail_formatter_parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailFormatterPrivate)); @@ -555,22 +563,22 @@ e_mail_formatter_class_init (EMailFormatterClass *class) class->context_size = sizeof (EMailFormatterContext); class->run = mail_formatter_run; - class->set_style = mail_formatter_set_style; + class->update_style = mail_formatter_update_style; - color = &class->colors[E_MAIL_FORMATTER_COLOR_BODY]; - gdk_color_parse ("#eeeeee", color); + rgba = &class->colors[E_MAIL_FORMATTER_COLOR_BODY]; + gdk_rgba_parse (rgba, "#eeeeee"); - color = &class->colors[E_MAIL_FORMATTER_COLOR_CONTENT]; - gdk_color_parse ("#ffffff", color); + rgba = &class->colors[E_MAIL_FORMATTER_COLOR_CONTENT]; + gdk_rgba_parse (rgba, "#ffffff"); - color = &class->colors[E_MAIL_FORMATTER_COLOR_FRAME]; - gdk_color_parse ("#3f3f3f", color); + rgba = &class->colors[E_MAIL_FORMATTER_COLOR_FRAME]; + gdk_rgba_parse (rgba, "#3f3f3f"); - color = &class->colors[E_MAIL_FORMATTER_COLOR_HEADER]; - gdk_color_parse ("#eeeeee", color); + rgba = &class->colors[E_MAIL_FORMATTER_COLOR_HEADER]; + gdk_rgba_parse (rgba, "#eeeeee"); - color = &class->colors[E_MAIL_FORMATTER_COLOR_TEXT]; - gdk_color_parse ("#000000", color); + rgba = &class->colors[E_MAIL_FORMATTER_COLOR_TEXT]; + gdk_rgba_parse (rgba, "#000000"); g_object_class_install_property ( object_class, @@ -579,7 +587,7 @@ e_mail_formatter_class_init (EMailFormatterClass *class) "body-color", "Body Color", NULL, - GDK_TYPE_COLOR, + GDK_TYPE_RGBA, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -589,7 +597,7 @@ e_mail_formatter_class_init (EMailFormatterClass *class) "citation-color", "Citation Color", NULL, - GDK_TYPE_COLOR, + GDK_TYPE_RGBA, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -599,7 +607,7 @@ e_mail_formatter_class_init (EMailFormatterClass *class) "content-color", "Content Color", NULL, - GDK_TYPE_COLOR, + GDK_TYPE_RGBA, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -609,7 +617,7 @@ e_mail_formatter_class_init (EMailFormatterClass *class) "frame-color", "Frame Color", NULL, - GDK_TYPE_COLOR, + GDK_TYPE_RGBA, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -619,7 +627,7 @@ e_mail_formatter_class_init (EMailFormatterClass *class) "header-color", "Header Color", NULL, - GDK_TYPE_COLOR, + GDK_TYPE_RGBA, G_PARAM_READWRITE)); g_object_class_install_property ( @@ -1067,13 +1075,13 @@ e_mail_formatter_get_html_header (EMailFormatter *formatter) " table th { color: #%06x; font-weight: bold; }\n" "</style>\n" "</head><body bgcolor=\"#%06x\" text=\"#%06x\">", - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_HEADER)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_BODY)), - e_color_to_value ((GdkColor *) + e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_TEXT))); } @@ -1097,7 +1105,7 @@ e_mail_formatter_get_text_format_flags (EMailFormatter *formatter) return E_MAIL_FORMATTER_GET_CLASS (formatter)->text_html_flags; } -const GdkColor * +const GdkRGBA * e_mail_formatter_get_color (EMailFormatter *formatter, EMailFormatterColorType type) { @@ -1110,9 +1118,9 @@ e_mail_formatter_get_color (EMailFormatter *formatter, void e_mail_formatter_set_color (EMailFormatter *formatter, EMailFormatterColorType type, - const GdkColor *color) + const GdkRGBA *color) { - GdkColor *format_color; + GdkRGBA *format_color; const gchar *property_name; g_return_if_fail (E_IS_MAIL_FORMATTER (formatter)); @@ -1121,7 +1129,7 @@ e_mail_formatter_set_color (EMailFormatter *formatter, format_color = &E_MAIL_FORMATTER_GET_CLASS (formatter)->colors[type]; - if (gdk_color_equal (color, format_color)) + if (gdk_rgba_equal (color, format_color)) return; format_color->red = color->red; @@ -1155,19 +1163,17 @@ e_mail_formatter_set_color (EMailFormatter *formatter, } void -e_mail_formatter_set_style (EMailFormatter *formatter, - GtkStyle *style, - GtkStateType state) +e_mail_formatter_update_style (EMailFormatter *formatter, + GtkStateFlags state) { EMailFormatterClass *formatter_class; g_return_if_fail (E_IS_MAIL_FORMATTER (formatter)); - g_return_if_fail (GTK_IS_STYLE (style)); formatter_class = E_MAIL_FORMATTER_GET_CLASS (formatter); - g_return_if_fail (formatter_class->set_style != NULL); + g_return_if_fail (formatter_class->update_style != NULL); - formatter_class->set_style (formatter, style, state); + formatter_class->update_style (formatter, state); } EMailImageLoadingPolicy diff --git a/em-format/e-mail-formatter.h b/em-format/e-mail-formatter.h index 93e5268950..2c7b144359 100644 --- a/em-format/e-mail-formatter.h +++ b/em-format/e-mail-formatter.h @@ -110,7 +110,7 @@ struct _EMailFormatterClass { CamelMimeFilterToHTMLFlags text_html_flags; /* Colors should apply globally */ - GdkColor colors[E_MAIL_FORMATTER_NUM_COLOR_TYPES]; + GdkRGBA colors[E_MAIL_FORMATTER_NUM_COLOR_TYPES]; /* sizeof(EMailFormatterContext) or some derivative struct */ gsize context_size; @@ -120,9 +120,8 @@ struct _EMailFormatterClass { CamelStream *stream, GCancellable *cancellable); - void (*set_style) (EMailFormatter *formatter, - GtkStyle *style, - GtkStateType state); + void (*update_style) (EMailFormatter *formatter, + GtkStateFlags state); /* Signals */ void (*need_redraw) (EMailFormatter *formatter); @@ -175,15 +174,14 @@ CamelMimeFilterToHTMLFlags e_mail_formatter_get_text_format_flags (EMailFormatter *formatter); -const GdkColor * +const GdkRGBA * e_mail_formatter_get_color (EMailFormatter *formatter, EMailFormatterColorType type); void e_mail_formatter_set_color (EMailFormatter *efh, EMailFormatterColorType type, - const GdkColor *color); -void e_mail_formatter_set_style (EMailFormatter *formatter, - GtkStyle *style, - GtkStateType state); + const GdkRGBA *color); +void e_mail_formatter_update_style (EMailFormatter *formatter, + GtkStateFlags state); EMailImageLoadingPolicy e_mail_formatter_get_image_loading_policy |