aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorPeter Williams <peterw@ximian.com>2001-07-11 02:05:25 +0800
committerPeter Williams <peterw@src.gnome.org>2001-07-11 02:05:25 +0800
commit6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8 (patch)
tree245c07e855aa79cbb776c288d96de8eeb5834fa8 /mail
parent7c200467e52ab6e1210788f97a057f85840a0d56 (diff)
downloadgsoc2013-evolution-6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8.tar
gsoc2013-evolution-6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8.tar.gz
gsoc2013-evolution-6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8.tar.bz2
gsoc2013-evolution-6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8.tar.lz
gsoc2013-evolution-6079b3a3457d5f6a0a9b02e7db6a58f4ff9b0bc8.tar.xz
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')
-rw-r--r--mail/ChangeLog19
-rw-r--r--mail/mail-display.c19
-rw-r--r--mail/mail-format.c90
-rw-r--r--mail/mail.h2
4 files changed, 108 insertions, 22 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index f9a6484118..7852d7fb96 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,22 @@
+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.
+
2001-07-10 JP Rosevear <jpr@ximian.com>
* Makefile.am: extra dist the news files
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 9eda71b942..00212c8868 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -311,11 +311,7 @@ inline_cb (GtkWidget *widget, gpointer user_data)
MailDisplay *md = gtk_object_get_data (user_data, "MailDisplay");
CamelMimePart *part = gtk_object_get_data (user_data, "CamelMimePart");
- if (mail_part_is_inline (part))
- camel_mime_part_set_disposition (part, "attachment");
- else
- camel_mime_part_set_disposition (part, "inline");
-
+ mail_part_toggle_displayed (part, md);
mail_display_queue_redisplay (md);
}
@@ -330,11 +326,7 @@ button_press (GtkWidget *widget, CamelMimePart *part)
return;
}
- if (mail_part_is_inline (part))
- camel_mime_part_set_disposition (part, "attachment");
- else
- camel_mime_part_set_disposition (part, "inline");
-
+ mail_part_toggle_displayed (part, md);
mail_display_queue_redisplay (md);
}
@@ -348,6 +340,7 @@ pixmap_press (GtkWidget *widget, GdkEventButton *event, EScrollFrame *user_data)
GTK_SIGNAL_FUNC (inline_cb), NULL, 2 };
EPopupMenu open_item = { N_("Open in %s..."), NULL,
GTK_SIGNAL_FUNC (launch_cb), NULL, 1 };
+ MailDisplay *md;
CamelMimePart *part;
MailMimeHandler *handler;
int mask = 0, i, nitems;
@@ -383,7 +376,9 @@ pixmap_press (GtkWidget *widget, GdkEventButton *event, EScrollFrame *user_data)
/* Inline view item */
memcpy (&menu[1], &view_item, sizeof (menu[1]));
if (handler && handler->builtin) {
- if (!mail_part_is_inline (part)) {
+ md = gtk_object_get_data (GTK_OBJECT (widget), "MailDisplay");
+
+ if (!mail_part_is_displayed_inline (part, md)) {
if (handler->component) {
OAF_Property *prop;
char *name;
@@ -833,7 +828,7 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
- if (mail_part_is_inline (CAMEL_MIME_PART (medium))) {
+ if (mail_part_is_displayed_inline (CAMEL_MIME_PART (medium), md)) {
arrow = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_DOWN);
} else {
arrow = gnome_stock_new_with_icon (GNOME_STOCK_PIXMAP_FORWARD);
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
diff --git a/mail/mail.h b/mail/mail.h
index f9bcdc7d79..b8254591c9 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -54,6 +54,8 @@ typedef struct {
MailMimeHandler *mail_lookup_handler (const char *mime_type);
gboolean mail_part_is_inline (CamelMimePart *part);
+gboolean mail_part_is_displayed_inline (CamelMimePart *part, MailDisplay *md);
+void mail_part_toggle_displayed (CamelMimePart *part, MailDisplay *md);
char *mail_get_message_body (CamelDataWrapper *data, gboolean want_plain,
gboolean *is_html);