diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 31 | ||||
-rw-r--r-- | mail/folder-browser-factory.c | 19 | ||||
-rw-r--r-- | mail/folder-browser.c | 20 | ||||
-rw-r--r-- | mail/folder-browser.h | 6 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 14 | ||||
-rw-r--r-- | mail/mail-config.c | 13 | ||||
-rw-r--r-- | mail/mail-config.h | 2 | ||||
-rw-r--r-- | mail/mail-display.c | 27 | ||||
-rw-r--r-- | mail/mail-display.h | 7 | ||||
-rw-r--r-- | mail/mail-format.c | 25 | ||||
-rw-r--r-- | mail/mail-ops.c | 131 | ||||
-rw-r--r-- | mail/mail-ops.h | 2 | ||||
-rw-r--r-- | mail/mail.h | 2 |
13 files changed, 136 insertions, 163 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 4afc22ac4c..ba52267de9 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,9 +1,40 @@ +2000-11-21 Jeffrey Stedfast <fejj@helixcode.com> + + * mail-config.c (mail_config_view_source): New function to return + if user wants to view message source. + (mail_config_set_view_source): New function to set whether the + view wants to view source. + + * mail-ops.c (mail_do_view_message_sources): Removed. We're not + gonna view-source this way anymore. + + * folder-browser-factory.c: Removed the ViewSource bonobo verb + from the Message menu. + (control_activate): Added ViewSource. + + * folder-browser.c (on_right_click): Removed Message menu item to + view message source. + (folder_browser_toggle_view_source): New callback to set whether + or not the MailDisplay shows the raw message or the pretty-ified + message. + + * mail-callbacks.c: Removed view_source. + + * mail-display.c (redisplay): If toggle_raw is set then display + the raw message else display the pretty formatted message. + (mail_display_redisplay): New function to force the redisplay of a + message. + + * mail-format.c (mail_format_raw_message): New function to + write the raw message data. + 2000-11-21 Not Zed <NotZed@HelixCode.com> * mail-vfolder.c (vfolder_uri_to_folder): IF we dont find a source, clear the exception and ignore it silently. for e.g. if the user reconfigured their mailboxes and one of them no longer exists. + 2000-11-21 Radek Doulik <rodo@helixcode.com> * mail-display.c: #include <gtkhtml/gtkhtml-embedded.h> diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index 1ca2a2c906..07bd36d3fb 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -14,7 +14,7 @@ #include <bonobo/bonobo-main.h> #include <bonobo/bonobo-object.h> #include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-control.h> +#include <bonobo/bonobo-control.h> #include <bonobo/bonobo-ui-component.h> #include <gal/util/e-util.h> @@ -80,8 +80,6 @@ BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("MessageFilterSndr", filter_sender), BONOBO_UI_UNSAFE_VERB ("MessageFilterRecip", filter_recipient), - BONOBO_UI_UNSAFE_VERB ("MessageViewSource", view_source), - /* Folder Menu */ BONOBO_UI_UNSAFE_VERB ("FolderExpunge", expunge_folder), BONOBO_UI_UNSAFE_VERB ("FolderConfig", configure_folder), @@ -157,11 +155,22 @@ control_activate (BonoboControl *control, else bonobo_ui_component_set_prop ( uic, "/commands/ViewThreaded", "state", "0", NULL); - + bonobo_ui_component_add_listener ( uic, "ViewThreaded", folder_browser_toggle_threads, folder_browser); - + + if (mail_config_view_source ()) + bonobo_ui_component_set_prop (uic, "/commands/ViewSource", + "state", "1", NULL); + else + bonobo_ui_component_set_prop (uic, "/commands/ViewSource", + "state", "0", NULL); + + bonobo_ui_component_add_listener (uic, "ViewSource", + folder_browser_toggle_view_source, + folder_browser); + update_pixmaps (uic); bonobo_ui_component_thaw (uic, NULL); diff --git a/mail/folder-browser.c b/mail/folder-browser.c index f6c1b94963..d03e58eaa4 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -382,6 +382,22 @@ folder_browser_toggle_threads (BonoboUIComponent *component, } void +folder_browser_toggle_view_source (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + FolderBrowser *fb = user_data; + + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + + mail_config_set_view_source (atoi (state)); + mail_display_redisplay (fb->mail_display, TRUE); +} + +void vfolder_subject (GtkWidget *w, FolderBrowser *fb) { vfolder_gui_add_from_message (fb->mail_display->current_message, AUTO_SUBJECT, @@ -481,8 +497,6 @@ on_right_click (ETableScrolled *table, gint row, gint col, GdkEvent *event, Fold { _("Apply Filters"), NULL, GTK_SIGNAL_FUNC (apply_filters), NULL, 0 }, { "", NULL, GTK_SIGNAL_FUNC (NULL), NULL, 0 }, { _("Create Rule From Message"), NULL, GTK_SIGNAL_FUNC (NULL), filter_menu, 2 }, - { "", NULL, GTK_SIGNAL_FUNC (NULL), NULL, 0 }, - { _("View Message Source"), NULL, GTK_SIGNAL_FUNC (view_source), NULL, 0 }, { NULL, NULL, NULL, NULL, 0 } }; @@ -721,7 +735,7 @@ my_folder_browser_init (GtkObject *object) */ fb->message_list = (MessageList *)message_list_new (); fb->mail_display = (MailDisplay *)mail_display_new (); - + gtk_signal_connect (GTK_OBJECT (fb->message_list->etable), "key_press", GTK_SIGNAL_FUNC (etable_key), fb); diff --git a/mail/folder-browser.h b/mail/folder-browser.h index 490088c639..a7c06dca80 100644 --- a/mail/folder-browser.h +++ b/mail/folder-browser.h @@ -90,4 +90,10 @@ void folder_browser_toggle_threads (BonoboUIComponent *component, const char *state, gpointer user_data); +void folder_browser_toggle_view_source (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data); + #endif /* _FOLDER_BROWSER_H_ */ diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 8286735f5b..fd57b5b6bc 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -929,20 +929,6 @@ configure_folder (BonoboUIComponent *uih, void *user_data, const char *path) } void -view_source (GtkWidget *widget, gpointer user_data) -{ - FolderBrowser *fb = user_data; - GPtrArray *uids; - - if (!fb->folder) - return; - - uids = g_ptr_array_new (); - message_list_foreach (fb->message_list, enumerate_msg, uids); - mail_do_view_message_sources (fb->folder, uids, fb); -} - -void view_msg (GtkWidget *widget, gpointer user_data) { FolderBrowser *fb = user_data; diff --git a/mail/mail-config.c b/mail/mail-config.c index 73dce61f9c..df8d7bc0a3 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -46,6 +46,7 @@ typedef struct MailConfigService *transport; gboolean thread_list; + gboolean view_source; gint paned_size; gboolean send_html; gint seen_timeout; @@ -425,12 +426,24 @@ mail_config_thread_list (void) return config->thread_list; } +gboolean +mail_config_view_source (void) +{ + return config->view_source; +} + void mail_config_set_thread_list (gboolean value) { config->thread_list = value; } +void +mail_config_set_view_source (gboolean value) +{ + config->view_source = value; +} + gint mail_config_paned_size (void) { diff --git a/mail/mail-config.h b/mail/mail-config.h index 47c1e4d6a0..e11ce1a67f 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -59,8 +59,10 @@ void mail_config_write_on_exit (void); /* General Accessor functions */ gboolean mail_config_is_configured (void); gboolean mail_config_thread_list (void); +gboolean mail_config_view_source (void); gint mail_config_paned_size (void); void mail_config_set_thread_list (gboolean value); +void mail_config_set_view_source (gboolean value); void mail_config_set_paned_size (gint size); gboolean mail_config_send_html (void); void mail_config_set_send_html (gboolean send_html); diff --git a/mail/mail-display.c b/mail/mail-display.c index 6c72d35016..2934500f63 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -732,16 +732,19 @@ redisplay (MailDisplay *md, gboolean unscroll) adj = e_scroll_frame_get_vadjustment (md->scroll); oldv = adj->value; } - + md->stream = gtk_html_begin (md->html); mail_html_write (md->html, md->stream, "%s%s", HTML_HEADER, "<BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\">\n"); - + if (md->current_message) { camel_object_ref (CAMEL_OBJECT (md->current_message)); - mail_format_mime_message (md->current_message, md); + if (mail_config_view_source ()) + mail_format_raw_message (md->current_message, md); + else + mail_format_mime_message (md->current_message, md); } - + mail_html_write (md->html, md->stream, "</BODY></HTML>\n"); gtk_html_end (md->html, md->stream, GTK_HTML_STREAM_OK); md->stream = NULL; @@ -759,6 +762,20 @@ redisplay (MailDisplay *md, gboolean unscroll) } } + +/** + * mail_display_redisplay: + * @mail_display: the mail display object + * @unscroll: specifies whether or not to lose current scroll + * + * Force a redraw of the message display. + **/ +void +mail_display_redisplay (MailDisplay *mail_display, gboolean unscroll) +{ + redisplay (mail_display, unscroll); +} + /** * mail_display_set_message: * @mail_display: the mail display object @@ -861,6 +878,4 @@ mail_display_new (void) return GTK_WIDGET (mail_display); } - - 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 9f2d8a2620..c4eac5f145 100644 --- a/mail/mail-display.h +++ b/mail/mail-display.h @@ -27,7 +27,7 @@ struct _MailDisplay { GtkHTML *html; GtkHTMLStream *stream; guint idle_id; - + CamelMimeMessage *current_message; GData **data; }; @@ -39,9 +39,14 @@ typedef struct { GtkType mail_display_get_type (void); GtkWidget * mail_display_new (void); +void mail_display_redisplay (MailDisplay *mail_display, gboolean unscroll); + void mail_display_set_message (MailDisplay *mail_display, CamelMedium *medium); +void mail_display_toggle_raw (MailDisplay *mail_display, + gboolean toggle); + #define HTML_HEADER "<!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" diff --git a/mail/mail-format.c b/mail/mail-format.c index d85f54febf..8b78c01860 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -40,6 +40,8 @@ #include <string.h> /* for strstr */ #include <fcntl.h> +static char *get_data_wrapper_text (CamelDataWrapper *data); + static char *try_inline_pgp (char *start, MailDisplay *md); static char *try_uudecoding (char *start, MailDisplay *md); static char *try_inline_binhex (char *start, MailDisplay *md); @@ -140,11 +142,32 @@ mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md) g_datalist_set_data_full (md->data, "urls", urls, free_urls); } - + write_headers (mime_message, md); call_handler_function (CAMEL_MIME_PART (mime_message), md); } + +/** + * mail_format_raw_message: + * @mime_message: the input mime message + * @md: the MailDisplay to render into + * + * Writes a CamelMimeMessage source out into a MailDisplay + **/ +void +mail_format_raw_message (CamelMimeMessage *mime_message, MailDisplay *md) +{ + gchar *text; + + g_return_if_fail (CAMEL_IS_MIME_MESSAGE (mime_message)); + + text = get_data_wrapper_text (CAMEL_DATA_WRAPPER (mime_message)); + fprintf (stderr, "****** %s\n", text ? "yes! we have text" : "nope...no text"); + mail_text_write (md->html, md->stream, text ? text : ""); + g_free (text); +} + static const char * get_cid (CamelMimePart *part, MailDisplay *md) { diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 728ab77484..60c7a3dad6 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -2387,137 +2387,6 @@ mail_do_view_messages (CamelFolder *folder, GPtrArray *uids, mail_operation_queue (&op_view_messages, input, TRUE); } -/* ** VIEW MESSAGE SOURCE ******************************************************* */ - -typedef struct view_message_sources_input_s { - CamelFolder *folder; - GPtrArray *uids; - FolderBrowser *fb; -} view_message_sources_input_t; - -typedef struct view_message_sources_data_s { - GPtrArray *messages; -} view_message_sources_data_t; - -static gchar * -describe_view_message_sources (gpointer in_data, gboolean gerund) -{ - view_message_sources_input_t *input = (view_message_sources_input_t *) in_data; - - if (gerund) - return g_strdup_printf - (_("Viewing message sources from folder \"%s\""), - mail_tool_get_folder_name (input->folder)); - else - return g_strdup_printf (_("View message sources from \"%s\""), - mail_tool_get_folder_name (input->folder)); -} - -static void -setup_view_message_sources (gpointer in_data, gpointer op_data, CamelException *ex) -{ - view_message_sources_input_t *input = (view_message_sources_input_t *) in_data; - - camel_object_ref (CAMEL_OBJECT (input->folder)); - gtk_object_ref (GTK_OBJECT (input->fb)); -} - -static void -do_view_message_sources (gpointer in_data, gpointer op_data, CamelException *ex) -{ - view_message_sources_input_t *input = (view_message_sources_input_t *) in_data; - view_message_sources_data_t *data = (view_message_sources_data_t *) op_data; - int i; - - data->messages = g_ptr_array_new (); - - for (i = 0; i < input->uids->len; i++) { - CamelMimeMessage *message; - - mail_op_set_message (_("Retrieving message %d of %d (uid \"%s\")"), - i + 1, input->uids->len, (char *)input->uids->pdata[i]); - - mail_tool_camel_lock_up (); - message = camel_folder_get_message (input->folder, input->uids->pdata[i], ex); - mail_tool_camel_lock_down (); - - g_ptr_array_add (data->messages, message); - } -} - -static void -cleanup_view_message_sources (gpointer in_data, gpointer op_data, - CamelException *ex) -{ - view_message_sources_input_t *input = (view_message_sources_input_t *) in_data; - view_message_sources_data_t *data = (view_message_sources_data_t *) op_data; - int i; - - for (i = 0; i < data->messages->len; i++) { - CamelMimeMessage *msg; - CamelStream *stream; - GtkWidget *dialog; - GtkWidget *source; - - if (data->messages->pdata[i] == NULL) - continue; - - msg = data->messages->pdata[i]; - - stream = camel_stream_mem_new (); - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (msg), stream); - - dialog = gnome_dialog_new (camel_mime_message_get_subject (msg), GNOME_STOCK_BUTTON_OK, NULL); - gtk_window_set_policy (GTK_WINDOW (dialog), FALSE, TRUE, FALSE); - source = gtk_text_new (NULL, NULL); - gtk_text_set_editable (GTK_TEXT (source), FALSE); - gtk_text_freeze (GTK_TEXT (source)); - gtk_text_insert (GTK_TEXT (source), NULL, NULL, NULL, - CAMEL_STREAM_MEM (stream)->buffer->data, - CAMEL_STREAM_MEM (stream)->buffer->len); - gtk_text_thaw (GTK_TEXT (source)); - gtk_widget_show (source); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), source, TRUE, TRUE, 0); - - /* FIXME: this blocks, we should probably not use a run_and_close */ - gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); - - camel_object_unref (CAMEL_OBJECT (stream)); - camel_object_unref (CAMEL_OBJECT (data->messages->pdata[i])); - g_free (input->uids->pdata[i]); - } - - g_ptr_array_free (input->uids, TRUE); - g_ptr_array_free (data->messages, TRUE); - camel_object_unref (CAMEL_OBJECT (input->folder)); - gtk_object_unref (GTK_OBJECT (input->fb)); -} - -static const mail_operation_spec op_view_message_sources = { - describe_view_message_sources, - sizeof (view_message_sources_data_t), - setup_view_message_sources, - do_view_message_sources, - cleanup_view_message_sources -}; - -void -mail_do_view_message_sources (CamelFolder *folder, GPtrArray *uids, - FolderBrowser *fb) -{ - view_message_sources_input_t *input; - - g_return_if_fail (CAMEL_IS_FOLDER (folder)); - g_return_if_fail (uids != NULL); - g_return_if_fail (IS_FOLDER_BROWSER (fb)); - - input = g_new (view_message_sources_input_t, 1); - input->folder = folder; - input->uids = uids; - input->fb = fb; - - mail_operation_queue (&op_view_message_sources, input, TRUE); -} /* ** SAVE MESSAGES ******************************************************* */ diff --git a/mail/mail-ops.h b/mail/mail-ops.h index de56198e7b..1144810592 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -71,6 +71,4 @@ void mail_do_edit_messages (CamelFolder *folder, GPtrArray *uids, void mail_do_setup_folder (const char *name, CamelFolder **folder); void mail_do_view_messages (CamelFolder *folder, GPtrArray *uids, FolderBrowser *fb); -void mail_do_view_message_sources (CamelFolder *folder, GPtrArray *uids, - FolderBrowser *fb); void mail_do_save_messages (CamelFolder *folder, GPtrArray *uids, gchar *path); diff --git a/mail/mail.h b/mail/mail.h index 9a897d52f1..0deb3adee1 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -36,6 +36,8 @@ extern char *evolution_dir; /* mail-format */ void mail_format_mime_message (CamelMimeMessage *mime_message, MailDisplay *md); +void mail_format_raw_message (CamelMimeMessage *mime_message, + MailDisplay *md); typedef gboolean (*MailMimeHandlerFn) (CamelMimePart *part, const char *mime_type, |