2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2014-2016 Ricardo Mones and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "claws-features.h"
25 #include <glib/gi18n.h>
32 #include "prefs_common.h"
35 static guint avatar_render_hook_id
= -1;
37 AvatarRender
*avatars_avatarrender_new(MsgInfo
*msginfo
)
39 AvatarRender
*ar
= g_new0(AvatarRender
, 1);
40 ar
->full_msginfo
= msginfo
;
47 void avatars_avatarrender_free(AvatarRender
*avrender
)
52 if (avrender
->image
!= NULL
) {
53 gtk_widget_destroy(avrender
->image
);
58 gboolean
avatars_internal_rendering_hook(gpointer source
, gpointer data
)
60 AvatarRender
*avatarr
= (AvatarRender
*)source
;
63 if (!(prefs_common
.enable_avatars
& AVATARS_ENABLE_RENDER
)) {
64 debug_print("Internal rendering of avatars is disabled\n");
68 if (avatarr
== NULL
) {
69 g_warning("Internal rendering invoked with NULL argument");
73 if (avatarr
->image
!= NULL
) {
74 g_warning("Memory leak: image widget not destroyed");
77 aface
= procmsg_msginfo_get_avatar(avatarr
->full_msginfo
, AVATAR_FACE
);
79 avatarr
->image
= face_get_from_header(aface
);
80 avatarr
->type
= AVATAR_FACE
;
84 aface
= procmsg_msginfo_get_avatar(avatarr
->full_msginfo
, AVATAR_XFACE
);
86 avatarr
->image
= xface_get_from_header(aface
);
87 avatarr
->type
= AVATAR_XFACE
;
94 void avatars_init(void)
96 if (avatar_render_hook_id
!= -1) {
97 g_warning("Internal avatars rendering already initialized");
100 avatar_render_hook_id
= hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST
, avatars_internal_rendering_hook
, NULL
);
101 if (avatar_render_hook_id
== -1) {
102 g_warning("Failed to register avatars internal rendering hook");
106 void avatars_done(void)
108 if (avatar_render_hook_id
!= -1) {
109 hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST
, avatar_render_hook_id
);
110 avatar_render_hook_id
= -1;