# HG changeset patch # User Luke Schierer # Date 1133826089 0 # Node ID f758af0373cbab8ad206dd53e0225aabbeb6c184 # Parent e7e3144760b0073ee23946051049b42a11366797 [gaim-migrate @ 14667] this gets rid of the warnings and should express my intent more clearly committer: Tailor Script diff -r e7e3144760b0 -r f758af0373cb src/gtkconv.c --- a/src/gtkconv.c Mon Dec 05 22:50:03 2005 +0000 +++ b/src/gtkconv.c Mon Dec 05 23:41:29 2005 +0000 @@ -7563,7 +7563,7 @@ static GdkColor* generate_nick_colors(guint numcolors, GdkColor background) { - guint i = 0; + guint i = 0, j = 0; GdkColor *colors = g_new(GdkColor, numcolors); GdkColor nick_highlight; GdkColor send_color; @@ -7573,9 +7573,16 @@ srand(background.red + background.green + background.blue + 1); - for (i ; i < numcolors; ) + /* first we look through the list of "good" colors: colors that differ from every other color in the + * list. only some of them will differ from the background color though. lets see if we can find + * numcolors of them that do + */ + while (i < numcolors && j < NUM_NICK_SEED_COLORS ) { - GdkColor color = nick_seed_colors[i]; + GdkColor color = nick_seed_colors[j]; + + gaim_debug(GAIM_DEBUG_INFO, NULL, + "Looking for colors from safe list, I have found %i so far.\n",i); if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && @@ -7584,12 +7591,21 @@ colors[i] = color; i++; } - } - - for (i ; i < numcolors; ) + j++; + } + + /* we might not have found numcolors in the last loop. if we did, we'll never enter this one. + * if we did not, lets just find some colors that don't conflict with the background. its + * expensive to find colors that not only don't conflict with the background, but also do not + * conflict with each other. + */ + while(i < numcolors ) { GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; + gaim_debug(GAIM_DEBUG_WARNING, NULL, + "Looking for random colors to fill the list, I have found %i so far.\n",i); + if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0))