changeset 8428:018406bb4ab6

[gaim-migrate @ 9158] These fixes are going to come in rapid succession until I have to leave. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 11 Mar 2004 20:18:38 +0000
parents 2e18099ded93
children 1b6c43246cf6
files src/gtkimhtml.c
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtml.c	Thu Mar 11 20:02:00 2004 +0000
+++ b/src/gtkimhtml.c	Thu Mar 11 20:18:38 2004 +0000
@@ -2527,8 +2527,18 @@
 		imhtml->edit.bold = span;
 		imhtml->format_spans = g_list_append(imhtml->format_spans, span);
 	} else {
+		GtkTextIter start;
 		span = imhtml->edit.bold;
 		span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
+		gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, span->start);
+		if (gtk_text_iter_equal(&start, &iter)) { /* Format turned off before any text was entered, so remove the tag */
+			imhtml->format_spans = g_list_remove(imhtml->format_spans, span);
+			if (span->start_tag)
+				g_free(span->start_tag);
+			if (span->end_tag)
+				g_free(span->end_tag);
+			g_free(span);
+		}
 		imhtml->edit.bold = NULL;
 	}
 	return imhtml->edit.bold != NULL;
@@ -2551,8 +2561,18 @@
 		imhtml->edit.italic = span;
 		imhtml->format_spans = g_list_append(imhtml->format_spans, span);
 	} else {
+		GtkTextIter start;
 		span = imhtml->edit.italic;
 		span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
+		gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, span->start);
+		if (gtk_text_iter_equal(&start, &iter)) { /* Format turned off before any text was entered, so remove the tag */
+			imhtml->format_spans = g_list_remove(imhtml->format_spans, span);
+			if (span->start_tag)
+				g_free(span->start_tag);
+			if (span->end_tag)
+				g_free(span->end_tag);
+			g_free(span);
+		}
 		imhtml->edit.italic = NULL;
 	}
 	return imhtml->edit.italic != NULL;
@@ -2575,8 +2595,18 @@
 		imhtml->edit.underline = span;
 		imhtml->format_spans = g_list_append(imhtml->format_spans, span);
 	} else {
+		GtkTextIter start;
 		span = imhtml->edit.underline;
 		span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
+		gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, span->start);
+		if (gtk_text_iter_equal(&start, &iter)) { /* Format turned off before any text was entered, so remove the tag */
+			imhtml->format_spans = g_list_remove(imhtml->format_spans, span);
+			if (span->start_tag)
+				g_free(span->start_tag);
+			if (span->end_tag)
+				g_free(span->end_tag);
+			g_free(span);
+		}
 		imhtml->edit.underline = NULL;
 	}
 	return imhtml->edit.underline != NULL;
@@ -2938,6 +2968,7 @@
 		closers = g_list_remove(closers, span);
 
 	}
+	printf("gotten: %s\n", str->str);
 	return g_string_free(str, FALSE);
 }