diff options
-rw-r--r-- | mail/ChangeLog | 46 | ||||
-rw-r--r-- | mail/component-factory.c | 1 | ||||
-rw-r--r-- | mail/folder-browser.c | 11 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 13 | ||||
-rw-r--r-- | mail/mail-display.c | 130 | ||||
-rw-r--r-- | mail/mail-display.h | 10 | ||||
-rw-r--r-- | mail/mail-format.c | 71 | ||||
-rw-r--r-- | mail/mail-ops.c | 2 | ||||
-rw-r--r-- | mail/message-tag-editor.c | 6 | ||||
-rw-r--r-- | mail/message-tag-followup.c | 8 |
10 files changed, 210 insertions, 88 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 1c925d358d..53657bf740 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,49 @@ +2002-04-03 Jeffrey Stedfast <fejj@ximian.com> + + * message-tag-followup.c (construct): Set the window title/icon + here instead. + + * message-tag-editor.c (message_tag_editor_init): Don't set the + title or window icon here, this is a generic class. + + * mail-format.c (handle_multipart_signed): Replace + get_url_for_icon with the new mail_display_get_url_for_icon + function. + (handle_multipart_digest): Here too. + (get_cid): Use mail_display_add_url instead. + (get_location): Same. + (handle_text_enriched): Here too. + (handle_multipart_signed): And here. + + * message-tag-followup.c (message_tag_followup_i18n_name): Use the + U_() macro, not the _() macro as it is what we really want. + + * mail-ops.c (mail_send_message): Don't cast the message into a + CamelMedium before sending anymore. + + * mail-callbacks.c (expunge_folder): Set the followup argument to + NULL here. + (done_message_selected): Get the followup value here and pass it + to the mail-display here. + (do_mail_fetch_and_print): Again with the NULL followup here. + + * folder-browser.c (folder_browser_set_message_preview): Update to + pass in NULL as the followup since we are setting the message to + NULL here. + (done_message_selected): Get and set the appropriate followup + value here. + (do_message_selected): Update to pass in NULL as the followup + since we are setting the message to NULL here. + + * mail-display.c (mail_display_set_message): Now takes a followup + tag value. + (mail_display_init): Set md->followup to NULL. + (mail_display_destroy): Free md->followup. + (mail_display_add_url): New: replaces the static add_url function + originally in mail-format.c + (mail_display_get_url_for_icon): New: replaces get_url_for_icon + which was originally in mail-format.c + 2002-04-03 Dan Winship <danw@ximian.com> * mail-account-gui.c: Changes to allow combined store/transport diff --git a/mail/component-factory.c b/mail/component-factory.c index 4be91c720c..c1a8c096ac 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -39,6 +39,7 @@ #include "folder-browser.h" #include "mail.h" #include "mail-config.h" +#include "mail-config-factory.h" #include "mail-tools.h" #include "mail-ops.h" #include "mail-offline-handler.h" diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 17136f2bc8..6d653b99eb 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -1065,7 +1065,7 @@ folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show } else { e_paned_set_position (E_PANED (folder_browser->vpaned), 10000); gtk_widget_hide (GTK_WIDGET (folder_browser->mail_display)); - mail_display_set_message(folder_browser->mail_display, NULL); + mail_display_set_message (folder_browser->mail_display, NULL, NULL); folder_browser_ui_message_loaded(folder_browser); } } @@ -2244,12 +2244,15 @@ done_message_selected (CamelFolder *folder, char *uid, CamelMimeMessage *msg, vo { FolderBrowser *fb = data; int timeout = mail_config_get_mark_as_seen_timeout (); + const char *followup; if (folder != fb->folder || fb->mail_display == NULL) return; - mail_display_set_message (fb->mail_display, (CamelMedium *)msg); - + followup = camel_folder_get_message_user_tag (folder, uid, "follow-up"); + + mail_display_set_message (fb->mail_display, (CamelMedium *) msg, followup); + /* FIXME: should this signal be emitted here?? */ gtk_signal_emit (GTK_OBJECT (fb), folder_browser_signals [MESSAGE_LOADED], uid); @@ -2298,7 +2301,7 @@ do_message_selected (FolderBrowser *fb) fb->loading_uid = g_strdup (fb->new_uid); mail_get_message (fb->folder, fb->loading_uid, done_message_selected, fb, mail_thread_new); } else { - mail_display_set_message (fb->mail_display, NULL); + mail_display_set_message (fb->mail_display, NULL, NULL); } } diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 988f8b58f8..2f4f6b695a 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -2649,7 +2649,7 @@ expunge_folder (BonoboUIComponent *uih, void *user_data, const char *path) info = camel_folder_get_message_info (fb->folder, fb->loaded_uid); if (!info || info->flags & CAMEL_MESSAGE_DELETED) - mail_display_set_message (fb->mail_display, NULL); + mail_display_set_message (fb->mail_display, NULL, NULL); } fb->expunging = fb->folder; @@ -2906,11 +2906,14 @@ done_message_selected (CamelFolder *folder, char *uid, CamelMimeMessage *msg, vo struct blarg_this_sucks *blarg = data; FolderBrowser *fb = blarg->fb; gboolean preview = blarg->preview; + const char *followup; g_free (blarg); - - mail_display_set_message (fb->mail_display, (CamelMedium *)msg); - + + followup = camel_folder_get_message_user_tag (folder, uid, "follow-up"); + + mail_display_set_message (fb->mail_display, (CamelMedium *) msg, followup); + g_free (fb->loaded_uid); fb->loaded_uid = fb->loading_uid; fb->loading_uid = NULL; @@ -2941,7 +2944,7 @@ do_mail_fetch_and_print (FolderBrowser *fb, gboolean preview) fb->loading_uid = g_strdup (fb->new_uid); mail_get_message (fb->folder, fb->loading_uid, done_message_selected, blarg, mail_thread_new); } else { - mail_display_set_message (fb->mail_display, NULL); + mail_display_set_message (fb->mail_display, NULL, NULL); g_free (blarg); } } diff --git a/mail/mail-display.c b/mail/mail-display.c index a98f5418ba..e3dbcfc67d 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -46,6 +46,7 @@ #include "e-searching-tokenizer.h" #include "folder-browser-factory.h" #include "mail-stream-gtkhtml.h" +#include "message-tag-followup.h" #include "folder-browser-window.h" #include "folder-browser.h" #include "mail-display.h" @@ -1483,26 +1484,77 @@ clear_data (CamelObject *object, gpointer event_data, gpointer user_data) g_datalist_clear (&data); } + +#define COLOR_IS_LIGHT(r, g, b) ((r + g + b) > (128 * 3)) + void mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) { GtkHTMLStream *stream; - + char bgcolor[7], fontcolor[7]; + GtkStyle *style = NULL; + g_return_if_fail (IS_MAIL_DISPLAY (md)); g_return_if_fail (GTK_IS_HTML (html)); - + stream = gtk_html_begin (html); if (!reset_scroll) { /* This is a hack until there's a clean way to do this. */ GTK_HTML (md->html)->engine->newPage = FALSE; } - + mail_html_write (html, stream, "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n" "<html>\n" "<head>\n<meta name=\"generator\" content=\"Evolution Mail Component\">\n</head>\n"); mail_html_write (html, stream, "<body marginwidth=0 marginheight=0>\n"); + if (md->followup) { + /* my favorite thing to do... muck around with colors so we respect people's stupid themes. */ + style = gtk_widget_get_style (GTK_WIDGET (html)); + if (style && !md->printing) { + int state = GTK_WIDGET_STATE (GTK_WIDGET (html)); + gushort r, g, b; + + r = style->base[state].red / 256; + g = style->base[state].green / 256; + b = style->base[state].blue / 256; + + if (COLOR_IS_LIGHT (r, g, b)) { + r *= 0.92; + g *= 0.92; + b *= 0.92; + } else { + r = 255 - (0.92 * (255 - r)); + g = 255 - (0.92 * (255 - g)); + b = 255 - (0.92 * (255 - b)); + } + + sprintf (bgcolor, "%.2X%.2X%.2X", r, g, b); + + r = style->text[state].red / 256; + g = style->text[state].green / 256; + b = style->text[state].blue / 256; + + sprintf (fontcolor, "%.2X%.2X%.2X", r, g, b); + } else { + strcpy (bgcolor, "EEEEEE"); + strcpy (fontcolor, "000000"); + } + + gtk_html_stream_printf (stream, "<font color=\"#%s\">" + "<table width=\"100%%\" cellspacing=0 cellpading=0><tr><td width=\"100%%\">" + "<table bgcolor=\"#000000\" width=\"100%%\" cellspacing=0 cellpadding=1>" + "<tr><td><table bgcolor=\"#%s\" width=\"100%%\" cellpadding=0 cellspacing=0>" + "<tr>\n", fontcolor, bgcolor); + + gtk_html_stream_printf (stream, "<td><img src=\"%s\"></td><td halign=left><b>%s</b></td>\n", + mail_display_get_url_for_icon (md, EVOLUTION_IMAGES "/flag-for-followup-16.png"), + message_tag_followup_i18n_name (md->followup->type)); + + mail_html_write (html, stream, "</tr></table></tr></table></td></tr></table></font>"); + } + if (md->current_message) { if (md->display_style == MAIL_CONFIG_DISPLAY_SOURCE) mail_format_raw_message (md->current_message, md, html, stream); @@ -1539,25 +1591,30 @@ mail_display_redisplay (MailDisplay *md, gboolean reset_scroll) * mail_display_set_message: * @mail_display: the mail display object * @medium: the input camel medium, or %NULL + * @followup: followup value * * Makes the mail_display object show the contents of the medium * param. **/ void -mail_display_set_message (MailDisplay *md, CamelMedium *medium) +mail_display_set_message (MailDisplay *md, CamelMedium *medium, const char *followup) { /* For the moment, we deal only with CamelMimeMessage, but in * the future, we should be able to deal with any medium. */ if (medium && !CAMEL_IS_MIME_MESSAGE (medium)) return; - + /* Clean up from previous message. */ if (md->current_message) camel_object_unref (CAMEL_OBJECT (md->current_message)); - - md->current_message = (CamelMimeMessage*)medium; - + + g_free (md->followup); + + md->current_message = (CamelMimeMessage *) medium; + + md->followup = followup ? message_tag_followup_decode (followup) : NULL; + g_datalist_init (md->data); mail_display_redisplay (md, TRUE); if (medium) { @@ -1613,6 +1670,7 @@ mail_display_init (GtkObject *object) mail_display->idle_id = 0; mail_display->selection = NULL; mail_display->charset = NULL; + mail_display->followup = NULL; mail_display->current_message = NULL; mail_display->data = NULL; @@ -1630,6 +1688,7 @@ mail_display_destroy (GtkObject *object) g_free (mail_display->charset); g_free (mail_display->selection); + g_free (mail_display->followup); g_datalist_clear (mail_display->data); g_free (mail_display->data); @@ -2274,4 +2333,59 @@ mail_display_initialize_gtkhtml (MailDisplay *mail_display, GtkHTML *html) } +char * +mail_display_add_url (MailDisplay *md, const char *kind, char *url, gpointer data) +{ + GHashTable *urls; + gpointer old_key, old_value; + + urls = g_datalist_get_data (md->data, kind); + g_return_val_if_fail (urls != NULL, NULL); + if (g_hash_table_lookup_extended (urls, url, &old_key, &old_value)) { + g_free (url); + url = old_key; + } + + g_hash_table_insert (urls, url, data); + + return url; +} + +const char * +mail_display_get_url_for_icon (MailDisplay *md, const char *icon_name) +{ + char *icon_path, buf[1024], *url; + int fd, nread; + GByteArray *ba; + + /* FIXME: cache */ + + if (*icon_name == '/') + icon_path = g_strdup (icon_name); + else { + icon_path = gnome_pixmap_file (icon_name); + if (!icon_path) + return "file:///dev/null"; + } + + fd = open (icon_path, O_RDONLY); + g_free (icon_path); + if (fd == -1) + return "file:///dev/null"; + + ba = g_byte_array_new (); + while (1) { + nread = read (fd, buf, sizeof (buf)); + if (nread < 1) + break; + g_byte_array_append (ba, buf, nread); + } + close (fd); + + url = g_strdup_printf ("x-evolution-data:%p", ba); + + return mail_display_add_url (md, "data_urls", url, ba); +} + + E_MAKE_TYPE (mail_display, "MailDisplay", MailDisplay, mail_display_class_init, mail_display_init, PARENT_TYPE); diff --git a/mail/mail-display.h b/mail/mail-display.h index aa1960fc8d..0fcd98ab00 100644 --- a/mail/mail-display.h +++ b/mail/mail-display.h @@ -36,9 +36,10 @@ struct _MailDisplay { char *selection; + struct _FollowUpTag *followup; CamelMimeMessage *current_message; GData **data; - + GHashTable *related; /* related parts not displayed yet */ /* Sigh. This shouldn't be needed. I haven't figured out why it is @@ -76,7 +77,8 @@ void mail_display_stream_write_when_loaded (MailDisplay *md, gpointer data); void mail_display_set_message (MailDisplay *mail_display, - CamelMedium *medium); + CamelMedium *medium, + const char *followup); void mail_display_set_charset (MailDisplay *mail_display, const char *charset); @@ -94,4 +96,8 @@ void mail_error_printf (GtkHTML *html, GtkHTMLStream *stream, const char *format, ...); +char *mail_display_add_url (MailDisplay *md, const char *kind, char *url, gpointer data); + +const char *mail_display_get_url_for_icon (MailDisplay *md, const char *icon_name); + #endif /* _MAIL_DISPLAY_H_ */ diff --git a/mail/mail-format.c b/mail/mail-format.c index d353b0b249..d0f5da6757 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -136,22 +136,6 @@ free_data_urls (gpointer urls) g_hash_table_destroy (urls); } -static char * -add_url (const char *kind, char *url, gpointer data, MailDisplay *md) -{ - GHashTable *urls; - gpointer old_key, old_value; - - urls = g_datalist_get_data (md->data, kind); - g_return_val_if_fail (urls != NULL, NULL); - if (g_hash_table_lookup_extended (urls, url, &old_key, &old_value)) { - g_free (url); - url = old_key; - } - g_hash_table_insert (urls, url, data); - return url; -} - /** * mail_format_mime_message: * @mime_message: the input mime message @@ -249,8 +233,8 @@ get_cid (CamelMimePart *part, MailDisplay *md) camel_mime_part_get_content_id (part)); } else cid = g_strdup_printf ("cid:@@@%d", fake_cid_counter++); - - return add_url ("part_urls", cid, part, md); + + return mail_display_add_url (md, "part_urls", cid, part); } static const char * @@ -263,42 +247,7 @@ get_location (CamelMimePart *part, MailDisplay *md) if (!loc) return NULL; - return add_url ("part_urls", g_strdup (loc), part, md); -} - -static const char * -get_url_for_icon (const char *icon_name, MailDisplay *md) -{ - char *icon_path, buf[1024], *url; - int fd, nread; - GByteArray *ba; - - /* FIXME: cache */ - - if (*icon_name == '/') - icon_path = g_strdup (icon_name); - else { - icon_path = gnome_pixmap_file (icon_name); - if (!icon_path) - return "file:///dev/null"; - } - - fd = open (icon_path, O_RDONLY); - g_free (icon_path); - if (fd == -1) - return "file:///dev/null"; - - ba = g_byte_array_new (); - while (1) { - nread = read (fd, buf, sizeof (buf)); - if (nread < 1) - break; - g_byte_array_append (ba, buf, nread); - } - close (fd); - - url = g_strdup_printf ("x-evolution-data:%p", ba); - return add_url ("data_urls", url, ba, md); + return mail_display_add_url (md, "part_urls", g_strdup (loc), part); } @@ -1007,11 +956,11 @@ write_headers (CamelMimeMessage *message, MailDisplay *md, const char *charset; CamelContentType *ct; char *value; - + ct = camel_mime_part_get_content_type(CAMEL_MIME_PART(message)); charset = header_content_type_param(ct, "charset"); charset = e_iconv_charset_name(charset); - + header = CAMEL_MIME_PART(message)->headers; while (header) { i = default_header_index(header->name); @@ -1626,7 +1575,7 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, xed = g_strdup_printf ("x-evolution-data:%p", part); gtk_html_stream_printf (stream, "<iframe src=\"%s\" frameborder=0 scrolling=no></iframe>", xed); - add_url ("data_urls", xed, ba, md); + mail_display_add_url (md, "data_urls", xed, ba); return TRUE; } @@ -1708,7 +1657,7 @@ handle_multipart_digest (CamelMimePart *part, const char *mime_type, g_return_val_if_fail (CAMEL_IS_MULTIPART (wrapper), FALSE); gtk_html_stream_printf (stream, " <a href=\"digest:\"><img src=\"%s\">%s</a>", - get_url_for_icon (EVOLUTION_ICONSDIR "/envelope.png", md), + mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/envelope.png"), U_("View messages...")); return TRUE; @@ -1800,7 +1749,7 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, "<td><table width=3 cellspacing=0 cellpadding=0>" "<tr><td></td></tr></table></td>" "<td><font size=-1>", url); - add_url ("part_urls", url, subpart, md); + mail_display_add_url (md, "part_urls", url, subpart); mail_html_write (html, stream, U_("This message is digitally signed. " @@ -1833,7 +1782,7 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, "<table><tr valign=top>" "<td><img src=\"%s\"></td>" "<td>%s<br><br>", - get_url_for_icon (EVOLUTION_ICONSDIR "/pgp-signature-ok.png", md), + mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/pgp-signature-ok.png"), U_("This message is digitally signed and " "has been found to be authentic.")); } else { @@ -1841,7 +1790,7 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, "<table><tr valign=top>" "<td><img src=\"%s\"></td>" "<td>%s<br><br>", - get_url_for_icon (EVOLUTION_ICONSDIR "/pgp-signature-bad.png", md), + mail_display_get_url_for_icon (md, EVOLUTION_ICONSDIR "/pgp-signature-bad.png"), U_("This message is digitally signed but can " "not be proven to be authentic.")); } diff --git a/mail/mail-ops.c b/mail/mail-ops.c index be6c2ed8ed..13cd285f37 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -506,7 +506,7 @@ mail_send_message (CamelMimeMessage *message, const char *destination, camel_address_cat (recipients, CAMEL_ADDRESS (iaddr)); } - camel_transport_send_to (xport, CAMEL_MEDIUM (message), from, recipients, ex); + camel_transport_send_to (xport, message, from, recipients, ex); camel_object_unref (CAMEL_OBJECT (recipients)); camel_object_unref (CAMEL_OBJECT (from)); diff --git a/mail/message-tag-editor.c b/mail/message-tag-editor.c index 6aff7fd2b8..a806f78d09 100644 --- a/mail/message-tag-editor.c +++ b/mail/message-tag-editor.c @@ -87,8 +87,6 @@ static void message_tag_editor_init (MessageTagEditor *editor) { gtk_window_set_policy (GTK_WINDOW (editor), FALSE, TRUE, FALSE); - - gtk_window_set_title (GTK_WINDOW (editor), _("Flag to Follow Up")); gnome_dialog_append_buttons (GNOME_DIALOG (editor), GNOME_STOCK_BUTTON_OK, @@ -96,10 +94,6 @@ message_tag_editor_init (MessageTagEditor *editor) NULL); gnome_dialog_set_default (GNOME_DIALOG (editor), 0); - - gnome_window_icon_set_from_file (GTK_WINDOW (editor), EVOLUTION_ICONSDIR "/flag-for-followup-16.png"); - - } diff --git a/mail/message-tag-followup.c b/mail/message-tag-followup.c index 610a35fc53..4b6af39e40 100644 --- a/mail/message-tag-followup.c +++ b/mail/message-tag-followup.c @@ -33,6 +33,8 @@ #include <libgnomeui/gnome-pixmap.h> +#include <gal/util/e-unicode-i18n.h> + #include "message-tag-followup.h" static void message_tag_followup_class_init (MessageTagFollowUpClass *class); @@ -225,13 +227,14 @@ message_tag_followup_encode (struct _FollowUpTag *tag) (unsigned long) tag->completed); } + const char * message_tag_followup_i18n_name (int type) { g_return_val_if_fail (type >= 0 && type <= FOLLOWUP_FLAG_NONE, NULL); if (type != FOLLOWUP_FLAG_NONE) - return _(available_flags[type].i18n_name); + return U_(available_flags[type].i18n_name); else return NULL; } @@ -306,6 +309,9 @@ construct (MessageTagEditor *editor) GladeXML *gui; int i; + gtk_window_set_title (GTK_WINDOW (editor), _("Flag to Follow Up")); + gnome_window_icon_set_from_file (GTK_WINDOW (editor), EVOLUTION_IMAGES "/flag-for-followup-16.png"); + gui = glade_xml_new (EVOLUTION_GLADEDIR "/message-tags.glade", "followup_editor"); widget = glade_xml_get_widget (gui, "toplevel"); |