[evolution] Bug 626453 - Show attachments inline when printing



commit 221c841d423c567f3bfb8b12ea039d7e932fdefa
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Aug 10 06:01:18 2010 -0400

    Bug 626453 - Show attachments inline when printing

 em-format/em-format.c       |   60 ++++++++++++++++++++++++++++++-------------
 em-format/em-format.h       |   11 +++++--
 mail/em-format-html-print.c |   14 ++++++++++
 3 files changed, 64 insertions(+), 21 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index a323c56..74bcb31 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -117,6 +117,35 @@ emf_finalize (GObject *object)
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+static gboolean
+emf_is_inline (EMFormat *emf,
+               const gchar *part_id,
+               CamelMimePart *mime_part,
+               const EMFormatHandler *handle)
+{
+	struct _EMFormatCache *emfc;
+	const gchar *disposition;
+
+	if (handle == NULL)
+		return FALSE;
+
+	emfc = g_hash_table_lookup (emf->inline_table, part_id);
+	if (emfc && emfc->state != INLINE_UNSET)
+		return emfc->state & 1;
+
+	/* Some types need to override the disposition.
+	 * e.g. application/x-pkcs7-mime */
+	if (handle->flags & EM_FORMAT_HANDLER_INLINE_DISPOSITION)
+		return TRUE;
+
+	disposition = camel_mime_part_get_disposition (mime_part);
+	if (disposition != NULL)
+		return g_ascii_strcasecmp (disposition, "inline") == 0;
+
+	/* Otherwise, use the default for this handler type. */
+	return (handle->flags & EM_FORMAT_HANDLER_INLINE) != 0;
+}
+
 static void
 emf_base_init (EMFormatClass *class)
 {
@@ -138,6 +167,7 @@ emf_class_init (EMFormatClass *class)
 	class->format_clone = emf_format_clone;
 	class->format_secure = emf_format_secure;
 	class->busy = emf_busy;
+	class->is_inline = emf_is_inline;
 
 	signals[EMF_COMPLETE] = g_signal_new (
 		"complete",
@@ -1040,28 +1070,22 @@ gint em_format_is_attachment(EMFormat *emf, CamelMimePart *part)
  *
  * Return value:
  **/
-gint em_format_is_inline(EMFormat *emf, const gchar *partid, CamelMimePart *part, const EMFormatHandler *handle)
+gboolean
+em_format_is_inline (EMFormat *emf,
+                     const gchar *part_id,
+                     CamelMimePart *mime_part,
+                     const EMFormatHandler *handle)
 {
-	struct _EMFormatCache *emfc;
-	const gchar *tmp;
-
-	if (handle == NULL)
-		return FALSE;
-
-	emfc = g_hash_table_lookup(emf->inline_table, partid);
-	if (emfc && emfc->state != INLINE_UNSET)
-		return emfc->state & 1;
+	EMFormatClass *class;
 
-	/* some types need to override the disposition, e.g. application/x-pkcs7-mime */
-	if (handle->flags & EM_FORMAT_HANDLER_INLINE_DISPOSITION)
-		return TRUE;
+	g_return_val_if_fail (EM_IS_FORMAT (emf), FALSE);
+	g_return_val_if_fail (part_id != NULL, FALSE);
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), FALSE);
 
-	tmp = camel_mime_part_get_disposition(part);
-	if (tmp)
-		return g_ascii_strcasecmp(tmp, "inline") == 0;
+	class = EM_FORMAT_GET_CLASS (emf);
+	g_return_val_if_fail (class->is_inline != NULL, FALSE);
 
-	/* otherwise, use the default for this handler type */
-	return (handle->flags & EM_FORMAT_HANDLER_INLINE) != 0;
+	return class->is_inline (emf, part_id, mime_part, handle);
 }
 
 /**
diff --git a/em-format/em-format.h b/em-format/em-format.h
index 965ca20..5ae0e7f 100644
--- a/em-format/em-format.h
+++ b/em-format/em-format.h
@@ -251,6 +251,11 @@ struct _EMFormatClass {
 	/* Shows optional way to open messages  */
 	void (*format_optional)(EMFormat *, CamelStream *, CamelMimePart *, CamelStream* );
 
+	gboolean	(*is_inline)		(EMFormat *emf,
+						 const gchar *part_id,
+						 CamelMimePart *mime_part,
+						 const EMFormatHandler *handle);
+
 	/* signals */
 	/* complete, alternative to polling busy, for asynchronous work */
 	void (*complete)(EMFormat *);
@@ -277,9 +282,9 @@ void		em_format_add_header		(EMFormat *emf,
 gint		em_format_is_attachment		(EMFormat *emf,
 						 CamelMimePart *part);
 
-gint		em_format_is_inline		(EMFormat *emf,
-						 const gchar *partid,
-						 CamelMimePart *part,
+gboolean	em_format_is_inline		(EMFormat *emf,
+						 const gchar *part_id,
+						 CamelMimePart *mime_part,
 						 const EMFormatHandler *handle);
 void		em_format_set_inline		(EMFormat *emf,
 						 const gchar *partid,
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index e660602..f7eb288 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -50,15 +50,29 @@ efhp_finalize (GObject *object)
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+static gboolean
+efhp_is_inline (EMFormat *emf,
+                const gchar *part_id,
+                CamelMimePart *mime_part,
+                const EMFormatHandler *handle)
+{
+	/* When printing, inline any part that has a handler. */
+	return (handle != NULL);
+}
+
 static void
 efhp_class_init (EMFormatHTMLPrintClass *class)
 {
 	GObjectClass *object_class;
+	EMFormatClass *format_class;
 
 	parent_class = g_type_class_peek_parent (class);
 
 	object_class = G_OBJECT_CLASS (class);
 	object_class->finalize = efhp_finalize;
+
+	format_class = EM_FORMAT_CLASS (class);
+	format_class->is_inline = efhp_is_inline;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]