Feature #241

XEmbed MIME viewer

Added by Charles Lehner about 2 years ago. Updated about 2 years ago.

Status:NewStart date:07/06/2015
Priority:NormalDue date:
Assignee:Hiroyuki Yamamoto% Done:

0%

Category:SylpheedSpent time:-
Target version:-

Description

Patch 1 changes the behavior of selecting text or HTML attachments. Currently in the attachments pane, the first text/plain attachment is selected. With the handling of text/html attachments in patch 2, it becomes desirable to select the HTML part. So we change the behavior to select the first HTML part if the preference "Prefer HTML in multipart/alternative for display" is set.

Patch 2 adds an attachment viewer EmbedView which uses XEmbed to display the attachment in the message window using an external application. MimeView is changed to use EmbedView for attachments of type HTML, PDF, audio, video, and GIF (for animated GIF support). A preference item mime_embed_command is added to specify a program to launch to render the attachment, like the mime_command preference. The program is passed the mime type, xid (xembed window ID), and filename. An example program is the following script:

# using preference mime_embed_command=/usr/local/bin/mime-xembed-open '%s' %d '%s'
cat /usr/local/bin/mime-xembed-open 
#!/bin/sh
test -z "$3" && echo "usage: ${0##*/} mime/type xid filename" >&2 && exit 1
case "$1" in
        text/html) exec dillo -f -x $2 "$3";;
        application/pdf) exec zathura -e $2 "$3";;
        audio/*) exec xterm -into $2 -e mpv --pause "$3";;
        video/*) exec mpv --pause --wid=$2 "$3";;
        image/*) exec display -backdrop -window $2 "$3";;
        multipart/*) exit 1;;
        *) exec gvim --socketid $2 "$3";;
esac

Other programs that can be used are surf -e and uzbl -s for web pages, gnome-mplayer --window or mplayer -wid for media, xli -windowid for images, and urxvt -embed or st -w for terminals.

I don't consider requiring the user to set up a shell script to launch the embedded viewers to be the most user-friendly option, but it was the easiest to implement. Another option would be to have a set of preferences for each mime type, like there is now for launching audio and images. This has the disadvantage of requiring a restart after changing any option. The mailcap database doesn't know which applications are XEmbed-aware so it is of limited utility. So I'm not sure what would be best here, but I wanted to share these patches since I've been using them for a while with some success. I'm also not sure about Windows support - I don't know if GtkSocket works on Windows. Also, I sometimes see "leaked" dillo processes after quitting Sylpheed while using this patch, so there should probably be some more code added to handle cleaning up the embed viewer processes.

0001-Use-preference-for-preferring-html-or-text-alt.patch Magnifier - Follow preferences for selecting text or HTML message parts (1.82 KB) Charles Lehner, 07/06/2015 05:01 AM

0002-Add-EmbedView-view-MIME-attachments-using-XEmbed.patch Magnifier - Add XEmbed MIME viewer (15.4 KB) Charles Lehner, 07/06/2015 06:06 AM

History

#1 Updated by Charles Lehner about 2 years ago

Note: the EmbedView patch uses procmime_get_multipart from #240 but can be changed to use procmime_get_part instead if #240 is not applied.

Also available in: Atom PDF