tny_folder_add_msg (folder, msg, NULL); /* TODO: check err */
gdk_threads_enter ();
- ModestWindow *win = modest_msg_edit_window_new (msg, account_name);
+ ModestWindow *win = modest_msg_edit_window_new (msg, account_name, FALSE);
modest_window_mgr_register_window (modest_runtime_get_window_mgr (), win);
gtk_widget_show_all (GTK_WIDGET (win));
gdk_threads_enter ();
- ModestWindow *win = modest_msg_edit_window_new (msg, account_name);
+ ModestWindow *win = modest_msg_edit_window_new (msg, account_name, FALSE);
/* it seems Sketch at least sends a leading ',' -- take that into account,
* ie strip that ,*/
if (is_draft) {
/* TODO: Maybe the msg_uid should be registered for edit windows too,
* so we can open the same window again next time: */
- msg_view = modest_msg_edit_window_new (msg, modest_account_name);
+ msg_view = modest_msg_edit_window_new (msg, modest_account_name, TRUE);
} else {
msg_view = modest_msg_view_window_new (msg, modest_account_name,
msg_uid);
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(priv->msg_body));
- body = modest_tny_msg_get_body (msg, FALSE);
+ body = modest_tny_msg_get_body (msg, FALSE, NULL);
if (body)
gtk_text_buffer_set_text (buf, body, -1);
g_free (body);
}
static void
-set_msg (ModestMsgEditWindow *self, TnyMsg *msg)
+set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
{
TnyHeader *header;
const gchar *to, *cc, *bcc, *subject;
GtkTextIter iter;
TnyHeaderFlags priority_flags;
TnyFolder *msg_folder;
+ gboolean is_html = FALSE;
g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self));
g_return_if_fail (TNY_IS_MSG (msg));
update_window_title (self);
wp_text_buffer_reset_buffer (WP_TEXT_BUFFER (priv->text_buffer), TRUE);
- body = modest_tny_msg_get_body (msg, TRUE);
+ body = modest_tny_msg_get_body (msg, TRUE, &is_html);
if ((body == NULL)||(body[0] == '\0')) {
g_free (body);
body = modest_text_utils_convert_to_html ("");
+ is_html = FALSE;
}
wp_text_buffer_load_document_begin (WP_TEXT_BUFFER (priv->text_buffer), TRUE);
wp_text_buffer_load_document_write (WP_TEXT_BUFFER (priv->text_buffer),
wp_text_buffer_load_document_end (WP_TEXT_BUFFER (priv->text_buffer));
g_free (body);
+ if (preserve_is_rich && !is_html) {
+ wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), FALSE);
/* Get the default format required from configuration */
- if (!modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_PREFER_FORMATTED_TEXT, NULL)) {
+ } else if (!modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_PREFER_FORMATTED_TEXT, NULL)) {
wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), FALSE);
}
ModestWindow*
-modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name)
+modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean preserve_is_rich)
{
GObject *obj;
ModestWindowPrivate *parent_priv;
if (account_pair != NULL)
modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->from_field), account_pair->first);
- set_msg (MODEST_MSG_EDIT_WINDOW (obj), msg);
+ set_msg (MODEST_MSG_EDIT_WINDOW (obj), msg, preserve_is_rich);
text_buffer_refresh_attributes (WP_TEXT_BUFFER (priv->text_buffer), MODEST_MSG_EDIT_WINDOW (obj));
update_paste_dimming (MODEST_MSG_EDIT_WINDOW (obj));
priv->update_caption_visibility = TRUE;
+
+ reset_modified (MODEST_MSG_EDIT_WINDOW (obj));
return (ModestWindow*) obj;
}
gchar *
-modest_tny_msg_get_body (TnyMsg *msg, gboolean want_html)
+modest_tny_msg_get_body (TnyMsg *msg, gboolean want_html, gboolean *is_html)
{
TnyStream *stream;
TnyMimePart *body;
GtkTextBuffer *buf;
GtkTextIter start, end;
gchar *to_quote;
+ gboolean result_was_html = TRUE;
body = modest_tny_msg_find_body_part(msg, want_html);
if (!body)
gchar *to_quote_converted = modest_text_utils_convert_to_html (to_quote);
g_free (to_quote);
to_quote = to_quote_converted;
+ result_was_html = FALSE;
}
g_object_unref (buf);
g_object_unref (G_OBJECT(stream));
g_object_unref (G_OBJECT(body));
+ if (is_html != NULL)
+ *is_html = result_was_html;
+
return to_quote;
}
* modest_tny_msg_find_body:
* @self:
* @want_html:
+ * @is_html: if the original body was html or plain text
*
* gets the body of a message as text, if @want_html is true, try HTML mail
* first.
* Returns: the body of the message as text, or NULL if it is not found
* the text should be freed with
**/
-gchar* modest_tny_msg_get_body (TnyMsg *self, gboolean want_html);
+gchar* modest_tny_msg_get_body (TnyMsg *self, gboolean want_html, gboolean *is_html);
/**
/* Create and register edit window */
/* This is destroyed by TOOD. */
- msg_win = modest_msg_edit_window_new (msg, account_name);
+ msg_win = modest_msg_edit_window_new (msg, account_name, FALSE);
mgr = modest_runtime_get_window_mgr ();
modest_window_mgr_register_window (mgr, msg_win);
run_account_setup_wizard(parent_win);
goto cleanup;
}
- win = modest_msg_edit_window_new (msg, account);
+ win = modest_msg_edit_window_new (msg, account, TRUE);
} else {
gchar *uid = modest_tny_folder_get_header_unique_id (header);
}
/* Create and register the windows */
- msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account_name);
+ msg_win = modest_msg_edit_window_new (new_msg, rf_helper->account_name, FALSE);
mgr = modest_runtime_get_window_mgr ();
modest_window_mgr_register_window (mgr, msg_win);
/**
* modest_msg_edit_window_new:
- * #msg: a #TnyMsg instance
- * #account_name: the account this message applies to
+ * @msg: a #TnyMsg instance
+ * @account_name: the account this message applies to
+ * @preserve_is_rich: if @msg is not rich, open the message as plain text
*
* instantiates a new #ModestMsgEditWindow widget
*
* Returns: a new #ModestMsgEditWindow, or NULL in case of error
*/
-ModestWindow* modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name);
+ModestWindow* modest_msg_edit_window_new (TnyMsg *msg,
+ const gchar *account_name,
+ gboolean preserve_is_rich);
/**