Wed, 24 Aug 2022 21:18:06 -0500
Remove the custom css setup for now as it's throwing a GWarning and we need to plan this out more.
Testing Done:
Ran and verified the warning was gone.
Reviewed at https://reviews.imfreedom.org/r/1636/
|
40951
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Pidgin - Internet Messenger |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "pidgincolor.h" |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | /****************************************************************************** |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | * Public API |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | *****************************************************************************/ |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | void |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | pidgin_color_calculate_for_text(const gchar *text, GdkRGBA *color) { |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | GdkRGBA background; |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | GChecksum *checksum = NULL; |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | guchar digest[20]; |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | gsize digest_len = sizeof(digest); |
|
41522
e87f6a720a98
Fix some warning related to the parameter datatype change in gtk_hsv_to_rgb
Gary Kramlich <grim@reaperworld.com>
parents:
41521
diff
changeset
|
34 | gfloat hue = 0, red = 0, green = 0, blue = 0; |
|
40951
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | g_return_if_fail(color != NULL); |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | |
|
41519
4dcf742979d3
Remove the pidgin_style_context API as it's all deprecated.
Gary Kramlich <grim@reaperworld.com>
parents:
41286
diff
changeset
|
38 | #warning figure out how to get the background color |
|
4dcf742979d3
Remove the pidgin_style_context API as it's all deprecated.
Gary Kramlich <grim@reaperworld.com>
parents:
41286
diff
changeset
|
39 | gdk_rgba_parse(&background, "#FFFFFFFF"); |
|
40951
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | /* hash the string and get the first 2 bytes of the digest */ |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | checksum = g_checksum_new(G_CHECKSUM_SHA1); |
|
41286
a0f2d660128d
GChecksum throws a warning if you pass NULL to append so let's stop doing that
Gary Kramlich <grim@reaperworld.com>
parents:
40951
diff
changeset
|
43 | if(text != NULL) { |
|
a0f2d660128d
GChecksum throws a warning if you pass NULL to append so let's stop doing that
Gary Kramlich <grim@reaperworld.com>
parents:
40951
diff
changeset
|
44 | g_checksum_update(checksum, (const guchar *)text, -1); |
|
a0f2d660128d
GChecksum throws a warning if you pass NULL to append so let's stop doing that
Gary Kramlich <grim@reaperworld.com>
parents:
40951
diff
changeset
|
45 | } |
|
40951
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | g_checksum_get_digest(checksum, digest, &digest_len); |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | g_checksum_free(checksum); |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | /* Calculate the hue based on the digest. We need a value between 0 and 1 |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | * so we divide the value by 65535 which is the maximum value for 2 bytes. |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | */ |
|
41522
e87f6a720a98
Fix some warning related to the parameter datatype change in gtk_hsv_to_rgb
Gary Kramlich <grim@reaperworld.com>
parents:
41521
diff
changeset
|
52 | hue = (digest[0] << 8 | digest[1]) / 65535.0f; |
|
40951
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | /* Get the rgb values for the hue at full saturation and value. */ |
|
41522
e87f6a720a98
Fix some warning related to the parameter datatype change in gtk_hsv_to_rgb
Gary Kramlich <grim@reaperworld.com>
parents:
41521
diff
changeset
|
55 | gtk_hsv_to_rgb(hue, 1.0f, 1.0f, &red, &green, &blue); |
|
40951
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | /* Finally calculate the color summing 20% of the inverted background color |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | * with 80% of the color. |
|
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | */ |
|
41522
e87f6a720a98
Fix some warning related to the parameter datatype change in gtk_hsv_to_rgb
Gary Kramlich <grim@reaperworld.com>
parents:
41521
diff
changeset
|
60 | color->red = (0.2f * (1 - background.red)) + (0.8f * red); |
|
e87f6a720a98
Fix some warning related to the parameter datatype change in gtk_hsv_to_rgb
Gary Kramlich <grim@reaperworld.com>
parents:
41521
diff
changeset
|
61 | color->green = (0.2f * (1 - background.green)) + (0.8f * green); |
|
e87f6a720a98
Fix some warning related to the parameter datatype change in gtk_hsv_to_rgb
Gary Kramlich <grim@reaperworld.com>
parents:
41521
diff
changeset
|
62 | color->blue = (0.2f * (1 - background.blue)) + (0.8f * blue); |
|
e87f6a720a98
Fix some warning related to the parameter datatype change in gtk_hsv_to_rgb
Gary Kramlich <grim@reaperworld.com>
parents:
41521
diff
changeset
|
63 | color->alpha = 1.0f; |
|
40951
c83bf354d142
Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | } |