changeset 10858:a29815b897c0

[gaim-migrate @ 12534] this changes the background "fix" to not use the heap, and also does it for backcolor and font color, so that you can see SmarterChild in its full glory. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Fri, 22 Apr 2005 02:51:15 +0000
parents 06e71aa662af
children 310c5e6120fb
files src/gtkimhtml.c
diffstat 1 files changed, 28 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtml.c	Fri Apr 22 01:15:33 2005 +0000
+++ b/src/gtkimhtml.c	Fri Apr 22 02:51:15 2005 +0000
@@ -647,10 +647,12 @@
 			color = tag->name + 11;
 
 			if (!gdk_color_parse(color, &gcolor)) {
-				gchar *tmp = g_strdup_printf("#%s", color);
+				gchar tmp[8];
+				tmp[0] = '#';
+				strncpy(&tmp[1], color, 7);
+				tmp[7] = '\0';
 				if (!gdk_color_parse(tmp, &gcolor))
 					gdk_color_parse("white", &gcolor);
-				g_free(tmp);
 			}
 			gdk_gc_set_rgb_fg_color(gc, &gcolor);
 
@@ -3348,8 +3350,18 @@
 	g_snprintf(str, sizeof(str), "FORECOLOR %s", color);
 
 	tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str);
-	if (!tag)
-		tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", color, NULL);
+	if (!tag) {
+		GdkColor gcolor;
+		if (!gdk_color_parse(color, &gcolor)) {
+			gchar tmp[8];
+			tmp[0] = '#';
+			strncpy(&tmp[1], color, 7);
+			tmp[7] = '\0';
+			if (!gdk_color_parse(tmp, &gcolor))
+				gdk_color_parse("black", &gcolor);
+		}
+		tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", &gcolor, NULL);
+	}
 
 	return tag;
 }
@@ -3362,8 +3374,18 @@
 	g_snprintf(str, sizeof(str), "BACKCOLOR %s", color);
 
 	tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str);
-	if (!tag)
-		tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background", color, NULL);
+	if (!tag) {
+		GdkColor gcolor;
+		if (!gdk_color_parse(color, &gcolor)) {
+			gchar tmp[8];
+			tmp[0] = '#';
+			strncpy(&tmp[1], color, 7);
+			tmp[7] = '\0';
+			if (!gdk_color_parse(tmp, &gcolor))
+				gdk_color_parse("white", &gcolor);
+		}
+		tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background-gdk", &gcolor, NULL);
+	}
 
 	return tag;
 }