libpurple/purpleavatar.c

Tue, 24 Oct 2023 01:04:19 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Tue, 24 Oct 2023 01:04:19 -0500
changeset 42388
e0f4a672f85d
parent 42008
ae3fa963c1b3
child 42576
ab1ca778ddb2
permissions
-rw-r--r--

Add symbol visibility for symbols tagged with Since: 2.x

These are _only_ symbols that already have `Since: 2.x.y`.

Testing Done:
Compiled, mostly.

Bugs closed: PIDGIN-17838

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

41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * (at your option) any later version.
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * GNU General Public License for more details.
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * along with this program; if not, see <https://www.gnu.org/licenses/>.
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include "purpleavatar.h"
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 struct _PurpleAvatar {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 GObject parent;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 char *filename;
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
25
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 GdkPixbuf *pixbuf;
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
27
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
28 gboolean animated;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
29 GdkPixbufAnimation *animation;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
30
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 PurpleTags *tags;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 };
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 enum {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 PROP_0,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 PROP_FILENAME,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 PROP_PIXBUF,
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
38 PROP_ANIMATED,
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
39 PROP_ANIMATION,
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 PROP_TAGS,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 N_PROPERTIES,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 };
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 G_DEFINE_TYPE(PurpleAvatar, purple_avatar, G_TYPE_OBJECT)
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 /******************************************************************************
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
48 * Helpers
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
49 *****************************************************************************/
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
50 static void
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
51 purple_avatar_set_filename(PurpleAvatar *avatar, const char *filename) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
52 g_return_if_fail(PURPLE_IS_AVATAR(avatar));
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
53
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
54 g_free(avatar->filename);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
55 avatar->filename = g_strdup(filename);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
56
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
57 g_object_notify_by_pspec(G_OBJECT(avatar), properties[PROP_FILENAME]);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
58 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
59
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
60 static PurpleAvatar *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
61 purple_avatar_new_common(const char *filename, GdkPixbufAnimation *animation) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
62 PurpleAvatar *avatar = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
63
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
64 avatar = g_object_new(PURPLE_TYPE_AVATAR, "filename", filename, NULL);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
65
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
66 if(gdk_pixbuf_animation_is_static_image(animation)) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
67 /* If we loaded a static image, grab the static image and set it to our
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
68 * pixbuf member, clear the animation, and return the new avatar.
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
69 */
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
70
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
71 avatar->pixbuf = gdk_pixbuf_animation_get_static_image(animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
72 g_object_ref(avatar->pixbuf);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
73
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
74 g_clear_object(&animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
75 } else {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
76 /* If we did load an animation, set the appropriate properties and
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
77 * return the avatar.
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
78 */
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
79 avatar->animated = TRUE;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
80 avatar->animation = animation;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
81 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
82
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
83 return avatar;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
84 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
85
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
86 /******************************************************************************
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 * GObject Implementation
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 *****************************************************************************/
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 purple_avatar_get_property(GObject *obj, guint param_id, GValue *value,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 GParamSpec *pspec)
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 PurpleAvatar *avatar = PURPLE_AVATAR(obj);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 switch(param_id) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 case PROP_FILENAME:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 g_value_set_string(value, purple_avatar_get_filename(avatar));
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 break;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 case PROP_PIXBUF:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 g_value_set_object(value, purple_avatar_get_pixbuf(avatar));
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 break;
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
102 case PROP_ANIMATED:
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
103 g_value_set_boolean(value, purple_avatar_get_animated(avatar));
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
104 break;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
105 case PROP_ANIMATION:
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
106 g_value_set_object(value, purple_avatar_get_animation(avatar));
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
107 break;
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 case PROP_TAGS:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 g_value_set_object(value, purple_avatar_get_tags(avatar));
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 break;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 default:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 break;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 purple_avatar_set_property(GObject *obj, guint param_id, const GValue *value,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 GParamSpec *pspec)
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 PurpleAvatar *avatar = PURPLE_AVATAR(obj);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 switch(param_id) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 case PROP_FILENAME:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 purple_avatar_set_filename(avatar, g_value_get_string(value));
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 break;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 default:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 break;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 purple_avatar_finalize(GObject *obj) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 PurpleAvatar *avatar = PURPLE_AVATAR(obj);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 g_clear_pointer(&avatar->filename, g_free);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 g_clear_object(&avatar->pixbuf);
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
139 g_clear_object(&avatar->animation);
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 g_clear_object(&avatar->tags);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 G_OBJECT_CLASS(purple_avatar_parent_class)->finalize(obj);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 purple_avatar_init(PurpleAvatar *avatar) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 avatar->tags = purple_tags_new();
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 purple_avatar_class_init(PurpleAvatarClass *klass) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 obj_class->finalize = purple_avatar_finalize;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 obj_class->get_property = purple_avatar_get_property;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 obj_class->set_property = purple_avatar_set_property;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 /**
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 * PurpleAvatar:filename:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 *
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
161 * The filename that this avatar was created from.
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 * Since: 3.0.0
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 */
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 properties[PROP_FILENAME] = g_param_spec_string(
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 "filename", "filename",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 "The filename to save/load the avatar from.",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 NULL,
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
169 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 /**
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 * PurpleAvatar:pixbuf:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 *
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
174 * The [class@GdkPixbuf.Pixbuf] of the avatar. If
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
175 * [property@Purple.Avatar:animated] is %TRUE, this will be a static frame
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
176 * from the animation.
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 * Since: 3.0.0
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 */
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 properties[PROP_PIXBUF] = g_param_spec_object(
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 "pixbuf", "pixbuf",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 "The pixbuf of the avatar.",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 GDK_TYPE_PIXBUF,
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
184 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
185
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
186 /**
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
187 * PurpleAvatar:animated:
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
188 *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
189 * Whether or not this avatar is animated.
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
190 *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
191 * Since: 3.0.0
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
192 */
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
193 properties[PROP_ANIMATED] = g_param_spec_boolean(
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
194 "animated", "animated",
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
195 "Whether or not the avatar is animated.",
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
196 FALSE,
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
197 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
198
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
199 /**
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
200 * PurpleAvatar:animation:
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
201 *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
202 * The [class@GdkPixbuf.PixbufAnimation] if
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
203 * [property@Purple.Avatar:animated] is %TRUE.
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
204 *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
205 * Since: 3.0.0
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
206 */
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
207 properties[PROP_ANIMATION] = g_param_spec_object(
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
208 "animation", "animation",
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
209 "The animation of the avatar.",
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
210 GDK_TYPE_PIXBUF_ANIMATION,
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
211 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 /**
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 * PurpleAvatar:tags:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 * The [class@Purple.Tags] for the avatar.
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 * Since: 3.0.0
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 */
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 properties[PROP_TAGS] = g_param_spec_object(
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 "tags", "tags",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 "The tags for the avatar.",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 PURPLE_TYPE_TAGS,
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
224 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 /******************************************************************************
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 * Public API
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 *****************************************************************************/
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 PurpleAvatar *
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
233 purple_avatar_new_from_filename(const char *filename, GError **error) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
234 GdkPixbufAnimation *animation = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
235 GError *local_error = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
236
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
237 g_return_val_if_fail(filename != NULL, NULL);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
238
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
239 animation = gdk_pixbuf_animation_new_from_file(filename, &local_error);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
240 if(!GDK_IS_PIXBUF_ANIMATION(animation) || local_error != NULL) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
241 g_clear_object(&animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
242
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
243 g_propagate_error(error, local_error);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
244
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
245 return NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
246 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
247
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
248 return purple_avatar_new_common(filename, animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
249 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
250
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
251 PurpleAvatar *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
252 purple_avatar_new_from_resource(const char *resource_path, GError **error) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
253 GdkPixbufAnimation *animation = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
254 GError *local_error = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
255
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
256 g_return_val_if_fail(resource_path != NULL, NULL);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
257
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
258 animation = gdk_pixbuf_animation_new_from_resource(resource_path,
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
259 &local_error);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
260 if(!GDK_IS_PIXBUF_ANIMATION(animation) || local_error != NULL) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
261 g_clear_object(&animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
262
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
263 g_propagate_error(error, local_error);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
264
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
265 return NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
266 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
267
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
268 return purple_avatar_new_common(NULL, animation);
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 const char *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 purple_avatar_get_filename(PurpleAvatar *avatar) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 return avatar->filename;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 GdkPixbuf *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 purple_avatar_get_pixbuf(PurpleAvatar *avatar) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
282 if(avatar->animated) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
283 return gdk_pixbuf_animation_get_static_image(avatar->animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
284 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
285
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 return avatar->pixbuf;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
289 gboolean
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
290 purple_avatar_get_animated(PurpleAvatar *avatar) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
291 g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), FALSE);
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
293 return avatar->animated;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
294 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
295
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
296 GdkPixbufAnimation *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
297 purple_avatar_get_animation(PurpleAvatar *avatar) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
298 g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
299
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
300 return avatar->animation;
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 PurpleTags *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 purple_avatar_get_tags(PurpleAvatar *avatar) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 return avatar->tags;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 }

mercurial