From a456ef68fd8cb97faa2fc0f0ecf6341aec2dcc1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Thu, 2 Aug 2012 11:11:04 +0200 Subject: Bug #680666 - Contacts/Tasks/Memos preview pane does not follow theme colors --- addressbook/gui/widgets/eab-contact-display.c | 11 +++ addressbook/gui/widgets/eab-contact-formatter.c | 113 +++++++++++++++++++++--- addressbook/gui/widgets/eab-contact-formatter.h | 11 +++ 3 files changed, 123 insertions(+), 12 deletions(-) (limited to 'addressbook') 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" \ "\n" \ -"\n" \ "\n" static gboolean @@ -773,7 +768,12 @@ render_normal (EABContactFormatter *formatter, GString *buffer) { g_string_append (buffer, HTML_HEADER); - g_string_append (buffer, ""); + g_string_append_printf ( + buffer, "", + 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 @@ -1215,6 +1255,55 @@ eab_contact_formatter_get_render_maps (EABContactFormatter *formatter) return formatter->priv->render_maps; } +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, 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); -- cgit v1.2.3