From 22dc0c949c909394889c9b56d63240ad271eb3f8 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 9 Jun 2008 11:09:01 +0000 Subject: ** Fix for bug #535791 2008-06-09 Milan Crha ** Fix for bug #535791 * mail-config.glade: * em-composer-prefs.c: (em_composer_prefs_construct): New UI option to let uset choose whether start typing at the bottom of the document or not on replying. * em-utils.h: (em_utils_message_to_html): * em-utils.c: (em_utils_message_to_html): * em-composer-utils.c: (forward_non_attached), (composer_set_body): Take care of /apps/evolution/mail/composer/reply_start_bottom. svn path=/trunk/; revision=35621 --- mail/ChangeLog | 13 +++++++++++++ mail/em-composer-prefs.c | 6 ++++++ mail/em-composer-utils.c | 26 ++++++++++++++++++++++---- mail/em-utils.c | 6 +++++- mail/em-utils.h | 2 +- mail/mail-config.glade | 19 +++++++++++++++++++ 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 5a1331c77c..88ebea6dc9 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,16 @@ +2008-06-09 Milan Crha + + ** Fix for bug #535791 + + * mail-config.glade: + * em-composer-prefs.c: (em_composer_prefs_construct): + New UI option to let uset choose whether start typing at the bottom + of the document or not on replying. + * em-utils.h: (em_utils_message_to_html): + * em-utils.c: (em_utils_message_to_html): + * em-composer-utils.c: (forward_non_attached), (composer_set_body): + Take care of /apps/evolution/mail/composer/reply_start_bottom. + 2008-06-09 Milan Crha ** Fix for bug #201011 diff --git a/mail/em-composer-prefs.c b/mail/em-composer-prefs.c index 41975589ef..87cdd0d4de 100644 --- a/mail/em-composer-prefs.c +++ b/mail/em-composer-prefs.c @@ -939,6 +939,12 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) gtk_widget_set_sensitive (widget, FALSE); gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + key = "/apps/evolution/mail/composer/reply_start_bottom"; + widget = glade_xml_get_widget (gui, "chkReplyStartBottom"); + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (widget, FALSE); + gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + key = "/apps/evolution/mail/composer/top_signature"; widget = glade_xml_get_widget (gui, "chkTopSignature"); if (!gconf_client_key_is_writable (client, key, NULL)) diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 90b2b579be..ef72fd6e4a 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -1005,7 +1005,7 @@ forward_non_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, message = messages->pdata[i]; subject = mail_tool_generate_forward_subject (message); - text = em_utils_message_to_html (message, _("-------- Forwarded Message --------"), flags, &len, NULL); + text = em_utils_message_to_html (message, _("-------- Forwarded Message --------"), flags, &len, NULL, NULL); if (text) { composer = create_new_composer (subject, fromuri, !uids || !uids->pdata [i]); @@ -1990,9 +1990,11 @@ composer_set_body (EMsgComposer *composer, CamelMimeMessage *message, EMFormat * char *text, *credits; CamelMimePart *part; GConfClient *gconf; - ssize_t len; + ssize_t len = 0; + gboolean start_bottom; gconf = mail_config_get_gconf_client (); + start_bottom = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/reply_start_bottom", NULL); switch (gconf_client_get_int (gconf, "/apps/evolution/mail/format/reply_style", NULL)) { case MAIL_CONFIG_REPLY_DO_NOT_QUOTE: @@ -2005,7 +2007,7 @@ composer_set_body (EMsgComposer *composer, CamelMimeMessage *message, EMFormat * camel_object_unref (part); break; case MAIL_CONFIG_REPLY_OUTLOOK: - text = em_utils_message_to_html(message, _("-----Original Message-----"), EM_FORMAT_QUOTE_HEADERS, &len, source); + text = em_utils_message_to_html (message, _("-----Original Message-----"), EM_FORMAT_QUOTE_HEADERS, &len, source, start_bottom ? "
" : NULL); e_msg_composer_set_body_text(composer, text, len); g_free (text); break; @@ -2014,12 +2016,28 @@ composer_set_body (EMsgComposer *composer, CamelMimeMessage *message, EMFormat * default: /* do what any sane user would want when replying... */ credits = attribution_format (ATTRIBUTION, message); - text = em_utils_message_to_html(message, credits, EM_FORMAT_QUOTE_CITE, &len, source); + text = em_utils_message_to_html (message, credits, EM_FORMAT_QUOTE_CITE, &len, source, start_bottom ? "
" : NULL); g_free (credits); e_msg_composer_set_body_text(composer, text, len); g_free (text); break; } + + if (len > 0 && start_bottom) { + GtkhtmlEditor *editor = GTKHTML_EDITOR (composer); + + /* If we are placing signature on top, then move cursor to the end, + otherwise try to find the signature place and place cursor just + before the signature. We added there an empty line already. */ + gtkhtml_editor_run_command (editor, "block-selection"); + gtkhtml_editor_run_command (editor, "cursor-bod"); + if (gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/top_signature", NULL) + || !gtkhtml_editor_search_by_data (editor, 1, "ClueFlow", "signature", "1")) + gtkhtml_editor_run_command (editor, "cursor-eod"); + else + gtkhtml_editor_run_command (editor, "selection-move-left"); + gtkhtml_editor_run_command (editor, "unblock-selection"); + } } struct _reply_data { diff --git a/mail/em-utils.c b/mail/em-utils.c index 799ff9c339..50b56aa453 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1645,6 +1645,7 @@ em_utils_part_to_html(CamelMimePart *part, ssize_t *len, EMFormat *source) * @flags: EMFormatQuote flags * @len: * @source: + * @append: Text to append, can be NULL. * * Convert a message to html, quoting if the @credits attribution * string is given. @@ -1652,7 +1653,7 @@ em_utils_part_to_html(CamelMimePart *part, ssize_t *len, EMFormat *source) * Return value: The html version. **/ char * -em_utils_message_to_html(CamelMimeMessage *message, const char *credits, guint32 flags, ssize_t *len, EMFormat *source) +em_utils_message_to_html(CamelMimeMessage *message, const char *credits, guint32 flags, ssize_t *len, EMFormat *source, const char *append) { EMFormatQuote *emfq; CamelStreamMem *mem; @@ -1682,6 +1683,9 @@ em_utils_message_to_html(CamelMimeMessage *message, const char *credits, guint32 em_format_format_clone((EMFormat *)emfq, NULL, NULL, message, source); g_object_unref (emfq); + if (append && *append) + camel_stream_write ((CamelStream*)mem, append, strlen (append)); + camel_stream_write((CamelStream *)mem, "", 1); camel_object_unref(mem); diff --git a/mail/em-utils.h b/mail/em-utils.h index 8f2cc83985..6e5733eaef 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -91,7 +91,7 @@ char *em_utils_get_proxy_uri(void); /* FIXME: should this have an override charset? */ char *em_utils_part_to_html(struct _CamelMimePart *part, ssize_t *len, struct _EMFormat *source); -char *em_utils_message_to_html(struct _CamelMimeMessage *msg, const char *credits, guint32 flags, ssize_t *len, struct _EMFormat *source); +char *em_utils_message_to_html(struct _CamelMimeMessage *msg, const char *credits, guint32 flags, ssize_t *len, struct _EMFormat *source, const char *append); void em_utils_expunge_folder (struct _GtkWidget *parent, struct _CamelFolder *folder); void em_utils_empty_trash (struct _GtkWidget *parent); diff --git a/mail/mail-config.glade b/mail/mail-config.glade index f73eaae09c..867f786f9f 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -7104,6 +7104,25 @@ For example: "Work" or "Personal" + + + True + True + Start _typing at the bottom on replying + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + True -- cgit v1.2.3