| 39 |
39 |
| 40 pidgin_style_context_get_background_color(&background); |
40 pidgin_style_context_get_background_color(&background); |
| 41 |
41 |
| 42 /* hash the string and get the first 2 bytes of the digest */ |
42 /* hash the string and get the first 2 bytes of the digest */ |
| 43 checksum = g_checksum_new(G_CHECKSUM_SHA1); |
43 checksum = g_checksum_new(G_CHECKSUM_SHA1); |
| 44 g_checksum_update(checksum, (const guchar *)text, -1); |
44 if(text != NULL) { |
| |
45 g_checksum_update(checksum, (const guchar *)text, -1); |
| |
46 } |
| 45 g_checksum_get_digest(checksum, digest, &digest_len); |
47 g_checksum_get_digest(checksum, digest, &digest_len); |
| 46 g_checksum_free(checksum); |
48 g_checksum_free(checksum); |
| 47 |
49 |
| 48 /* Calculate the hue based on the digest. We need a value between 0 and 1 |
50 /* Calculate the hue based on the digest. We need a value between 0 and 1 |
| 49 * so we divide the value by 65535 which is the maximum value for 2 bytes. |
51 * so we divide the value by 65535 which is the maximum value for 2 bytes. |