From 45ac013007eae4d11a85b238d431e056fdcb2c0b Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 10 Jan 2025 11:14:47 +0000 Subject: [PATCH] support image/x-eps format via pdf_viewer patch by Konstantin Tokarev; modified for all formats supported by gdk-pixbuf --- AUTHORS | 1 + src/gtk/authors.h | 1 + src/image_viewer.c | 54 +++++++++++++++++++++++++++++++-- src/plugins/pdf_viewer/poppler_viewer.c | 12 ++++++-- src/plugins/pdf_viewer/poppler_viewer.h | 6 ++-- src/textview.c | 5 +-- 6 files changed, 71 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index f2e3d0f1a..572ce2c2d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -354,3 +354,4 @@ contributors (in addition to the above; based on Changelog) Quentin Rameau MatN Jan Willamowius + Konstantin Tokarev diff --git a/src/gtk/authors.h b/src/gtk/authors.h index a9fa182aa..17aafc8af 100644 --- a/src/gtk/authors.h +++ b/src/gtk/authors.h @@ -316,6 +316,7 @@ static char *CONTRIBS_LIST[] = { "Pascal Terjan", "Thorsten Thielen", "Edgar Toernig", +"Konstantin Tokarev", "Masahiro Tomita", "Tomita", "Topia", diff --git a/src/image_viewer.c b/src/image_viewer.c index ef143b1bc..6d2e410ca 100644 --- a/src/image_viewer.c +++ b/src/image_viewer.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2023 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2025 the Claws Mail team and Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -423,7 +423,57 @@ static MimeViewer *image_viewer_create(void) } static gchar *content_types[] = - {"image/*", NULL}; + {"image/png", + "image/jpeg", + "image/x-wmf", + "image/x-adobe-dng", + "image/x-canon-cr2", + "image/x-canon-crw", + "image/x-nikon-nef", + "image/x-olympus-orf", + "image/x-pentax-pef", + "image/x-sony-arw", + "image/x-epson-erf", + "image/x-minolta-mrw", + "image/x-fuji-raf", + "application/x-navi-animation", + "image/avif", + "image/bmp", + "image/x-bmp", + "image/x-MS-bmp", + "image/gif", + "image/heif", + "image/heic", + "image/avif", + "image/x-icns", + "image/x-icon", + "image/x-ico", + "image/x-win-bitmap", + "image/vnd.microsoft.icon", + "application/ico", + "image/ico", + "image/icon", + "text/ico", + "image/jxl", + "image/x-portable-anymap", + "image/x-portable-bitmap", + "image/x-portable-graymap", + "image/x-portable-pixmap", + "image/x-quicktime", + "image/qtif", + "image/x-tga", + "image/tiff", + "image/webp", + "audio/x-riff", + "image/x-xbitmap", + "image/x-xpixmap", + "image/svg+xml", + "image/svg", + "image/svg-xml", + "image/vnd.adobe.svg+xml", + "text/xml-svg", + "image/svg+xml-compressed", + NULL }; MimeViewerFactory image_viewer_factory = { diff --git a/src/plugins/pdf_viewer/poppler_viewer.c b/src/plugins/pdf_viewer/poppler_viewer.c index c20386ed0..5acd6e2bd 100644 --- a/src/plugins/pdf_viewer/poppler_viewer.c +++ b/src/plugins/pdf_viewer/poppler_viewer.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2024 the Claws Mail Team and Salvatore De Paolis + * Copyright (C) 1999-2025 the Claws Mail Team and Salvatore De Paolis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -758,6 +758,7 @@ static FileType pdf_viewer_mimepart_get_type(MimeInfo *partinfo) if (content_type == NULL) type = TYPE_UNKNOWN; else if (!strcmp(content_type, "application/pdf")) type = TYPE_PDF; else if (!strcmp(content_type, "application/postscript")) type = TYPE_PS; + else if (!strcmp(content_type, "image/x-eps")) type = TYPE_EPS; else type = TYPE_UNKNOWN; g_free(content_type); @@ -1315,6 +1316,12 @@ static void pdf_viewer_update(MimeViewer *_viewer, gboolean reload_file, int pag gtk_image_set_from_pixbuf(GTK_IMAGE(viewer->icon_type), viewer->icon_pixbuf); } + else if (pdf_viewer_mimepart_get_type(viewer->to_load) == TYPE_EPS) { + stock_pixbuf_gdk(STOCK_PIXMAP_MIME_IMAGE, + &viewer->icon_pixbuf); + gtk_image_set_from_pixbuf(GTK_IMAGE(viewer->icon_type), + viewer->icon_pixbuf); + } else if (pdf_viewer_mimepart_get_type(viewer->to_load) == TYPE_PDF) { stock_pixbuf_gdk(STOCK_PIXMAP_MIME_PDF, &viewer->icon_pixbuf); @@ -1334,7 +1341,8 @@ static void pdf_viewer_update(MimeViewer *_viewer, gboolean reload_file, int pag GTK_EVENTS_FLUSH(); - if (pdf_viewer_mimepart_get_type(viewer->to_load) == TYPE_PS) { + if (pdf_viewer_mimepart_get_type(viewer->to_load) == TYPE_PS || + pdf_viewer_mimepart_get_type(viewer->to_load) == TYPE_EPS) { gchar *cmdline = NULL, *tmp = NULL, *gspath = NULL; gint result = 0; diff --git a/src/plugins/pdf_viewer/poppler_viewer.h b/src/plugins/pdf_viewer/poppler_viewer.h index c536fcfed..59df74beb 100644 --- a/src/plugins/pdf_viewer/poppler_viewer.h +++ b/src/plugins/pdf_viewer/poppler_viewer.h @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2016 Salvatore De Paolis & the Claws Mail Team + * Copyright (C) 1999-2025 the Claws Mail Team and Salvatore De Paolis * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -129,11 +129,13 @@ struct _PdfViewer static gchar *content_types[] = {"application/pdf", "application/postscript", + "image/x-eps", NULL}; typedef enum { TYPE_UNKNOWN, TYPE_PDF, - TYPE_PS + TYPE_PS, + TYPE_EPS } FileType; enum { diff --git a/src/textview.c b/src/textview.c index cf57a2486..0961ce3dd 100644 --- a/src/textview.c +++ b/src/textview.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2024 the Claws Mail team and Hiroyuki Yamamoto + * Copyright (C) 1999-2025 the Claws Mail team and Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -719,7 +719,8 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo) gtk_text_buffer_insert(buffer, &iter, "\n", 1); TEXTVIEW_INSERT_LINK(buf, "cm://select_attachment", mimeinfo); gtk_text_buffer_insert(buffer, &iter, " \n", -1); - if (mimeinfo->type == MIMETYPE_IMAGE && + if (mimeinfo->type == MIMETYPE_IMAGE && mimeinfo->subtype && + g_ascii_strcasecmp(mimeinfo->subtype, "x-eps") && prefs_common.inline_img ) { GdkPixbuf *pixbuf; GError *error = NULL; -- 2.11.4.GIT