evolution r35621 - trunk/mail



Author: mcrha
Date: Mon Jun  9 11:09:01 2008
New Revision: 35621
URL: http://svn.gnome.org/viewvc/evolution?rev=35621&view=rev

Log:
2008-06-09  Milan Crha  <mcrha redhat com>

	** 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.



Modified:
   trunk/mail/ChangeLog
   trunk/mail/em-composer-prefs.c
   trunk/mail/em-composer-utils.c
   trunk/mail/em-utils.c
   trunk/mail/em-utils.h
   trunk/mail/mail-config.glade

Modified: trunk/mail/em-composer-prefs.c
==============================================================================
--- trunk/mail/em-composer-prefs.c	(original)
+++ trunk/mail/em-composer-prefs.c	Mon Jun  9 11:09:01 2008
@@ -939,6 +939,12 @@
 		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))

Modified: trunk/mail/em-composer-utils.c
==============================================================================
--- trunk/mail/em-composer-utils.c	(original)
+++ trunk/mail/em-composer-utils.c	Mon Jun  9 11:09:01 2008
@@ -1005,7 +1005,7 @@
 		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 @@
 	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 @@
 		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 ? "<BR>" : NULL);
 		e_msg_composer_set_body_text(composer, text, len);
 		g_free (text);
 		break;
@@ -2014,12 +2016,28 @@
 	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 ? "<BR>" : 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 {

Modified: trunk/mail/em-utils.c
==============================================================================
--- trunk/mail/em-utils.c	(original)
+++ trunk/mail/em-utils.c	Mon Jun  9 11:09:01 2008
@@ -1645,6 +1645,7 @@
  * @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 @@
  * 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_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);
 

Modified: trunk/mail/em-utils.h
==============================================================================
--- trunk/mail/em-utils.h	(original)
+++ trunk/mail/em-utils.h	Mon Jun  9 11:09:01 2008
@@ -91,7 +91,7 @@
 
 /* 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);

Modified: trunk/mail/mail-config.glade
==============================================================================
--- trunk/mail/mail-config.glade	(original)
+++ trunk/mail/mail-config.glade	Mon Jun  9 11:09:01 2008
@@ -7105,6 +7105,25 @@
 			  </child>
 
 			  <child>
+			    <widget class="GtkCheckButton" id="chkReplyStartBottom">
+			      <property name="visible">True</property>
+			      <property name="can_focus">True</property>
+			      <property name="label" translatable="yes">Start _typing at the bottom on replying</property>
+			      <property name="use_underline">True</property>
+			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
+			      <property name="active">False</property>
+			      <property name="inconsistent">False</property>
+			      <property name="draw_indicator">True</property>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
+
+			  <child>
 			    <widget class="GtkTable" id="tableForwardsReplies">
 			      <property name="visible">True</property>
 			      <property name="n_rows">3</property>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]