pidgin/pidgincolor.c

Sun, 03 Nov 2024 00:05:44 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sun, 03 Nov 2024 00:05:44 -0500
changeset 43045
308e8d0ce68c
parent 42440
0459fca48457
permissions
-rw-r--r--

remove purple3-url-handler.desktop.in.in

The application that did the launching was removed long ago. Also this should
be implemented by the user interfaces and they might provide separate files to
groups schemas as well.

Testing Done:
Called in the turtles.

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

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) {
42440
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
30 GdkRGBA background;
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
31 GChecksum *checksum = NULL;
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
32 guchar digest[20];
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
33 gsize digest_len = sizeof(digest);
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
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
42440
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
36 g_return_if_fail(color != NULL);
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
37
42440
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
38 #pragma message("figure out how to get the background color")
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
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
42440
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
41 /* hash the string and get the first 2 bytes of the digest */
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
42 checksum = g_checksum_new(G_CHECKSUM_SHA1);
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
43 if(text != NULL) {
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
44 g_checksum_update(checksum, (const guchar *)text, -1);
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
45 }
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
46 g_checksum_get_digest(checksum, digest, &digest_len);
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
47 g_checksum_free(checksum);
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
48
42440
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
49 /* Calculate the hue based on the digest. We need a value between 0 and 1
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
50 * so we divide the value by 65535 which is the maximum value for 2 bytes.
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
51 */
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
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
42440
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
54 /* Get the rgb values for the hue at full saturation and value. */
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
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
42440
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
57 /* Finally calculate the color summing 20% of the inverted background color
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
58 * with 80% of the color.
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
59 */
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
60 color->red = (0.2f * (1 - background.red)) + (0.8f * red);
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
61 color->green = (0.2f * (1 - background.green)) + (0.8f * green);
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
diff changeset
62 color->blue = (0.2f * (1 - background.blue)) + (0.8f * blue);
0459fca48457 Change #warning to #pragma message
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41522
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 }

mercurial