From: Melvin Hadasht Date: Sat, 15 Mar 2003 20:17:25 +0000 (+0000) Subject: Added html mail viewing using Dillo X-Git-Tag: rel_0_9_0~206 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=a576fefe7e15ec22d9cfe213a7f4b5d62795ac23 Added html mail viewing using Dillo --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 8a2722c49..f88a2b3f5 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,11 @@ +2003-03-15 [melvin] 0.8.11claws14 + + * src/plugins/dillo_viewer/.cvsignore ** NEW ** + * src/plugins/dillo_viewer/Makefile.am ** NEW ** + * src/plugins/dillo_viewer/dillo_viewer.c ** NEW ** + Added a html mail viewer plugin that uses Dillo v0.7.0 or + newer (http://dillo.auriga.wearlab.de/). + 2003-03-15 [christoph] 0.8.11claws13 * src/imap.c diff --git a/configure.ac b/configure.ac index f8931a9b8..63a320625 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=11 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws13 +EXTRA_VERSION=claws14 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target @@ -408,6 +408,15 @@ if test x"$ac_cv_enable_mathml_viewer_plugin" = xyes; then PLUGINS="mathml-viewer $PLUGINS" fi +AC_ARG_ENABLE(dillo-viewer-plugin, + [ --enable-dillo-viewer-plugin Build Dillo plugin for html mail rendering [default=no]], + [ac_cv_enable_dillo_plugin=$enableval], [ac_cv_enable_dillo_plugin=no]) +AM_CONDITIONAL(BUILD_DILLO_VIEWER_PLUGIN, test x"$ac_cv_enable_dillo_plugin" = xyes) +if test x"$ac_cv_enable_dillo_plugin" = xyes; then + PLUGINS="dillo $PLUGINS" +fi + + dnl **************************** dnl ** Final configure output ** dnl **************************** @@ -427,6 +436,7 @@ src/plugins/Makefile src/plugins/demo/Makefile src/plugins/spamassassin/Makefile src/plugins/mathml_viewer/Makefile +src/plugins/dillo_viewer/Makefile faq/Makefile faq/de/Makefile faq/en/Makefile diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index a6efe3b83..0830d8670 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -10,5 +10,11 @@ if BUILD_MATHML_VIEWER_PLUGIN mathml_viewer_dir = mathml_viewer endif -SUBDIRS = $(demo_dir) $(spamassasssin_dir) $(mathml_viewer_dir) +if BUILD_DILLO_VIEWER_PLUGIN +dillo_viewer_dir = dillo_viewer +endif + + +SUBDIRS = $(demo_dir) $(spamassasssin_dir) $(mathml_viewer_dir) \ + $(dillo_viewer_dir) diff --git a/src/plugins/dillo_viewer/.cvsignore b/src/plugins/dillo_viewer/.cvsignore new file mode 100644 index 000000000..988786875 --- /dev/null +++ b/src/plugins/dillo_viewer/.cvsignore @@ -0,0 +1,7 @@ +.deps +.libs +Makefile +Makefile.in +*.o +*.la +*.lo \ No newline at end of file diff --git a/src/plugins/dillo_viewer/Makefile.am b/src/plugins/dillo_viewer/Makefile.am new file mode 100644 index 000000000..cbe1c84e3 --- /dev/null +++ b/src/plugins/dillo_viewer/Makefile.am @@ -0,0 +1,20 @@ +plugindir = $(pkglibdir)/plugins + +plugin_LTLIBRARIES = dillo_viewer.la + +dillo_viewer_la_SOURCES = \ + dillo_viewer.c + +dillo_viewer_la_LDFLAGS = \ + -avoid-version -module \ + $(GTK_LIBS) + +INCLUDES = \ + -I../.. \ + -I../../common \ + -I../../gtk + +CPPFLAGS = \ + $(ASPELL_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GTK_CFLAGS) diff --git a/src/plugins/dillo_viewer/dillo_viewer.c b/src/plugins/dillo_viewer/dillo_viewer.c new file mode 100644 index 000000000..eb0e8ac44 --- /dev/null +++ b/src/plugins/dillo_viewer/dillo_viewer.c @@ -0,0 +1,165 @@ +/* + * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client + * Copyright (C) 1999-2003 Hiroyuki Yamamoto and the Sylpheed-Claws Team + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include + +#include +#include +#include + +#include "common/plugin.h" +#include "common/utils.h" +#include "mimeview.h" + +typedef struct _dilloViewer dilloViewer; + +struct _dilloViewer +{ + MimeViewer mimeviewer; + GtkWidget *widget; + GtkWidget *socket; + gchar *filename; +}; + +static MimeViewerFactory dillo_viewer_factory; + +static GtkWidget *dillo_get_widget(MimeViewer *_viewer) +{ + dilloViewer *viewer = (dilloViewer *) _viewer; + + debug_print("dillo_get_widget\n"); + + return GTK_WIDGET(viewer->widget); +} + +static gboolean socket_destroy_cb(GtkObject *object, gpointer data) +{ + dilloViewer *viewer = (dilloViewer *) data; + debug_print("Destroyed dillo socket %p\n", viewer->socket); + viewer->socket = NULL; + return FALSE; +} + +static void dillo_show_mimepart(MimeViewer *_viewer, const gchar *infile, MimeInfo *partinfo) +{ + dilloViewer *viewer = (dilloViewer *) _viewer; + + debug_print("dillo_show_mimepart\n"); + + if (viewer->filename != NULL) { + unlink(viewer->filename); + g_free(viewer->filename); + } + + viewer->filename = procmime_get_tmp_file_name(partinfo); + + if (!(procmime_get_part(viewer->filename, infile, partinfo) < 0)) { + gchar *cmd; + viewer->socket = gtk_socket_new(); + debug_print("Adding dillo socket %p", viewer->socket); + gtk_container_add(GTK_CONTAINER(viewer->widget), + viewer->socket); + gtk_widget_realize(viewer->socket); + gtk_widget_show(viewer->socket); + gtk_signal_connect(GTK_OBJECT(viewer->socket), + "destroy", + GTK_SIGNAL_FUNC(socket_destroy_cb), + viewer); + cmd = g_strdup_printf("dillo -f -l -x %d \"%s\"", + GDK_WINDOW_XWINDOW(viewer->socket->window), + viewer->filename); + execute_command_line(cmd, TRUE); + g_free(cmd); + } +} + +static void dillo_clear_viewer(MimeViewer *_viewer) +{ + dilloViewer *viewer = (dilloViewer *) _viewer; + debug_print("dillo_clear_viewer\n"); + debug_print("Removing dillo socket %p\n", viewer->socket); + if (viewer->socket) { + gtk_widget_destroy(viewer->socket); + } + +} + +static void dillo_destroy_viewer(MimeViewer *_viewer) +{ + dilloViewer *viewer = (dilloViewer *) _viewer; + + debug_print("dillo_destroy_viewer\n"); + + gtk_widget_unref(GTK_WIDGET(viewer->widget)); + unlink(viewer->filename); + g_free(viewer->filename); + g_free(viewer); +} + +static MimeViewer *dillo_viewer_create() +{ + dilloViewer *viewer; + + debug_print("dillo_viewer_create\n"); + + viewer = g_new0(dilloViewer, 1); + viewer->mimeviewer.factory = &dillo_viewer_factory; + + viewer->mimeviewer.get_widget = dillo_get_widget; + viewer->mimeviewer.show_mimepart = dillo_show_mimepart; + viewer->mimeviewer.clear_viewer = dillo_clear_viewer; + viewer->mimeviewer.destroy_viewer = dillo_destroy_viewer; + + viewer->widget = gtk_event_box_new(); + gtk_widget_show(viewer->widget); + gtk_widget_ref(viewer->widget); + + viewer->filename = NULL; + + return (MimeViewer *) viewer; +} + +static MimeViewerFactory dillo_viewer_factory = +{ + "text/html", + 0, + + dillo_viewer_create, +}; + +gint plugin_init(gchar **error) +{ + mimeview_register_viewer_factory(&dillo_viewer_factory); + return 0; +} + +void plugin_done() +{ +} + +const gchar *plugin_name() +{ + return "View HTML mail with Dillo"; +} + +const gchar *plugin_desc() +{ + return "This plugin allows to render HTML mail using the Dillo " + "web browser."; +}