#include <string.h>
#include <time.h>
-#if HAVE_LIBCOMPFACE
-# include <compface.h>
-#endif
-
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "headerview.h"
#include "base64.h"
#include "headers.h"
#include "addrindex.h"
+#include "hooks.h"
+#include "avatars.h"
-#if HAVE_LIBCOMPFACE
-static gint headerview_show_xface (HeaderView *headerview,
- MsgInfo *msginfo);
-#endif
-
-static gint headerview_show_face (HeaderView *headerview,
+static gint headerview_show_avatar (HeaderView *headerview,
MsgInfo *msginfo);
static gint headerview_show_contact_pic (HeaderView *headerview,
MsgInfo *msginfo);
gtk_widget_show(headerview->tags_body_label);
g_free(tags);
}
- if (!headerview_show_face(headerview, msginfo))
- return;
-
-#if HAVE_LIBCOMPFACE
- if (!headerview_show_xface(headerview, msginfo))
+ if (!headerview_show_avatar(headerview, msginfo))
return;
-#endif
if (!headerview_show_contact_pic(headerview, msginfo))
return;
}
-#if HAVE_LIBCOMPFACE
-static gint headerview_show_xface(HeaderView *headerview, MsgInfo *msginfo)
+static gint headerview_show_avatar (HeaderView *headerview, MsgInfo *msginfo)
{
+ AvatarRender *avatarr = avatars_avatarrender_new(msginfo);
GtkWidget *hbox = headerview->hbox;
GtkWidget *image;
- gchar *xface = procmsg_msginfo_get_avatar(msginfo, AVATAR_XFACE);
- if (!msginfo->extradata || !xface || strlen(xface) < 5) {
- if (headerview->image &&
- gtk_widget_get_visible(headerview->image)) {
+ hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST, avatarr);
+
+ if (!avatarr->image) {
+ if (headerview->image
+ && gtk_widget_get_visible(headerview->image)) {
gtk_widget_hide(headerview->image);
gtk_widget_queue_resize(hbox);
}
+ avatars_avatarrender_free(avatarr);
return -1;
}
- if (!gtk_widget_get_visible(headerview->hbox)) return -1;
-
- if (headerview->image) {
- gtk_widget_destroy(headerview->image);
- headerview->image = NULL;
- }
-
- image = xface_get_from_header(xface);
-
- if (image) {
- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
- gtk_widget_show(image);
- }
-
- headerview->image = image;
- if (image) {
- headerview_save_contact_pic(headerview, msginfo);
- }
- return 0;
-}
-#endif
-
-static gint headerview_show_face (HeaderView *headerview, MsgInfo *msginfo)
-{
- GtkWidget *hbox = headerview->hbox;
- GtkWidget *image;
- gchar *face = procmsg_msginfo_get_avatar(msginfo, AVATAR_FACE);
-
- if (!msginfo->extradata || !face) {
- if (headerview->image &&
- gtk_widget_get_visible(headerview->image)) {
- gtk_widget_hide(headerview->image);
- gtk_widget_queue_resize(hbox);
- }
+ if (!gtk_widget_get_visible(hbox)) {
+ avatars_avatarrender_free(avatarr);
return -1;
}
- if (!gtk_widget_get_visible(headerview->hbox)) return -1;
if (headerview->image) {
gtk_widget_destroy(headerview->image);
headerview->image = NULL;
}
- image = face_get_from_header(face);
+ gtk_box_pack_start(GTK_BOX(hbox), avatarr->image, FALSE, FALSE, 0);
+ gtk_widget_show(avatarr->image);
- if (image) {
- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
- gtk_widget_show(image);
- }
+ headerview->image = avatarr->image;
+ avatarr->image = NULL; /* avoid destroying */
+ avatars_avatarrender_free(avatarr);
- headerview->image = image;
- if (image == NULL)
- return -1;
- else {
- headerview_save_contact_pic(headerview, msginfo);
- return 0;
- }
+ headerview_save_contact_pic(headerview, msginfo);
+ return 0;
}
static void headerview_save_contact_pic (HeaderView *headerview, MsgInfo *msginfo)
#include "version.h"
#include "statusbar.h"
#include "folder_item_prefs.h"
+#include "avatars.h"
#ifndef USE_NEW_ADDRBOOK
#include "addressbook.h"
#else
MessageView *messageview = (MessageView *)data;
MsgInfo *msginfo, *full_msginfo;
gchar *from;
- GtkWidget *image = NULL;
GdkPixbuf *picture = NULL;
- gchar *face;
+ AvatarRender *avatarr;
if (!messageview->msginfo || !messageview->msginfo->from)
return;
extract_address(from);
full_msginfo = procmsg_msginfo_get_full_info(msginfo);
- face = procmsg_msginfo_get_avatar(full_msginfo, AVATAR_FACE);
- if (face) {
- image = face_get_from_header(face);
- }
-#if HAVE_LIBCOMPFACE
- else {
- gchar *xface = procmsg_msginfo_get_avatar(full_msginfo, AVATAR_XFACE);
- if (xface) {
- image = xface_get_from_header(xface);
- }
- }
-#endif
+
+ avatarr = avatars_avatarrender_new(full_msginfo);
+ hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST, avatarr);
+
procmsg_msginfo_free(full_msginfo);
- if (image)
- picture = gtk_image_get_pixbuf(GTK_IMAGE(image));
+
+ if (avatarr->image != NULL)
+ picture = gtk_image_get_pixbuf(GTK_IMAGE(avatarr->image));
#ifndef USE_NEW_ADDRBOOK
addressbook_add_contact(msginfo->fromname, from, NULL, picture);
debug_print( "addressbook_add_contact - added\n" );
}
#endif
- if (image)
- gtk_widget_destroy(image);
+ avatars_avatarrender_free(avatarr);
}
static void create_filter_cb(GtkAction *gaction, gpointer data)
#include "edittags.h"
#include "manual.h"
#include "manage_window.h"
+#include "avatars.h"
#define SUMMARY_COL_MARK_WIDTH 10
#define SUMMARY_COL_STATUS_WIDTH 13
{
MsgInfo *msginfo, *full_msginfo;
gchar *from;
- GtkWidget *image = NULL;
GdkPixbuf *picture = NULL;
- gchar *face;
+ AvatarRender *avatarr;
msginfo = gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview->ctree),
summaryview->selected);
extract_address(from);
full_msginfo = procmsg_msginfo_get_full_info(msginfo);
- face = procmsg_msginfo_get_avatar(full_msginfo, AVATAR_FACE);
- if (face) {
- image = face_get_from_header(face);
- }
-#if HAVE_LIBCOMPFACE
- else {
- gchar *xface = procmsg_msginfo_get_avatar(full_msginfo, AVATAR_XFACE);
- if (xface) {
- image = xface_get_from_header(xface);
- }
- }
-#endif
+
+ avatarr = avatars_avatarrender_new(full_msginfo);
+ hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST, avatarr);
+
procmsg_msginfo_free(full_msginfo);
- if (image)
- picture = gtk_image_get_pixbuf(GTK_IMAGE(image));
+
+ if (avatarr->image)
+ picture = gtk_image_get_pixbuf(GTK_IMAGE(avatarr->image));
#ifndef USE_NEW_ADDRBOOK
addressbook_add_contact(msginfo->fromname, from, NULL, picture);
debug_print( "addressbook_add_contact - added\n" );
}
#endif
- if (image)
- gtk_widget_destroy(image);
+ avatars_avatarrender_free(avatarr);
}
void summary_select_all(SummaryView *summaryview)
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
-#if HAVE_LIBCOMPFACE
-# include <compface.h>
-#endif
#include "main.h"
#include "summaryview.h"
#include "tags.h"
#include "manage_window.h"
#include "folder_item_prefs.h"
+#include "avatars.h"
static GdkColor quote_colors[3] = {
{(gulong)0, (gushort)0, (gushort)0, (gushort)0},
return sorted_headers;
}
-static void textview_show_face(TextView *textview)
+static void textview_show_avatar(TextView *textview)
{
GtkAllocation allocation;
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
MsgInfo *msginfo = textview->messageview->msginfo;
int x = 0;
- gchar *face;
+ AvatarRender *avatarr;
if (prefs_common.display_header_pane || !prefs_common.display_xface)
goto bail;
- face = procmsg_msginfo_get_avatar(msginfo, AVATAR_FACE);
- if (!face)
+ avatarr = avatars_avatarrender_new(msginfo);
+ hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST, avatarr);
+
+ if (!avatarr->image) {
+ avatars_avatarrender_free(avatarr);
goto bail;
+ }
if (textview->image)
gtk_widget_destroy(textview->image);
- textview->image = face_get_from_header(face);
- cm_return_if_fail(textview->image != NULL);
+ textview->image = avatarr->image;
+ avatarr->image = NULL; /* avoid destroying */
+ avatars_avatarrender_free(avatarr);
gtk_widget_show(textview->image);
GTK_TEXT_WINDOW_TEXT, x, 5);
gtk_widget_show_all(textview->text);
-
return;
bail:
return;
}
-#if HAVE_LIBCOMPFACE
-static void textview_show_xface(TextView *textview)
-{
- GtkAllocation allocation;
- MsgInfo *msginfo = textview->messageview->msginfo;
- GtkTextView *text = GTK_TEXT_VIEW(textview->text);
- int x = 0;
- GdkWindow *window = NULL;
- gchar *face, *xface;
-
- if (prefs_common.display_header_pane || !prefs_common.display_xface)
- goto bail;
-
- if (!msginfo || !msginfo->extradata || !msginfo->extradata->avatars)
- goto bail;
-
- face = procmsg_msginfo_get_avatar(msginfo, AVATAR_FACE);
- if (face)
- return;
-
- xface = procmsg_msginfo_get_avatar(msginfo, AVATAR_XFACE);
- if (!xface || strlen(xface) < 5)
- goto bail;
-
- if (textview->image)
- gtk_widget_destroy(textview->image);
-
- window = mainwindow_get_mainwindow() ?
- mainwindow_get_mainwindow()->window->window :
- textview->text->window;
- textview->image = xface_get_from_header(xface);
- cm_return_if_fail(textview->image != NULL);
-
- gtk_widget_show(textview->image);
-
- gtk_widget_get_allocation(textview->text, &allocation);
- x = allocation.width - WIDTH -5;
-
- gtk_text_view_add_child_in_window(text, textview->image,
- GTK_TEXT_WINDOW_TEXT, x, 5);
-
- gtk_widget_show_all(textview->text);
-
- return;
-bail:
- if (textview->image)
- gtk_widget_destroy(textview->image);
- textview->image = NULL;
-
-}
-#endif
-
static void textview_save_contact_pic(TextView *textview)
{
#ifndef USE_NEW_ADDRBOOK
gchar *filename = NULL;
GError *error = NULL;
GdkPixbuf *picture = NULL;
- gchar *face, *xface;
-
- if (!msginfo->extradata || !msginfo->extradata->avatars)
- return;
- face = procmsg_msginfo_get_avatar(msginfo, AVATAR_FACE);
- xface = procmsg_msginfo_get_avatar(msginfo, AVATAR_XFACE);
- if (!face && !xface)
+ if (!msginfo->extradata || !msginfo->extradata->avatars)
return;
if (textview->image)
GdkPixbuf *picture = NULL;
gint w, h;
GtkAllocation allocation;
- gchar *face, *xface;
-
+
if (prefs_common.display_header_pane
|| !prefs_common.display_xface)
goto bail;
- face = procmsg_msginfo_get_avatar(msginfo, AVATAR_FACE);
- xface = procmsg_msginfo_get_avatar(msginfo, AVATAR_XFACE);
- if (msginfo->extradata && (face || xface)) /* FIXME extradata not needed */
+ if (msginfo->extradata && msginfo->extradata->avatars)
return;
if (textview->image)
"header", NULL);
}
- textview_show_face(textview);
-#if HAVE_LIBCOMPFACE
- textview_show_xface(textview);
-#endif
+ textview_show_avatar(textview);
+
textview_save_contact_pic(textview);
textview_show_contact_pic(textview);
}
gchar *fromname, *fromaddress;
ClickableText *uri = g_object_get_data(G_OBJECT(textview->mail_popup_menu),
"menu_button");
- GtkWidget *image = NULL;
+ AvatarRender *avatarr = NULL;
GdkPixbuf *picture = NULL;
gboolean use_picture = FALSE;
extract_address(fromaddress);
if (use_picture) {
- gchar *face = procmsg_msginfo_get_avatar(
- textview->messageview->msginfo,
- AVATAR_FACE);
- if (face) {
- image = face_get_from_header(face);
- }
-#if HAVE_LIBCOMPFACE
- else {
- gchar *xface = procmsg_msginfo_get_avatar(
- textview->messageview->msginfo,
- AVATAR_XFACE);
- if (xface) {
- image = xface_get_from_header(xface);
- }
- }
-#endif
+ avatarr = avatars_avatarrender_new(textview->messageview->msginfo);
+ hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST, avatarr);
}
- if (image)
- picture = gtk_image_get_pixbuf(GTK_IMAGE(image));
+ if (avatarr && avatarr->image) {
+ picture = gtk_image_get_pixbuf(GTK_IMAGE(avatarr->image));
+ }
+ if (avatarr) {
+ avatars_avatarrender_free(avatarr);
+ }
#ifndef USE_NEW_ADDRBOOK
addressbook_add_contact( fromname, fromaddress, NULL, picture);