pidgin/pidginiconname.c

Thu, 16 Nov 2023 23:44:39 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 16 Nov 2023 23:44:39 -0600
changeset 42504
02c38caf387b
parent 42476
5b5e6297cd31
child 42509
e96a15f7f0d8
permissions
-rw-r--r--

Depend on GPlugin 0.42.1

Testing Done:
Ran `ninja turtles` without issues and noted that the ircv3 introspection was successful.

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

41027
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "pidginiconname.h"
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 /******************************************************************************
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 * Public API
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 *****************************************************************************/
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 const gchar *
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 pidgin_icon_name_from_status_primitive(PurpleStatusPrimitive primitive,
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 const gchar *fallback)
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 {
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 switch(primitive) {
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 case PURPLE_STATUS_OFFLINE:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 return "pidgin-user-offline";
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 break;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 case PURPLE_STATUS_AVAILABLE:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 return "pidgin-user-available";
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 break;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 case PURPLE_STATUS_UNAVAILABLE:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 return "pidgin-user-unavailable";
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 break;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 case PURPLE_STATUS_AWAY:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 return "pidgin-user-away";
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 break;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 case PURPLE_STATUS_INVISIBLE:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 return "pidgin-user-invisible";
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 break;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 case PURPLE_STATUS_EXTENDED_AWAY:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 return "pidgin-user-extended-away";
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 break;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 case PURPLE_STATUS_MOBILE:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 case PURPLE_STATUS_UNSET:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 default:
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 break;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 }
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 return fallback;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 }
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 const gchar *
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 pidgin_icon_name_from_status_type(PurpleStatusType *type, const gchar *fallback)
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 {
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 PurpleStatusPrimitive primitive;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 if(type == NULL) {
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 return fallback;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 }
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 primitive = purple_status_type_get_primitive(type);
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 return pidgin_icon_name_from_status_primitive(primitive, fallback);
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 }
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 const gchar *
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 pidgin_icon_name_from_status(PurpleStatus *status, const gchar *fallback) {
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 PurpleStatusType *type = NULL;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 if(!PURPLE_IS_STATUS(status)) {
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 return fallback;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 }
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 type = purple_status_get_status_type(status);
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 if(type == NULL) {
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 return fallback;
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 }
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 return pidgin_icon_name_from_status_type(type, fallback);
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 }
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
42476
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
90 const char *
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
91 pidgin_icon_name_from_presence_primitive(PurplePresencePrimitive primitive,
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
92 const char *fallback)
41027
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 {
42476
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
94 switch(primitive) {
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
95 case PURPLE_PRESENCE_PRIMITIVE_OFFLINE:
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
96 return "pidgin-user-offline";
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
97 break;
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
98 case PURPLE_PRESENCE_PRIMITIVE_AVAILABLE:
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
99 return "pidgin-user-available";
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
100 break;
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
101 case PURPLE_PRESENCE_PRIMITIVE_IDLE:
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
102 return "pidgin-user-unavailable";
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
103 break;
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
104 case PURPLE_PRESENCE_PRIMITIVE_INVISIBLE:
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
105 return "pidgin-user-invisible";
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
106 break;
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
107 case PURPLE_PRESENCE_PRIMITIVE_AWAY:
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
108 return "pidgin-user-away";
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
109 break;
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
110 case PURPLE_PRESENCE_PRIMITIVE_EXTENDED_AWAY:
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
111 return "pidgin-user-extended-away";
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
112 break;
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
113 case PURPLE_PRESENCE_PRIMITIVE_STREAMING:
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
114 /* TODO: get an icon for streaming. */
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
115 default:
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
116 break;
41027
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 }
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118
42476
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
119 return fallback;
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
120 }
41027
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
42476
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
122 const char *
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
123 pidgin_icon_name_from_presence(PurplePresence *presence, const char *fallback)
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
124 {
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
125 PurplePresencePrimitive primitive;
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
126
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
127 primitive = purple_presence_get_primitive(presence);
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
128
5b5e6297cd31 Add a pidgin_icon_name_from_presence_primitive
Gary Kramlich <grim@reaperworld.com>
parents: 42164
diff changeset
129 return pidgin_icon_name_from_presence_primitive(primitive, fallback);
41027
aa0e688f2f46 Add a bunch of icon name utility functions
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 }

mercurial