[gaim-migrate @ 15143]

Mon, 09 Jan 2006 16:04:04 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Mon, 09 Jan 2006 16:04:04 +0000
changeset 12796
8fb3611a91e1
parent 12795
83d09a3b4e3c
child 12797
d0f51cfde6bc

[gaim-migrate @ 15143]
(The Last) Part of SF Patch #1400162 from Sadrul

"Do not change the format when
the imhtml is not editable. Also, reset the formatting
for the whole buffer when the imhtml has whole-buffer
formatting on, or the selected text otherwise."

Plus a change from me: If no text is selected, clear the formatting on the whole buffer.

committer: Richard Laager <rlaager@pidgin.im>

src/gtkimhtml.c file | annotate | diff | comparison | revisions
--- a/src/gtkimhtml.c	Mon Jan 09 15:39:51 2006 +0000
+++ b/src/gtkimhtml.c	Mon Jan 09 16:04:04 2006 +0000
@@ -3728,16 +3728,14 @@
 {
 	GtkTextIter start, end;
 
-	gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
-
-	/* Move the selection bounds (to select everything), so the format functions
-	 * will know we want to manipulate the formatting on the entire buffer. */
-#if GTK_CHECK_VERSION(2,4,0)
-	gtk_text_buffer_select_range(imhtml->text_buffer, &end, &start);
-#else
-	gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &end);
-	gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &start);
-#endif
+	if (!imhtml->editable)
+		return;
+
+	if (imhtml->wbfo)
+		gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
+	else
+		if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end))
+			gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end);
 
 	gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end);
 	gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end);
@@ -3758,14 +3756,6 @@
 	imhtml->edit.forecolor = NULL;
 	imhtml->edit.backcolor = NULL;
 	imhtml->edit.background = NULL;
-
-	/* Remove the selection, placing the cursor at the end. */
-#if GTK_CHECK_VERSION(2,4,0)
-	gtk_text_buffer_select_range(imhtml->text_buffer, &end, &end);
-#else
-	gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &end);
-	gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &end);
-#endif
 }
 
 /* Editable stuff */

mercurial