libpurple/purpleavatar.c

Mon, 13 May 2024 23:28:20 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Mon, 13 May 2024 23:28:20 -0500
changeset 42767
8cf1d11b59c1
parent 42613
780d7efe37c2
child 42841
fbb5c5cb37f4
permissions
-rw-r--r--

Use g_set_str everywhere

This simplifies many setters.

Testing Done:
Ran `ninja turtles`

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

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 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
7 * source distribution.
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
12 * any later version.
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
17 * more details.
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
18 *
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpleavatar.h"
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 struct _PurpleAvatar {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 GObject parent;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 char *filename;
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
29
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 GdkPixbuf *pixbuf;
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
31
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
32 gboolean animated;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
33 GdkPixbufAnimation *animation;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
34
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 PurpleTags *tags;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 };
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 enum {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PROP_0,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 PROP_FILENAME,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PROP_PIXBUF,
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
42 PROP_ANIMATED,
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
43 PROP_ANIMATION,
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_TAGS,
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 N_PROPERTIES,
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 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
42576
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42008
diff changeset
49 G_DEFINE_FINAL_TYPE(PurpleAvatar, purple_avatar, G_TYPE_OBJECT)
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 /******************************************************************************
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
52 * Helpers
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 static void
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
55 purple_avatar_set_filename(PurpleAvatar *avatar, const char *filename) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
56 g_return_if_fail(PURPLE_IS_AVATAR(avatar));
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
57
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42613
diff changeset
58 if(g_set_str(&avatar->filename, filename)) {
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42613
diff changeset
59 g_object_notify_by_pspec(G_OBJECT(avatar), properties[PROP_FILENAME]);
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42613
diff changeset
60 }
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
61 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
62
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
63 static PurpleAvatar *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
64 purple_avatar_new_common(const char *filename, GdkPixbufAnimation *animation) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
65 PurpleAvatar *avatar = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
66
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
67 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
68
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
69 if(gdk_pixbuf_animation_is_static_image(animation)) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
70 /* 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
71 * 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
72 */
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 avatar->pixbuf = gdk_pixbuf_animation_get_static_image(animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
75 g_object_ref(avatar->pixbuf);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
76
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
77 g_clear_object(&animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
78 } else {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
79 /* 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
80 * return the avatar.
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 avatar->animated = TRUE;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
83 avatar->animation = animation;
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 return avatar;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
87 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
88
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
89 /******************************************************************************
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 * GObject Implementation
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 *****************************************************************************/
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 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
94 GParamSpec *pspec)
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 PurpleAvatar *avatar = PURPLE_AVATAR(obj);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 switch(param_id) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 case PROP_FILENAME:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 g_value_set_string(value, purple_avatar_get_filename(avatar));
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 break;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 case PROP_PIXBUF:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 g_value_set_object(value, purple_avatar_get_pixbuf(avatar));
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 break;
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
105 case PROP_ANIMATED:
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
106 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
107 break;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
108 case PROP_ANIMATION:
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
109 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
110 break;
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 case PROP_TAGS:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 g_value_set_object(value, purple_avatar_get_tags(avatar));
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 default:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 break;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 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
122 GParamSpec *pspec)
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 PurpleAvatar *avatar = PURPLE_AVATAR(obj);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 switch(param_id) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 case PROP_FILENAME:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 purple_avatar_set_filename(avatar, g_value_get_string(value));
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 default:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 break;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 purple_avatar_finalize(GObject *obj) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 PurpleAvatar *avatar = PURPLE_AVATAR(obj);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 g_clear_pointer(&avatar->filename, g_free);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 g_clear_object(&avatar->pixbuf);
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
142 g_clear_object(&avatar->animation);
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 g_clear_object(&avatar->tags);
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 G_OBJECT_CLASS(purple_avatar_parent_class)->finalize(obj);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 purple_avatar_init(PurpleAvatar *avatar) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 avatar->tags = purple_tags_new();
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 static void
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 purple_avatar_class_init(PurpleAvatarClass *klass) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 obj_class->finalize = purple_avatar_finalize;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 obj_class->get_property = purple_avatar_get_property;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 obj_class->set_property = purple_avatar_set_property;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 /**
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 * PurpleAvatar:filename:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 *
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
164 * The filename that this avatar was created from.
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 *
42613
780d7efe37c2 Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
166 * Since: 3.0
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 */
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 properties[PROP_FILENAME] = g_param_spec_string(
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 "filename", "filename",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 "The filename to save/load the avatar from.",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 NULL,
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
172 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
173
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 /**
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 * PurpleAvatar:pixbuf:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 *
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
177 * The [class@GdkPixbuf.Pixbuf] of the avatar. If
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
178 * [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
179 * from the animation.
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 *
42613
780d7efe37c2 Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
181 * Since: 3.0
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 */
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 properties[PROP_PIXBUF] = g_param_spec_object(
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 "pixbuf", "pixbuf",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 "The pixbuf of the avatar.",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 GDK_TYPE_PIXBUF,
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
187 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
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 /**
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
190 * PurpleAvatar:animated:
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
191 *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
192 * Whether or not this avatar is animated.
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
193 *
42613
780d7efe37c2 Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
194 * Since: 3.0
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
195 */
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
196 properties[PROP_ANIMATED] = g_param_spec_boolean(
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
197 "animated", "animated",
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
198 "Whether or not the avatar is animated.",
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
199 FALSE,
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
200 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
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 /**
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
203 * PurpleAvatar:animation:
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 * The [class@GdkPixbuf.PixbufAnimation] if
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
206 * [property@Purple.Avatar:animated] is %TRUE.
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
207 *
42613
780d7efe37c2 Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
208 * Since: 3.0
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
209 */
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
210 properties[PROP_ANIMATION] = g_param_spec_object(
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
211 "animation", "animation",
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
212 "The animation of the avatar.",
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
213 GDK_TYPE_PIXBUF_ANIMATION,
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
214 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
41966
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 /**
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 * PurpleAvatar:tags:
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 * The [class@Purple.Tags] for the avatar.
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 *
42613
780d7efe37c2 Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
221 * Since: 3.0
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 */
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 properties[PROP_TAGS] = g_param_spec_object(
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 "tags", "tags",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 "The tags for the avatar.",
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 PURPLE_TYPE_TAGS,
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
227 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
41966
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 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 }
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 /******************************************************************************
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 * Public API
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 *****************************************************************************/
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 PurpleAvatar *
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
236 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
237 GdkPixbufAnimation *animation = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
238 GError *local_error = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
239
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
240 g_return_val_if_fail(filename != NULL, NULL);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
241
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
242 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
243 if(!GDK_IS_PIXBUF_ANIMATION(animation) || local_error != NULL) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
244 g_clear_object(&animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
245
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
246 g_propagate_error(error, local_error);
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 NULL;
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 return purple_avatar_new_common(filename, animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
252 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
253
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
254 PurpleAvatar *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
255 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
256 GdkPixbufAnimation *animation = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
257 GError *local_error = NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
258
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
259 g_return_val_if_fail(resource_path != NULL, NULL);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
260
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
261 animation = gdk_pixbuf_animation_new_from_resource(resource_path,
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
262 &local_error);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
263 if(!GDK_IS_PIXBUF_ANIMATION(animation) || local_error != NULL) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
264 g_clear_object(&animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
265
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
266 g_propagate_error(error, local_error);
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 NULL;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
269 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
270
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
271 return purple_avatar_new_common(NULL, animation);
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 const char *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 purple_avatar_get_filename(PurpleAvatar *avatar) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL);
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 return avatar->filename;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 GdkPixbuf *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 purple_avatar_get_pixbuf(PurpleAvatar *avatar) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
285 if(avatar->animated) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
286 return gdk_pixbuf_animation_get_static_image(avatar->animation);
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
287 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
288
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 return avatar->pixbuf;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
292 gboolean
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
293 purple_avatar_get_animated(PurpleAvatar *avatar) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
294 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
295
42008
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
296 return avatar->animated;
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
297 }
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
298
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
299 GdkPixbufAnimation *
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
300 purple_avatar_get_animation(PurpleAvatar *avatar) {
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
301 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
302
ae3fa963c1b3 Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents: 41966
diff changeset
303 return avatar->animation;
41966
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 }
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 PurpleTags *
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 purple_avatar_get_tags(PurpleAvatar *avatar) {
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL);
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 return avatar->tags;
c7bcaf2f41ef Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 }

mercurial