Mercurial > pidgin
comparison src/gtkconv.c @ 12363:f758af0373cb
[gaim-migrate @ 14667]
this gets rid of the warnings and should express my intent more clearly
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 05 Dec 2005 23:41:29 +0000 |
parents | 3153661f4d5c |
children | 4ed7663099ca |
comparison
equal
deleted
inserted
replaced
12362:e7e3144760b0 | 12363:f758af0373cb |
---|---|
7561 | 7561 |
7562 | 7562 |
7563 static GdkColor* | 7563 static GdkColor* |
7564 generate_nick_colors(guint numcolors, GdkColor background) | 7564 generate_nick_colors(guint numcolors, GdkColor background) |
7565 { | 7565 { |
7566 guint i = 0; | 7566 guint i = 0, j = 0; |
7567 GdkColor *colors = g_new(GdkColor, numcolors); | 7567 GdkColor *colors = g_new(GdkColor, numcolors); |
7568 GdkColor nick_highlight; | 7568 GdkColor nick_highlight; |
7569 GdkColor send_color; | 7569 GdkColor send_color; |
7570 | 7570 |
7571 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); | 7571 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); |
7572 gdk_color_parse(SEND_COLOR, &send_color); | 7572 gdk_color_parse(SEND_COLOR, &send_color); |
7573 | 7573 |
7574 srand(background.red + background.green + background.blue + 1); | 7574 srand(background.red + background.green + background.blue + 1); |
7575 | 7575 |
7576 for (i ; i < numcolors; ) | 7576 /* first we look through the list of "good" colors: colors that differ from every other color in the |
7577 * list. only some of them will differ from the background color though. lets see if we can find | |
7578 * numcolors of them that do | |
7579 */ | |
7580 while (i < numcolors && j < NUM_NICK_SEED_COLORS ) | |
7577 { | 7581 { |
7578 GdkColor color = nick_seed_colors[i]; | 7582 GdkColor color = nick_seed_colors[j]; |
7583 | |
7584 gaim_debug(GAIM_DEBUG_INFO, NULL, | |
7585 "Looking for colors from safe list, I have found %i so far.\n",i); | |
7579 | 7586 |
7580 if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && | 7587 if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && |
7581 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && | 7588 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
7582 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) | 7589 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
7583 { | 7590 { |
7584 colors[i] = color; | 7591 colors[i] = color; |
7585 i++; | 7592 i++; |
7586 } | 7593 } |
7587 } | 7594 j++; |
7588 | 7595 } |
7589 for (i ; i < numcolors; ) | 7596 |
7597 /* we might not have found numcolors in the last loop. if we did, we'll never enter this one. | |
7598 * if we did not, lets just find some colors that don't conflict with the background. its | |
7599 * expensive to find colors that not only don't conflict with the background, but also do not | |
7600 * conflict with each other. | |
7601 */ | |
7602 while(i < numcolors ) | |
7590 { | 7603 { |
7591 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; | 7604 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; |
7605 | |
7606 gaim_debug(GAIM_DEBUG_WARNING, NULL, | |
7607 "Looking for random colors to fill the list, I have found %i so far.\n",i); | |
7592 | 7608 |
7593 if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && | 7609 if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && |
7594 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && | 7610 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
7595 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) | 7611 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
7596 { | 7612 { |