pidgin/pidgincolor.c

Fri, 18 Mar 2022 00:13:23 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 18 Mar 2022 00:13:23 -0500
changeset 41305
92438aae2067
parent 41286
a0f2d660128d
child 41519
4dcf742979d3
permissions
-rw-r--r--

Remove a bunch of unused pixmaps

Testing Done:
Compiled and ran, didn't see anything missing.

It's worth noting that we've been using the logo from the resource for a long time, and the other icons were removed when we purge the `GtkStock` stuff, but there's existing items in the default icon theme for them anyways. Also we nuked the system tray stuff forever ago to.

Reviewed at https://reviews.imfreedom.org/r/1336/

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 #include "pidginstylecontext.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
26
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 * 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
29 *****************************************************************************/
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 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
31 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
32 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
33 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
34 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
35 gsize digest_len = sizeof(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
36 gdouble hue = 0, red = 0, green = 0, blue = 0;
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
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
38 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
39
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 pidgin_style_context_get_background_color(&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
41
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 /* 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
43 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
44 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
45 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
46 }
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
47 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
48 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
49
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 /* 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
51 * 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
52 */
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 hue = (digest[0] << 8 | digest[1]) / 65535.0;
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
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
55 /* Get the rgb values for the hue at full saturation and value. */
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 gtk_hsv_to_rgb(hue, 1.0, 1.0, &red, &green, &blue);
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
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 /* 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
59 * 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
60 */
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
61 color->red = (0.2 * (1 - background.red)) + (0.8 * red);
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
62 color->green = (0.2 * (1 - background.green)) + (0.8 * green);
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
63 color->blue = (0.2 * (1 - background.blue)) + (0.8 * blue);
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 color->alpha = 1.0;
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
65 }

mercurial