[Commits] [SCM] claws branch, master, updated. 3.12.0-50-g31806c2

ticho at claws-mail.org ticho at claws-mail.org
Thu Aug 13 20:32:04 CEST 2015


The branch, master has been updated
       via  31806c2352c74a2df322b3483b58123d9320e852 (commit)
      from  bf373b8226f1b3b335619a75de80041ee5ad9761 (commit)

Summary of changes:
 src/messageview.c |   38 ++++++++++++++++++++++++++++++--------
 src/textview.c    |   15 +++++++++++++++
 2 files changed, 45 insertions(+), 8 deletions(-)


- Log -----------------------------------------------------------------
commit 31806c2352c74a2df322b3483b58123d9320e852
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Aug 3 23:25:18 2015 +0200

    Improve how message body is quoted for reply/forward/etc.
    
    Insert body_start and body_end text marks around quotable
    message body, and quote that if user has not selected any text
    to quote for their reply.
    Closes bug #3483.

diff --git a/src/messageview.c b/src/messageview.c
index e6fc2ad..4886f08 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -2119,6 +2119,8 @@ gchar *messageview_get_selection(MessageView *msgview)
 	GtkTextView *edit = NULL;
 	GtkTextBuffer *textbuf;
 	gint body_pos = 0;
+	GtkTextIter start_iter, end_iter;
+	GtkTextMark *body_start, *body_end;
 	
 	cm_return_val_if_fail(msgview != NULL, NULL);
 
@@ -2140,15 +2142,35 @@ gchar *messageview_get_selection(MessageView *msgview)
 
 	textbuf = gtk_text_view_get_buffer(edit);
 
-	if (gtk_text_buffer_get_selection_bounds(textbuf, NULL, NULL))
+	if (gtk_text_buffer_get_selection_bounds(textbuf, NULL, NULL)) {
 		return gtkut_text_view_get_selection(edit);
-	else if (msgview->filtered) {
-		GtkTextIter start_iter, end_iter;
-		gtk_text_buffer_get_iter_at_offset(textbuf, &start_iter, body_pos);
-		gtk_text_buffer_get_end_iter(textbuf, &end_iter);
-		gtk_text_buffer_get_text(textbuf, &start_iter, &end_iter, FALSE);
-	} else
-		text = NULL;
+	} else {
+		if (msgview->filtered) {
+			gtk_text_buffer_get_iter_at_offset(textbuf, &start_iter, body_pos);
+			gtk_text_buffer_get_end_iter(textbuf, &end_iter);
+		} else {
+			body_start = gtk_text_buffer_get_mark(textbuf, "body_start");
+
+			/* If there is no body_start mark, an attachment is likely
+			 * selected, and we're looking at instructions on what to do
+			 * with it. No point in quoting that, so we'll just return NULL,
+			 * so that original message body is quoted instead down the line.
+			 */
+			if (body_start == NULL) {
+				return NULL;
+			}
+
+			gtk_text_buffer_get_iter_at_mark(textbuf, &start_iter, body_start);
+
+			body_end = gtk_text_buffer_get_mark(textbuf, "body_end");
+			if (body_end != NULL) /* Just in case */
+				gtk_text_buffer_get_iter_at_mark(textbuf, &end_iter, body_end);
+			else
+				gtk_text_buffer_get_end_iter(textbuf, &end_iter);
+		}
+
+		return gtk_text_buffer_get_text(textbuf, &start_iter, &end_iter, FALSE);
+	}
 
 	return text;
 }
diff --git a/src/textview.c b/src/textview.c
index d7420b5..0a39b7a 100644
--- a/src/textview.c
+++ b/src/textview.c
@@ -663,6 +663,7 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
 	const gchar *name;
 	gchar *content_type;
 	gint charcount;
+
 	START_TIMING("");
 
 	cm_return_if_fail(mimeinfo != NULL);
@@ -813,7 +814,17 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
 		if (prefs_common.display_header && (charcount > 0))
 			gtk_text_buffer_insert(buffer, &iter, "\n", 1);
 
+		if (!gtk_text_buffer_get_mark(buffer, "body_start")) {
+			gtk_text_buffer_get_end_iter(buffer, &iter);
+			gtk_text_buffer_create_mark(buffer, "body_start", &iter, TRUE);
+		}
+
 		textview_write_body(textview, mimeinfo);
+
+		if (!gtk_text_buffer_get_mark(buffer, "body_end")) {
+			gtk_text_buffer_get_end_iter(buffer, &iter);
+			gtk_text_buffer_create_mark(buffer, "body_end", &iter, TRUE);
+		}
 	}
 	END_TIMING();
 }
@@ -1747,6 +1758,10 @@ void textview_clear(TextView *textview)
 
 	buffer = gtk_text_view_get_buffer(text);
 	gtk_text_buffer_set_text(buffer, "", -1);
+	if (gtk_text_buffer_get_mark(buffer, "body_start"))
+		gtk_text_buffer_delete_mark_by_name(buffer, "body_start");
+	if (gtk_text_buffer_get_mark(buffer, "body_end"))
+		gtk_text_buffer_delete_mark_by_name(buffer, "body_end");
 
 	TEXTVIEW_STATUSBAR_POP(textview);
 	textview_uri_list_remove_all(textview->uri_list);

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list