comparison src/gtkconv.c @ 12346:f81d458aba18

[gaim-migrate @ 14650] A couple minor changes to the style of Tak's patch that Luke just committed. I removed a couple '1 *'s because they're irrelevant (* has higher precendence than + and 1 is the identity of *). If they belong in the calculation, then some ()s are needed. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 05 Dec 2005 05:22:47 +0000
parents f6fa5d742c76
children af152afe7bac
comparison
equal deleted inserted replaced
12345:f6fa5d742c76 12346:f81d458aba18
4070 if (hidden) 4070 if (hidden)
4071 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); 4071 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv);
4072 else 4072 else
4073 gaim_gtkconv_placement_place(gtkconv); 4073 gaim_gtkconv_placement_place(gtkconv);
4074 4074
4075 if(NULL == nick_colors) 4075 if (nick_colors == NULL)
4076 nick_colors = generate_nick_colors(NUM_NICK_COLORS, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]); 4076 nick_colors = generate_nick_colors(NUM_NICK_COLORS, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]);
4077 } 4077 }
4078 4078
4079 static void 4079 static void
4080 gaim_gtkconv_new_hidden(GaimConversation *conv) 4080 gaim_gtkconv_new_hidden(GaimConversation *conv)
7510 7510
7511 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ 7511 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */
7512 gboolean 7512 gboolean
7513 color_is_visible(GdkColor foreground, GdkColor background) 7513 color_is_visible(GdkColor foreground, GdkColor background)
7514 { 7514 {
7515 gulong fg_brightness, 7515 gulong fg_brightness;
7516 bg_brightness, 7516 gulong bg_brightness;
7517 br_diff, 7517 gulong br_diff;
7518 col_diff; 7518 gulong col_diff;
7519 7519
7520 fg_brightness = (foreground.red * 299 + foreground.green * 587 + foreground.blue * 114) / 1000; 7520 fg_brightness = (foreground.red * 299 + foreground.green * 587 + foreground.blue * 114) / 1000;
7521 bg_brightness = (background.red * 299 + background.green * 587 + background.blue * 114) / 1000; 7521 bg_brightness = (background.red * 299 + background.green * 587 + background.blue * 114) / 1000;
7522 br_diff = abs(fg_brightness - bg_brightness); 7522 br_diff = abs(fg_brightness - bg_brightness);
7523 7523
7529 7529
7530 GdkColor* 7530 GdkColor*
7531 generate_nick_colors(guint numcolors, GdkColor background) 7531 generate_nick_colors(guint numcolors, GdkColor background)
7532 { 7532 {
7533 guint i; 7533 guint i;
7534 GdkColor *colors = (GdkColor*)g_malloc(numcolors * sizeof(GdkColor)); 7534 GdkColor *colors = g_new(GdkColor, numcolors);
7535 7535
7536 srand(background.red + 1 * background.green + 1 * background.blue + 1); 7536 srand(background.red + background.green + background.blue + 1);
7537 7537
7538 for(i = 0; i < numcolors;){ 7538 for (i = 0; i < numcolors; )
7539 GdkColor color = { 0, rand()%65536, rand()%65536, rand()%65536 }; 7539 {
7540 if(color_is_visible(color, background)){ 7540 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 };
7541 if (color_is_visible(color, background)){
7541 colors[i] = color; 7542 colors[i] = color;
7542 i++; 7543 i++;
7543 } 7544 }
7544 } 7545 }
7545 7546