changeset 4171:858822a27529

[gaim-migrate @ 4400] Alex Converse (alex4): "Gaim had a nasty habbit of not converting prefrenced colors from 48-bit to 24-bit for outputting as html. (causing malformed colors like #00FFFF00) I fixed this by doing all the conversions at the time of outputting." he further wrote, when i failed to see a need for this patch at first: "The issue is GdkColors are 48-bit (16 of Red, green, and blue) HTML colors are 24-bit (bit of Red, Green, and Blue) gaim stores colors as GdkColors but when sends the color as HTML. The problem is colors that were stored inb gaimrc never got downsampled to 24bit." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 02 Jan 2003 16:24:53 +0000
parents 11e643c9ef51
children 88ebcfcc3217
files src/conversation.c src/dialogs.c src/util.c
diffstat 3 files changed, 25 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Thu Jan 02 15:55:22 2003 +0000
+++ b/src/conversation.c	Thu Jan 02 16:24:53 2003 +0000
@@ -1252,14 +1252,14 @@
 		}
 
 		if ((font_options & OPT_FONT_FGCOL) || c->hasfg) {
-			g_snprintf(buf2, limit, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", c->fgcol.red,
-				   c->fgcol.green, c->fgcol.blue, buf);
+			g_snprintf(buf2, limit, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", 
+				   c->fgcol.red/256, c->fgcol.green/256, c->fgcol.blue/256, buf);
 			strcpy(buf, buf2);
 		}
 
 		if ((font_options & OPT_FONT_BGCOL) || c->hasbg) {
 			g_snprintf(buf2, limit, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>",
-				   c->bgcol.red, c->bgcol.green, c->bgcol.blue, buf);
+				   c->bgcol.red/256, c->bgcol.green/256, c->bgcol.blue/256, buf);
 			strcpy(buf, buf2);
 		}
 	}
--- a/src/dialogs.c	Thu Jan 02 15:55:22 2003 +0000
+++ b/src/dialogs.c	Thu Jan 02 16:24:53 2003 +0000
@@ -3026,16 +3026,12 @@
 	c = gtk_object_get_user_data(GTK_OBJECT(colorsel));
 	/* GTK_IS_EDITABLE(c->entry); huh? */
 
-	text_color.red = text_color.red / 256;
-	text_color.green = text_color.green / 256;
-	text_color.blue = text_color.blue / 256;
-	
 	c->fgcol = text_color;
 	c->hasfg = 1;
-	g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green,
-		   text_color.blue);
+	g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red/256, 
+		   text_color.green/256, text_color.blue/256);
 	surround(c, open_tag, "</FONT>");
-	debug_printf("#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue);
+	debug_printf("#%02X%02X%02X\n", text_color.red/256, text_color.green/256, text_color.blue/256);
 	g_free(open_tag);
 	cancel_fgcolor(NULL, c);
 }
@@ -3053,16 +3049,12 @@
 	c = gtk_object_get_user_data(GTK_OBJECT(colorsel));
 	/* GTK_IS_EDITABLE(c->entry); huh? */
 
-	text_color.red = text_color.red / 256;
-	text_color.green = text_color.green / 256;
-	text_color.blue = text_color.blue / 256;
-
 	c->bgcol = text_color;
 	c->hasbg = 1;
-	g_snprintf(open_tag, 25, "<BODY BGCOLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green,
-		   text_color.blue);
+	g_snprintf(open_tag, 25, "<BODY BGCOLOR=\"#%02X%02X%02X\">", text_color.red/256, 
+		   text_color.green/256, text_color.blue/256);
 	surround(c, open_tag, "</BODY>");
-	debug_printf("#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue);
+	debug_printf("#%02X%02X%02X\n", text_color.red/256, text_color.green/256, text_color.blue/256);
 	g_free(open_tag);
 	cancel_bgcolor(NULL, c);
 }
@@ -3075,9 +3067,9 @@
 	if (color == NULL) {	/* we came from the prefs */
 		if (fgcseld)
 			return;
-		fgclr[0] = (gdouble)(fgcolor.red) / 255;
-		fgclr[1] = (gdouble)(fgcolor.green) / 255;
-		fgclr[2] = (gdouble)(fgcolor.blue) / 255;
+		fgclr[0] = (gdouble)(fgcolor.red) ;
+		fgclr[1] = (gdouble)(fgcolor.green);
+		fgclr[2] = (gdouble)(fgcolor.blue);
 
 		fgcseld = gtk_color_selection_dialog_new(_("Select Text Color"));
 		gtk_color_selection_set_color(GTK_COLOR_SELECTION
@@ -3095,9 +3087,9 @@
 	}
 
 	if (!c->fg_color_dialog) {
-		fgclr[0] = (gdouble)(c->fgcol.red) / 255;
-		fgclr[1] = (gdouble)(c->fgcol.green) / 255;
-		fgclr[2] = (gdouble)(c->fgcol.blue) / 255;
+		fgclr[0] = (gdouble)(c->fgcol.red);
+		fgclr[1] = (gdouble)(c->fgcol.green);
+		fgclr[2] = (gdouble)(c->fgcol.blue);
 
 		c->fg_color_dialog = gtk_color_selection_dialog_new(_("Select Text Color"));
 		colorsel = GTK_COLOR_SELECTION_DIALOG(c->fg_color_dialog)->colorsel;
@@ -3127,9 +3119,9 @@
 	if (color == NULL) {	/* we came from the prefs */
 		if (bgcseld)
 			return;
-		bgclr[0] = (gdouble)(bgcolor.red) / 255;
-		bgclr[1] = (gdouble)(bgcolor.green) / 255;
-		bgclr[2] = (gdouble)(bgcolor.blue) / 255;
+		bgclr[0] = (gdouble)(bgcolor.red);
+		bgclr[1] = (gdouble)(bgcolor.green);
+		bgclr[2] = (gdouble)(bgcolor.blue);
 
 		bgcseld = gtk_color_selection_dialog_new(_("Select Background Color"));
 		gtk_color_selection_set_color(GTK_COLOR_SELECTION
@@ -3147,9 +3139,9 @@
 	}
 
 	if (!c->bg_color_dialog) {
-		bgclr[0] = (gdouble)(c->bgcol.red) / 255;
-		bgclr[1] = (gdouble)(c->bgcol.green) / 255;
-		bgclr[2] = (gdouble)(c->bgcol.blue) / 255;
+		bgclr[0] = (gdouble)(c->bgcol.red);
+		bgclr[1] = (gdouble)(c->bgcol.green);
+		bgclr[2] = (gdouble)(c->bgcol.blue);
 
 		c->bg_color_dialog = gtk_color_selection_dialog_new(_("Select Background Color"));
 		colorsel = GTK_COLOR_SELECTION_DIALOG(c->bg_color_dialog)->colorsel;
--- a/src/util.c	Thu Jan 02 15:55:22 2003 +0000
+++ b/src/util.c	Thu Jan 02 16:24:53 2003 +0000
@@ -776,14 +776,14 @@
 	}
 
 	if (font_options & OPT_FONT_FGCOL) {
-		g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", fgcolor.red,
-			   fgcolor.green, fgcolor.blue, buf);
+		g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", fgcolor.red/256,
+			   fgcolor.green/256, fgcolor.blue/256, buf);
 		strcpy(buf, tmp);
 	}
 
 	if (font_options & OPT_FONT_BGCOL) {
-		g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", bgcolor.red,
-			   bgcolor.green, bgcolor.blue, buf);
+		g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", bgcolor.red/256,
+			   bgcolor.green/256, bgcolor.blue/256, buf);
 		strcpy(buf, tmp);
 	}