From f1c03de09dfda7052753b86a78bc22f87ca039a1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 10 Aug 2010 18:38:10 -0400 Subject: Bug 271691 - Add a way to view all attachments inline --- mail/em-format-html-display.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'mail') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index d49d797de4..b2661b67c0 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -744,31 +744,24 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF /* ********************************************************************** */ -/* Checks on the widget whether it can be processed, based on the - * state of EMFormatHTML. The widget should have set "efh" data as - * the EMFormatHTML instance. */ -static gboolean -efhd_can_process_attachment (GtkWidget *button) +static void +efhd_attachment_button_expanded (EAttachmentButton *button, + GParamSpec *pspec, + struct _attach_puri *info) { EMFormatHTML *efh; - if (!button) - return FALSE; - + /* FIXME The PURI struct seems to have some lifecycle issues, + * because casting info->puri.format to an EMFormatHTML + * can lead to crashes. So we hack around it. */ efh = g_object_get_data (G_OBJECT (button), "efh"); + g_return_if_fail (EM_IS_FORMAT_HTML (efh)); - return efh && efh->state != EM_FORMAT_HTML_STATE_RENDERING; -} - -static void -efhd_attachment_button_expanded (GtkWidget *widget, - GParamSpec *pspec, - struct _attach_puri *info) -{ - if (!efhd_can_process_attachment (widget)) + if (efh->state == EM_FORMAT_HTML_STATE_RENDERING) return; - info->shown = ~info->shown; + info->shown = e_attachment_button_get_expanded (button); + em_format_set_inline ( info->puri.format, info->puri.part_id, info->shown); } @@ -848,6 +841,10 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje gtk_container_add (GTK_CONTAINER (eb), widget); gtk_widget_show (widget); + /* FIXME Not sure why the expanded callback can't just use + * info->puri.format, but there seems to be lifecycle + * issues with the PURI struct. Maybe it should have + * a reference count? */ g_object_set_data (G_OBJECT (widget), "efh", efh); g_signal_connect ( -- cgit v1.2.3