Thu, 22 Feb 2024 06:03:16 -0600
Add a favorite property to PurpleContactInfo
This will be used in the future for toggling whether or not contacts are
favorited or starred.
Testing Done:
Ran the unit tests under valgrind.
Reviewed at https://reviews.imfreedom.org/r/2965/
|
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 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
58 | g_free(avatar->filename); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
59 | avatar->filename = g_strdup(filename); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
60 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
61 | 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
|
62 | } |
|
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 | static PurpleAvatar * |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
65 | purple_avatar_new_common(const char *filename, GdkPixbufAnimation *animation) { |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
66 | PurpleAvatar *avatar = NULL; |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
67 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
68 | 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
|
69 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
70 | if(gdk_pixbuf_animation_is_static_image(animation)) { |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
71 | /* 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
|
72 | * 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
|
73 | */ |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
74 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
75 | avatar->pixbuf = gdk_pixbuf_animation_get_static_image(animation); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
76 | g_object_ref(avatar->pixbuf); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
77 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
78 | g_clear_object(&animation); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
79 | } else { |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
80 | /* 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
|
81 | * return the avatar. |
|
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 | avatar->animated = TRUE; |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
84 | avatar->animation = animation; |
|
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 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
87 | return avatar; |
|
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 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
90 | /****************************************************************************** |
|
41966
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | * GObject Implementation |
|
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 | static void |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | 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
|
95 | GParamSpec *pspec) |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | PurpleAvatar *avatar = PURPLE_AVATAR(obj); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | switch(param_id) { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | case PROP_FILENAME: |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | g_value_set_string(value, purple_avatar_get_filename(avatar)); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | break; |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | case PROP_PIXBUF: |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | g_value_set_object(value, purple_avatar_get_pixbuf(avatar)); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | break; |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
106 | case PROP_ANIMATED: |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
107 | 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
|
108 | break; |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
109 | case PROP_ANIMATION: |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
110 | 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
|
111 | break; |
|
41966
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | case PROP_TAGS: |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | g_value_set_object(value, purple_avatar_get_tags(avatar)); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | break; |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | default: |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | break; |
|
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 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | static void |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | 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
|
123 | GParamSpec *pspec) |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | PurpleAvatar *avatar = PURPLE_AVATAR(obj); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | switch(param_id) { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | case PROP_FILENAME: |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | purple_avatar_set_filename(avatar, g_value_get_string(value)); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | break; |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | default: |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | break; |
|
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 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | static void |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | purple_avatar_finalize(GObject *obj) { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | PurpleAvatar *avatar = PURPLE_AVATAR(obj); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | g_clear_pointer(&avatar->filename, g_free); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | g_clear_object(&avatar->pixbuf); |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
143 | g_clear_object(&avatar->animation); |
|
41966
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | g_clear_object(&avatar->tags); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | G_OBJECT_CLASS(purple_avatar_parent_class)->finalize(obj); |
|
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 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | static void |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | purple_avatar_init(PurpleAvatar *avatar) { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | avatar->tags = purple_tags_new(); |
|
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 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | static void |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | purple_avatar_class_init(PurpleAvatarClass *klass) { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
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 | obj_class->finalize = purple_avatar_finalize; |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | obj_class->get_property = purple_avatar_get_property; |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | obj_class->set_property = purple_avatar_set_property; |
|
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 | /** |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | * PurpleAvatar:filename: |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | * |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
165 | * The filename that this avatar was created from. |
|
41966
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | * |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | * Since: 3.0.0 |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | */ |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | properties[PROP_FILENAME] = g_param_spec_string( |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | "filename", "filename", |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | "The filename to save/load the avatar from.", |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | NULL, |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
173 | 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
|
174 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | /** |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | * PurpleAvatar:pixbuf: |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | * |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
178 | * The [class@GdkPixbuf.Pixbuf] of the avatar. If |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
179 | * [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
|
180 | * from the animation. |
|
41966
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | * |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | * Since: 3.0.0 |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | */ |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | properties[PROP_PIXBUF] = g_param_spec_object( |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | "pixbuf", "pixbuf", |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | "The pixbuf of the avatar.", |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | GDK_TYPE_PIXBUF, |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
188 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
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 | /** |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
191 | * PurpleAvatar:animated: |
|
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 | * Whether or not this avatar is animated. |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
194 | * |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
195 | * Since: 3.0.0 |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
196 | */ |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
197 | properties[PROP_ANIMATED] = g_param_spec_boolean( |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
198 | "animated", "animated", |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
199 | "Whether or not the avatar is animated.", |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
200 | FALSE, |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
201 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
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 | /** |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
204 | * PurpleAvatar:animation: |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
205 | * |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
206 | * The [class@GdkPixbuf.PixbufAnimation] if |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
207 | * [property@Purple.Avatar:animated] is %TRUE. |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
208 | * |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
209 | * Since: 3.0.0 |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
210 | */ |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
211 | properties[PROP_ANIMATION] = g_param_spec_object( |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
212 | "animation", "animation", |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
213 | "The animation of the avatar.", |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
214 | GDK_TYPE_PIXBUF_ANIMATION, |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
215 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
41966
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 | /** |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | * PurpleAvatar:tags: |
|
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 | * The [class@Purple.Tags] for the avatar. |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | * |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | * Since: 3.0.0 |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | */ |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | properties[PROP_TAGS] = g_param_spec_object( |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | "tags", "tags", |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | "The tags for the avatar.", |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | PURPLE_TYPE_TAGS, |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
228 | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); |
|
41966
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 | g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
|
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 | /****************************************************************************** |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | * Public API |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | *****************************************************************************/ |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | PurpleAvatar * |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
237 | 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
|
238 | GdkPixbufAnimation *animation = NULL; |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
239 | GError *local_error = NULL; |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
240 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
241 | g_return_val_if_fail(filename != NULL, NULL); |
|
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 | 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
|
244 | if(!GDK_IS_PIXBUF_ANIMATION(animation) || local_error != NULL) { |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
245 | g_clear_object(&animation); |
|
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 | g_propagate_error(error, local_error); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
248 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
249 | return NULL; |
|
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 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
252 | return purple_avatar_new_common(filename, animation); |
|
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 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
255 | PurpleAvatar * |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
256 | 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
|
257 | GdkPixbufAnimation *animation = NULL; |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
258 | GError *local_error = NULL; |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
259 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
260 | g_return_val_if_fail(resource_path != NULL, NULL); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
261 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
262 | animation = gdk_pixbuf_animation_new_from_resource(resource_path, |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
263 | &local_error); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
264 | if(!GDK_IS_PIXBUF_ANIMATION(animation) || local_error != NULL) { |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
265 | g_clear_object(&animation); |
|
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 | g_propagate_error(error, local_error); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
268 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
269 | return NULL; |
|
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 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
272 | return purple_avatar_new_common(NULL, animation); |
|
41966
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 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | const char * |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | purple_avatar_get_filename(PurpleAvatar *avatar) { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | return avatar->filename; |
|
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 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | GdkPixbuf * |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | purple_avatar_get_pixbuf(PurpleAvatar *avatar) { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
286 | if(avatar->animated) { |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
287 | return gdk_pixbuf_animation_get_static_image(avatar->animation); |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
288 | } |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
289 | |
|
41966
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | return avatar->pixbuf; |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | } |
|
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 | gboolean |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
294 | purple_avatar_get_animated(PurpleAvatar *avatar) { |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
295 | 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
|
296 | |
|
42008
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
297 | return avatar->animated; |
|
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 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
300 | GdkPixbufAnimation * |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
301 | purple_avatar_get_animation(PurpleAvatar *avatar) { |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
302 | 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
|
303 | |
|
ae3fa963c1b3
Add animation support to PurpleAvatar
Gary Kramlich <grim@reaperworld.com>
parents:
41966
diff
changeset
|
304 | return avatar->animation; |
|
41966
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 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | PurpleTags * |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | purple_avatar_get_tags(PurpleAvatar *avatar) { |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | g_return_val_if_fail(PURPLE_IS_AVATAR(avatar), NULL); |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | return avatar->tags; |
|
c7bcaf2f41ef
Create PurpleAvatar to represent avatars
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | } |