X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fgnome%2Fmodest-msg-edit-window.c;h=de5044a1aa000a1b60847a7a4792759234dcfd38;hp=b02ad9f0335a54f8107d1867594463ebcd6d3564;hb=f64c740f4ee8ab71d5842f369beaced86ab521d5;hpb=c2e64fd105d649a5911bf21bb0d70e6e9e17597e diff --git a/src/gnome/modest-msg-edit-window.c b/src/gnome/modest-msg-edit-window.c index b02ad9f..de5044a 100644 --- a/src/gnome/modest-msg-edit-window.c +++ b/src/gnome/modest-msg-edit-window.c @@ -49,6 +49,8 @@ #include #include #include +#include +#include static void modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass); static void modest_msg_edit_window_init (ModestMsgEditWindow *obj); @@ -89,6 +91,9 @@ struct _ModestMsgEditWindowPrivate { TnyMsg *outbox_msg; gchar *msg_uid; + gchar *references; + gchar *in_reply_to; + gboolean sent; }; @@ -179,6 +184,8 @@ modest_msg_edit_window_init (ModestMsgEditWindow *obj) priv->draft_msg = NULL; priv->outbox_msg = NULL; priv->msg_uid = NULL; + priv->references = NULL; + priv->in_reply_to = NULL; } /** @@ -196,7 +203,7 @@ get_transports (void) while (cursor) { gchar *account_name = cursor->data ? g_strdup((gchar*)cursor->data) : NULL; gchar *from_string = modest_account_mgr_get_from_string (account_mgr, - account_name); + account_name, NULL); if (!from_string) { /* something went wrong: ignore this one */ g_free (account_name); @@ -280,9 +287,17 @@ init_window (ModestMsgEditWindow *obj, const gchar* account) gtk_table_attach_defaults (GTK_TABLE(header_table), priv->subject_field,1,2,4,5); gtk_table_attach_defaults (GTK_TABLE(header_table), priv->attachments_view,1,2,5,6); - priv->msg_body = gtk_html_new (); - gtk_html_load_empty (GTK_HTML (priv->msg_body)); - gtk_html_set_editable (GTK_HTML (priv->msg_body), TRUE); + priv->msg_body = gtk_source_view_new (); + gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (priv->msg_body), TRUE); + gtk_source_view_set_right_margin_position (GTK_SOURCE_VIEW (priv->msg_body), 78); + gtk_source_view_set_show_right_margin (GTK_SOURCE_VIEW (priv->msg_body), TRUE); + gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->msg_body), TRUE); + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->msg_body), GTK_WRAP_WORD_CHAR); + + PangoFontDescription *font_desc; + font_desc = pango_font_description_from_string ("Monospace"); + gtk_widget_modify_font (priv->msg_body, font_desc); + pango_font_description_free (font_desc); main_vbox = gtk_vbox_new (FALSE, 0); @@ -339,6 +354,8 @@ modest_msg_edit_window_finalize (GObject *obj) priv->outbox_msg = NULL; } g_free (priv->msg_uid); + g_free (priv->references); + g_free (priv->in_reply_to); G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -383,7 +400,8 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg) TnyFolder *msg_folder; gchar *to, *cc, *bcc, *subject; ModestMsgEditWindowPrivate *priv; - gchar *body; + TnyMimePart *body_part; + GtkTextBuffer *buffer; g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self)); g_return_if_fail (TNY_IS_MSG (msg)); @@ -405,17 +423,23 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg) if (subject) gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject); + modest_tny_msg_get_references (TNY_MSG (msg), NULL, &(priv->references), &(priv->in_reply_to)); + modest_attachments_view_set_message (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), msg); priv->attachments = modest_attachments_view_get_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view)); update_next_cid (self, priv->attachments); - body = modest_tny_msg_get_body (msg, FALSE, NULL); - gtk_html_set_editable (GTK_HTML (priv->msg_body), FALSE); - if (body) { - gtk_html_load_from_string (GTK_HTML (priv->msg_body), body, -1); + body_part = modest_tny_msg_find_body_part (msg, FALSE); + if (body_part) { + TnyStream *stream; + gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->msg_body), FALSE); + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body)); + stream = TNY_STREAM (tny_gtk_text_buffer_stream_new (buffer)); + tny_stream_reset (stream); + tny_mime_part_decode_to_stream (body_part, stream, NULL); + tny_stream_reset (stream); + gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->msg_body), TRUE); } - gtk_html_set_editable (GTK_HTML (priv->msg_body), TRUE); - g_free (body); modest_msg_edit_window_set_modified (self, FALSE); @@ -450,6 +474,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg) ModestWindow * modest_msg_edit_window_new (TnyMsg *msg, const gchar *account, + const gchar *mailbox, gboolean preserve_is_rich) { ModestMsgEditWindow *self; @@ -480,6 +505,12 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account, modest_msg_edit_toggle_action_entries, G_N_ELEMENTS (modest_msg_edit_toggle_action_entries), self); + gtk_action_group_add_radio_actions (action_group, + modest_msg_edit_priority_action_entries, + G_N_ELEMENTS (modest_msg_edit_priority_action_entries), + 0, + G_CALLBACK (modest_ui_actions_msg_edit_on_change_priority), + self); gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0); g_object_unref (action_group); @@ -556,16 +587,6 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account, return MODEST_WINDOW(self); } -static gboolean -html_export_save_buffer (gpointer engine, - const gchar *data, - size_t len, - GString **buffer) -{ - *buffer = g_string_append (*buffer, data); - return TRUE; -} - MsgData * modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window) @@ -575,7 +596,6 @@ modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window) const gchar *account_name; gchar *from_string = NULL; ModestMsgEditWindowPrivate *priv; - GString *buffer; TnyIterator *att_iter; g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (edit_window), NULL); @@ -584,8 +604,8 @@ modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window) account_name = (gchar*)modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field)); if (account_name) - from_string = modest_account_mgr_get_from_string ( - modest_runtime_get_account_mgr(), account_name); + from_string = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(), + account_name, NULL); if (!from_string) { g_printerr ("modest: cannot get from string\n"); return NULL; @@ -599,18 +619,14 @@ modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window) data->cc = g_strdup ( gtk_entry_get_text (GTK_ENTRY(priv->cc_field))); data->bcc = g_strdup ( gtk_entry_get_text (GTK_ENTRY(priv->bcc_field))); data->subject = g_strdup ( gtk_entry_get_text (GTK_ENTRY(priv->subject_field))); + data->references = g_strdup (priv->references); + data->in_reply_to = g_strdup (priv->in_reply_to); -/* GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body)); */ -/* GtkTextIter b, e; */ -/* gtk_text_buffer_get_bounds (buf, &b, &e); */ -/* data->plain_body = gtk_text_buffer_get_text (buf, &b, &e, FALSE); /\* Returns a copy. *\/ */ - - buffer = g_string_new (""); - gtk_html_export (GTK_HTML (priv->msg_body), "text/html", (GtkHTMLSaveReceiverFn) html_export_save_buffer, &buffer); - data->html_body = g_string_free (buffer, FALSE); - buffer = g_string_new (""); - gtk_html_export (GTK_HTML (priv->msg_body), "text/plain", (GtkHTMLSaveReceiverFn) html_export_save_buffer, &buffer); - data->plain_body = g_string_free (buffer, FALSE); + GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body)); + GtkTextIter b, e; + gtk_text_buffer_get_bounds (buf, &b, &e); + data->plain_body = gtk_text_buffer_get_text (buf, &b, &e, FALSE); /* Returns a copy. */ + data->html_body = NULL; /* deep-copy the attachment data */ att_iter = tny_list_create_iterator (priv->attachments); @@ -663,6 +679,8 @@ modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window, g_free (data->subject); g_free (data->plain_body); g_free (data->html_body); + g_free (data->references); + g_free (data->in_reply_to); if (data->draft_msg != NULL) { g_object_unref (data->draft_msg); @@ -821,7 +839,7 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, - message); + "%s", message); g_free (message); dialog_response = (gtk_dialog_run (GTK_DIALOG (confirmation_dialog))==GTK_RESPONSE_OK); gtk_widget_destroy (confirmation_dialog);