diff options
author | Peter Williams <peterw@ximian.com> | 2001-07-11 02:05:25 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2001-07-11 02:05:25 +0800 |
commit | 6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8 (patch) | |
tree | 245c07e855aa79cbb776c288d96de8eeb5834fa8 /mail/mail-format.c | |
parent | 7c200467e52ab6e1210788f97a057f85840a0d56 (diff) | |
download | gsoc2013-evolution-6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8.tar.gz gsoc2013-evolution-6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8.tar.zst gsoc2013-evolution-6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8.zip |
Took the logic of whether or not to make the attachment header out of the
2001-07-10 Peter Williams <peterw@ximian.com>
* mail-format.c (attachment_header): Took the logic of whether or not
to make the attachment header out of the actual function.
(mail_part_is_displayed_inline): Return if the part is being displayed
inline (regardless of whether it is actually inline).
(mail_part_toggle_displayed): Toggle whether it's displayed inline or not.
(get_inline_flags): Determine whether the part is displayed inline and whether
it is actually inline.
(mail_format_mime_message): Initialize the attachment_status hash table.
* mail-display.c (inline_cb): Instead of modifying the CamelMimePart,
use mail_part_toggle_displayed
(button_press): As above.
(pixmap_press): Use mail_part_is_displayed_inline instead of
mail_part_is_inline. Get the MailDisplay from the popup to do this.
* mail.h: Add prototypes.
svn path=/trunk/; revision=10960
Diffstat (limited to 'mail/mail-format.c')
-rw-r--r-- | mail/mail-format.c | 90 |
1 files changed, 80 insertions, 10 deletions
diff --git a/mail/mail-format.c b/mail/mail-format.c index fb0218659c..7bd1a84a8a 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -169,6 +169,14 @@ mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md) free_data_urls); } + /* ok, so they're not urls. so sue me. */ + urls = g_datalist_get_data (md->data, "attachment_states"); + if (!urls) { + urls = g_hash_table_new (g_direct_hash, g_direct_equal); + g_datalist_set_data_full (md->data, "attachment_states", urls, + (GDestroyNotify) g_hash_table_destroy); + } + write_headers (mime_message, md); format_mime_part (CAMEL_MIME_PART (mime_message), md); } @@ -512,17 +520,74 @@ mail_part_is_inline (CamelMimePart *part) return anon; } +enum inline_states { + I_VALID = (1 << 0), + I_ACTUALLY = (1 << 1), + I_DISPLAYED = (1 << 2) +}; + +static gint +get_inline_flags (CamelMimePart *part, MailDisplay *md) +{ + GHashTable *asht; + gint val; + + /* check if we already know. */ + + asht = g_datalist_get_data (md->data, "attachment_states"); + val = GPOINTER_TO_INT (g_hash_table_lookup (asht, part)); + if (val) + return val; + + /* ok, we don't know. Figure it out. */ + + if (mail_part_is_inline (part)) + val = (I_VALID | I_ACTUALLY | I_DISPLAYED); + else + val = (I_VALID); + + g_hash_table_insert (asht, part, GINT_TO_POINTER (val)); + + return val; +} + +gboolean +mail_part_is_displayed_inline (CamelMimePart *part, MailDisplay *md) +{ + return (gboolean) (get_inline_flags (part, md) & I_DISPLAYED); +} + +void +mail_part_toggle_displayed (CamelMimePart *part, MailDisplay *md) +{ + GHashTable *asht = g_datalist_get_data (md->data, "attachment_states"); + gint state; + + state = GPOINTER_TO_INT (g_hash_table_lookup (asht, part)); + + if (state & I_DISPLAYED) { + /*printf ("** part %p, hiding\n", part);*/ + state &= ~I_DISPLAYED; + } else { + if (state == 0) { + /*printf ("** part %p: uninitialized attachment state! Showing.", part);*/ + state |= I_VALID; + } + + printf ("** part %p, showing\n", part); + state |= I_DISPLAYED; + } + + g_hash_table_insert (asht, part, GINT_TO_POINTER (state)); +} + + static void -attachment_header (CamelMimePart *part, const char *mime_type, - gboolean is_inline, MailDisplay *md) +attachment_header (CamelMimePart *part, const char *mime_type, MailDisplay *md) { const char *info; char *htmlinfo; - /* No header for anonymous inline parts. */ - if (is_inline && is_anonymous (part, mime_type)) - return; - /* Start the table, create the pop-up object. */ mail_html_write (md->html, md->stream, "<table cellspacing=0 cellpadding=0>" @@ -573,7 +638,8 @@ format_mime_part (CamelMimePart *part, MailDisplay *md) CamelDataWrapper *wrapper; char *mime_type; MailMimeHandler *handler; - gboolean output, is_inline; + gboolean output; + int inline_flags; /* Record URLs associated with this part */ get_cid (part, md); @@ -613,9 +679,13 @@ format_mime_part (CamelMimePart *part, MailDisplay *md) } } - is_inline = mail_part_is_inline (part); - attachment_header (part, mime_type, is_inline, md); - if (handler && handler->builtin && is_inline && + inline_flags = get_inline_flags (part, md); + + /* No header for anonymous inline parts. */ + if (!((inline_flags & I_ACTUALLY) && is_anonymous (part, mime_type))) + attachment_header (part, mime_type, md); + + if (handler && handler->builtin && inline_flags & I_DISPLAYED && mail_content_loaded (wrapper, md)) output = (*handler->builtin) (part, mime_type, md); else |