diff options
author | Dan Vrátil <dvratil@redhat.com> | 2012-08-02 17:11:04 +0800 |
---|---|---|
committer | Dan Vrátil <dvratil@redhat.com> | 2012-08-02 17:11:41 +0800 |
commit | a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d (patch) | |
tree | 46b3517ae056c5d4c600b3bf6bf3c1321966c1de | |
parent | 9c2a94b367553d79add31c3beea0a86df2ff1f1d (diff) | |
download | gsoc2013-evolution-a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d.tar gsoc2013-evolution-a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d.tar.gz gsoc2013-evolution-a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d.tar.bz2 gsoc2013-evolution-a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d.tar.lz gsoc2013-evolution-a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d.tar.xz gsoc2013-evolution-a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d.tar.zst gsoc2013-evolution-a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d.zip |
Bug #680666 - Contacts/Tasks/Memos preview pane does not follow theme colors
-rw-r--r-- | addressbook/gui/widgets/eab-contact-display.c | 11 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-contact-formatter.c | 113 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-contact-formatter.h | 11 | ||||
-rw-r--r-- | calendar/gui/e-cal-component-preview.c | 79 | ||||
-rw-r--r-- | mail/e-mail-display.c | 20 | ||||
-rw-r--r-- | widgets/misc/e-web-view.c | 11 |
6 files changed, 202 insertions, 43 deletions
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c index 2c9912fa65..6501bccc24 100644 --- a/addressbook/gui/widgets/eab-contact-display.c +++ b/addressbook/gui/widgets/eab-contact-display.c @@ -183,6 +183,10 @@ contact_formatting_finished (GObject *object, GByteArray *ba; stream = g_simple_async_result_get_op_res_gpointer (result); + /* The operation was probably cancelled */ + if (!stream) + return; + ba = camel_stream_mem_get_byte_array (stream); html = g_strndup ((gchar *) ba->data, ba->len); @@ -212,6 +216,11 @@ load_contact (EABContactDisplay *display) formatter = eab_contact_formatter_new ( display->priv->mode, display->priv->show_maps); + g_object_set ( + G_OBJECT (formatter), + "style", gtk_widget_get_style (GTK_WIDGET (display)), + "state", gtk_widget_get_state (GTK_WIDGET (display)), + NULL); display->priv->formatter_cancellable = g_cancellable_new (); @@ -549,6 +558,8 @@ eab_contact_display_init (EABContactDisplay *display) #endif g_signal_connect (web_view, "notify::load-status", G_CALLBACK (contact_display_load_status_changed), NULL); + g_signal_connect (web_view, "style-set", + G_CALLBACK (load_contact), NULL); e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_FILE_REQUEST); e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_STOCK_REQUEST); diff --git a/addressbook/gui/widgets/eab-contact-formatter.c b/addressbook/gui/widgets/eab-contact-formatter.c index ce6825aa9d..5b3021cc6c 100644 --- a/addressbook/gui/widgets/eab-contact-formatter.c +++ b/addressbook/gui/widgets/eab-contact-formatter.c @@ -49,7 +49,9 @@ G_DEFINE_TYPE ( enum { PROP_0, PROP_DISPLAY_MODE, - PROP_RENDER_MAPS + PROP_RENDER_MAPS, + PROP_STYLE, + PROP_STATE }; struct _EABContactFormatterPrivate { @@ -58,6 +60,9 @@ struct _EABContactFormatterPrivate { EABContactDisplayMode mode; gboolean render_maps; + + GtkStyle *style; + GtkStateType state; }; static struct { @@ -97,16 +102,6 @@ common_location[] = " img#contact-photo { float: left; }\n" \ " div#contact-name { float: left; margin-left: 20px; }\n" \ "</style>\n" \ -"<script type=\"text/javascript\">\n" \ -"function collapse_list (obj, listId) {\n" \ -" var l = document.getElementById (listId);\n" \ -" if (l.style.display == \"none\") {\n" \ -" l.style.display = \"block\"; obj.src = obj.src.substr (0, obj.src.lastIndexOf (\"/\")) + \"/minus.png\";\n" \ -" } else {\n" \ -" l.style.display = \"none\"; obj.src = obj.src.substr (0, obj.src.lastIndexOf (\"/\")) + \"/plus.png\";\n" \ -" }\n" \ -"}\n" \ -"</script>\n" \ "</head>\n" static gboolean @@ -773,7 +768,12 @@ render_normal (EABContactFormatter *formatter, GString *buffer) { g_string_append (buffer, HTML_HEADER); - g_string_append (buffer, "<body>"); + g_string_append_printf ( + buffer, "<body bgcolor=\"#%06x\" text=\"#%06x\">", + e_color_to_value ( + &formatter->priv->style->base[formatter->priv->state]), + e_color_to_value ( + &formatter->priv->style->text[formatter->priv->state])); if (formatter->priv->contact) { @@ -1070,6 +1070,14 @@ eab_contact_formatter_set_property (GObject *object, eab_contact_formatter_set_render_maps ( formatter, g_value_get_boolean (value)); return; + case PROP_STYLE: + eab_contact_formatter_set_style ( + formatter, g_value_get_object (value)); + return; + case PROP_STATE: + eab_contact_formatter_set_state ( + formatter, g_value_get_uint (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1094,6 +1102,16 @@ eab_contact_formatter_get_property (GObject *object, eab_contact_formatter_get_render_maps ( formatter)); return; + case PROP_STYLE: + g_value_set_object (value, + eab_contact_formatter_get_style ( + formatter)); + return; + case PROP_STATE: + g_value_set_uint (value, + eab_contact_formatter_get_state ( + formatter)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1147,6 +1165,28 @@ eab_contact_formatter_class_init (EABContactFormatterClass *class) "", FALSE, G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_STYLE, + g_param_spec_object ( + "style", + NULL, + NULL, + GTK_TYPE_STYLE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property ( + object_class, + PROP_STATE, + g_param_spec_uint ( + "state", + NULL, + NULL, + 0, + G_MAXUINT, + 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } static void @@ -1216,6 +1256,55 @@ eab_contact_formatter_get_render_maps (EABContactFormatter *formatter) } void +eab_contact_formatter_set_style (EABContactFormatter *formatter, + GtkStyle *style) +{ + g_return_if_fail (EAB_IS_CONTACT_FORMATTER (formatter)); + + if (formatter->priv->style == style) { + return; + } + + g_clear_object (&formatter->priv->style); + + if (style != NULL) { + formatter->priv->style = g_object_ref (style); + } + + g_object_notify (G_OBJECT (formatter), "style"); +} + +GtkStyle * +eab_contact_formatter_get_style (EABContactFormatter *formatter) +{ + g_return_val_if_fail (EAB_IS_CONTACT_FORMATTER (formatter), NULL); + + return formatter->priv->style; +} + +void +eab_contact_formatter_set_state (EABContactFormatter *formatter, + GtkStateType state) +{ + g_return_if_fail (EAB_IS_CONTACT_FORMATTER (formatter)); + + if (formatter->priv->state == state) + return; + + formatter->priv->state = state; + + g_object_notify (G_OBJECT (formatter), "state"); +} + +GtkStateType +eab_contact_formatter_get_state (EABContactFormatter *formatter) +{ + g_return_val_if_fail (EAB_IS_CONTACT_FORMATTER (formatter), 0); + + return formatter->priv->state; +} + +void eab_contact_formatter_format_contact_sync (EABContactFormatter *formatter, EContact *contact, CamelStream *stream, diff --git a/addressbook/gui/widgets/eab-contact-formatter.h b/addressbook/gui/widgets/eab-contact-formatter.h index 7348f89f0c..4773a7bb24 100644 --- a/addressbook/gui/widgets/eab-contact-formatter.h +++ b/addressbook/gui/widgets/eab-contact-formatter.h @@ -62,6 +62,17 @@ EABContactFormatter* eab_contact_formatter_new (EABContactDisplayMode mode, gboolean render_maps); +void eab_contact_formatter_set_style + (EABContactFormatter *formatter, + GtkStyle *context); +GtkStyle* + eab_contact_formatter_get_style + (EABContactFormatter *formatter); + +void eab_contact_formatter_set_state (EABContactFormatter *formatter, + GtkStateType state); +GtkStateType eab_contact_formatter_get_state (EABContactFormatter *formatter); + void eab_contact_formatter_set_render_maps (EABContactFormatter *formatter, gboolean render_maps); diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c index 0cd65b0cd1..0eef0d2a64 100644 --- a/calendar/gui/e-cal-component-preview.c +++ b/calendar/gui/e-cal-component-preview.c @@ -52,6 +52,11 @@ struct _ECalComponentPreviewPrivate { gchar *comp_uid; struct icaltimetype comp_last_modified; gint comp_sequence; + + ECalClient *client; + ECalComponent *comp; + icaltimezone *timezone; + gboolean use_24_hour_format; }; #define HTML_HEADER "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n" \ @@ -77,6 +82,13 @@ clear_comp_info (ECalComponentPreview *preview) priv->comp_uid = NULL; priv->comp_last_modified = icaltime_null_time (); priv->comp_sequence = -1; + + g_clear_object (&priv->client); + g_clear_object (&priv->comp); + if (priv->timezone) { + icaltimezone_free (priv->timezone, 1); + priv->timezone = NULL; + } } /* Stores information about actually shown component and @@ -84,7 +96,9 @@ clear_comp_info (ECalComponentPreview *preview) static gboolean update_comp_info (ECalComponentPreview *preview, ECalClient *client, - ECalComponent *comp) + ECalComponent *comp, + icaltimezone *zone, + gboolean use_24_hour_format) { ECalComponentPreviewPrivate *priv; gboolean changed; @@ -135,6 +149,11 @@ update_comp_info (ECalComponentPreview *preview, priv->comp_uid = comp_uid; priv->comp_sequence = comp_sequence; priv->comp_last_modified = comp_last_modified; + + priv->comp = g_object_ref (comp); + priv->client = g_object_ref (client); + priv->timezone = icaltimezone_copy (zone); + priv->use_24_hour_format = use_24_hour_format; } return changed; @@ -175,12 +194,13 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, } static void -cal_component_preview_write_html (GString *buffer, - ECalClient *client, - ECalComponent *comp, - icaltimezone *default_zone, - gboolean use_24_hour_format) +cal_component_preview_write_html (ECalComponentPreview *preview, + GString *buffer) { + ECalClient *client; + ECalComponent *comp; + icaltimezone *default_zone; + gboolean use_24_hour_format; ECalComponentText text; ECalComponentDateTime dt; gchar *str; @@ -191,14 +211,25 @@ cal_component_preview_write_html (GString *buffer, icalproperty_status status; const gchar *location; gint *priority_value; + GtkStyle *style; + GtkStateType state; - g_return_if_fail (E_IS_CAL_COMPONENT (comp)); + client = preview->priv->client; + comp = preview->priv->comp; + default_zone = preview->priv->timezone; + use_24_hour_format = preview->priv->use_24_hour_format; /* write document header */ e_cal_component_get_summary (comp, &text); + style = gtk_widget_get_style (GTK_WIDGET (preview)); + state = gtk_widget_get_state (GTK_WIDGET (preview)); + g_string_append (buffer, HTML_HEADER); - g_string_append (buffer, "<body>"); + g_string_append_printf ( + buffer, "<body bgcolor=\"#%06x\" text=\"#%06x\">", + e_color_to_value (&style->base[state]), + e_color_to_value (&style->text[state])); if (text.value) g_string_append_printf (buffer, "<h2>%s</h2>", text.value); @@ -373,6 +404,23 @@ cal_component_preview_write_html (GString *buffer, } static void +load_comp (ECalComponentPreview *preview) +{ + GString *buffer; + + if (!preview->priv->comp) { + e_cal_component_preview_clear (preview); + return; + } + + + buffer = g_string_sized_new (4096); + cal_component_preview_write_html (preview, buffer); + e_web_view_load_string (E_WEB_VIEW (preview), buffer->str); + g_string_free (buffer, TRUE); +} + +static void cal_component_preview_finalize (GObject *object) { clear_comp_info (E_CAL_COMPONENT_PREVIEW (object)); @@ -396,6 +444,9 @@ static void e_cal_component_preview_init (ECalComponentPreview *preview) { preview->priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (preview); + + g_signal_connect (preview, "style-set", + G_CALLBACK (load_comp), NULL); } GtkWidget * @@ -411,23 +462,15 @@ e_cal_component_preview_display (ECalComponentPreview *preview, icaltimezone *zone, gboolean use_24_hour_format) { - GString *buffer; - g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview)); g_return_if_fail (E_IS_CAL_COMPONENT (comp)); /* do not update preview when setting the same component as last time, * which even didn't change */ - if (!update_comp_info (preview, client, comp)) + if (!update_comp_info (preview, client, comp, zone, use_24_hour_format)) return; - /* XXX The initial buffer size is arbitrary. Tune it. */ - - buffer = g_string_sized_new (4096); - cal_component_preview_write_html ( - buffer, client, comp, zone, use_24_hour_format); - e_web_view_load_string (E_WEB_VIEW (preview), buffer->str); - g_string_free (buffer, TRUE); + load_comp (preview); } void diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index 57666ea5e8..a80ece630c 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -1802,13 +1802,16 @@ void e_mail_display_set_status (EMailDisplay *display, const gchar *status) { - gchar *str, *header; + gchar *str; g_return_if_fail (E_IS_MAIL_DISPLAY (display)); - header = e_mail_formatter_get_html_header (display->priv->formatter); str = g_strdup_printf ( - "%s\n" + "<!DOCTYPE HTML>\n<html>\n" + "<head>\n<meta name=\"generator\" content=\"Evolution Mail Component\" />\n" + "<title>Evolution Mail Display</title>\n" + "</head>\n" + "<body bgcolor=\"#%06x\" text=\"#%06x\">" " <style>html, body { height: 100%%; }</style>\n" " <table border=\"0\" width=\"100%%\" height=\"100%%\">\n" " <tr height=\"100%%\" valign=\"middle\">\n" @@ -1819,8 +1822,15 @@ e_mail_display_set_status (EMailDisplay *display, " </table>\n" "</body>\n" "</html>\n", - header, status); - g_free (header); + e_color_to_value ((GdkColor *) + e_mail_formatter_get_color ( + display->priv->formatter, + E_MAIL_FORMATTER_COLOR_CONTENT)), + e_color_to_value ((GdkColor *) + e_mail_formatter_get_color ( + display->priv->formatter, + E_MAIL_FORMATTER_COLOR_TEXT)), + status); e_web_view_load_string (E_WEB_VIEW (display), str); g_free (str); diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c index e24621e711..bb755b134c 100644 --- a/widgets/misc/e-web-view.c +++ b/widgets/misc/e-web-view.c @@ -1875,21 +1875,16 @@ e_web_view_new (void) void e_web_view_clear (EWebView *web_view) { - GtkStyleContext *style_context; - GtkStateFlags state_flags; - GdkRGBA rgba; + GtkStyle *style; gchar *html; g_return_if_fail (E_IS_WEB_VIEW (web_view)); - style_context = gtk_widget_get_style_context (GTK_WIDGET (web_view)); - state_flags = gtk_widget_get_state_flags (GTK_WIDGET (web_view)); - gtk_style_context_get_background_color ( - style_context, state_flags, &rgba); + style = gtk_widget_get_style (GTK_WIDGET (web_view)); html = g_strdup_printf ( "<html><head></head><body bgcolor=\"#%06x\"></body></html>", - e_rgba_to_value (&rgba)); + e_color_to_value (&style->base[GTK_STATE_NORMAL])); webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (web_view), html, NULL); |