+2003-03-25 [christoph] 0.8.11claws46
+
+ * configure.ac
+ * src/Makefile.am
+ * src/imageview.[ch] ** REMOVE **
+ * src/messageview.[ch]
+ * src/mimeview.[ch]
+ * src/prefs_common.[ch]
+ * src/textview.c
+ * src/plugins/Makefile.am
+ * src/plugins/image_viewer/.cvsignore ** NEW **
+ * src/plugins/image_viewer/Makefile.am ** NEW **
+ * src/plugins/image_viewer/plugin.c ** NEW **
+ * src/plugins/image_viewer/viewer.[ch] ** NEW **
+ move image viewer into a plugin (building is enabled by default)
+ [ToDo: Prefs for resize and autoview]
+
2003-03-25 [paul] 0.8.11claws45
* sync with 0.8.11cvs12
MICRO_VERSION=11
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=claws44
+EXTRA_VERSION=claws46
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl set $target
AC_MSG_RESULT(no)
fi
-dnl Check for built-in image view support
-AC_ARG_ENABLE(gdk-pixbuf,
- [ --disable-gdk-pixbuf Do not use gdk-pixbuf],
- [ac_cv_enable_gdk_pixbuf=$enableval], [ac_cv_enable_gdk_pixbuf=yes])
-AC_ARG_ENABLE(imlib,
- [ --disable-imlib Do not use imlib],
- [ac_cv_enable_imlib=$enableval], [ac_cv_enable_imlib=yes])
-
-if test "$ac_cv_enable_gdk_pixbuf" = yes; then
- AM_PATH_GDK_PIXBUF(0.8.0,
- [AC_DEFINE(HAVE_GDK_PIXBUF, 1, Define if you use gdk-pixbuf to support image view)
- ac_cv_enable_imlib=no], [ac_cv_enable_gdk_pixbuf=no])
-fi
-if test "$ac_cv_enable_imlib" = yes; then
- AM_PATH_GDK_IMLIB(1.9,
- AC_DEFINE(HAVE_GDK_IMLIB, 1, Define if you use gdk_imlib to support image view),
- [ac_cv_enable_imlib=no])
-fi
-if test "$ac_cv_enable_gdk_pixbuf" = no -a "$ac_cv_enable_imlib" = no; then
- AC_MSG_WARN(*** Built-in image view will not be supported ***)
-fi
-
dnl GPGME is used to support OpenPGP
AC_ARG_ENABLE(gpgme,
[ --enable-gpgme Enable GnuPG support using GPGME [default=no]],
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"
+ [ac_cv_enable_dillo_viewer_plugin=$enableval], [ac_cv_enable_dillo_viewer_plugin=no])
+AM_CONDITIONAL(BUILD_DILLO_VIEWER_PLUGIN, test x"$ac_cv_enable_dillo_viewer_plugin" = xyes)
+if test x"$ac_cv_enable_dillo_viewer_plugin" = xyes; then
+ PLUGINS="dillo-viewer $PLUGINS"
+fi
+
+AC_ARG_ENABLE(image-viewer-plugin,
+ [ --disable-image-viewer-plugin Do not build image viewer plugin],
+ [ac_cv_enable_image_viewer_plugin=$enableval], [ac_cv_enable_image_viewer_plugin=yes])
+if test x"$ac_cv_enable_image_viewer_plugin" = xyes; then
+ AC_ARG_ENABLE(gdk-pixbuf,
+ [ --disable-gdk-pixbuf Do not use gdk-pixbuf],
+ [ac_cv_enable_gdk_pixbuf=$enableval], [ac_cv_enable_gdk_pixbuf=yes])
+ AC_ARG_ENABLE(imlib,
+ [ --disable-imlib Do not use imlib],
+ [ac_cv_enable_imlib=$enableval], [ac_cv_enable_imlib=yes])
+
+ if test "$ac_cv_enable_gdk_pixbuf" = yes; then
+ AM_PATH_GDK_PIXBUF(0.8.0,
+ [AC_DEFINE(HAVE_GDK_PIXBUF, 1, Define if you use gdk-pixbuf to support image viewer)
+ ac_cv_enable_imlib=no], [ac_cv_enable_gdk_pixbuf=no])
+ fi
+ if test "$ac_cv_enable_imlib" = yes; then
+ AM_PATH_GDK_IMLIB(1.9,
+ AC_DEFINE(HAVE_GDK_IMLIB, 1, Define if you use gdk_imlib to support image viewer),
+ [ac_cv_enable_imlib=no])
+ fi
+ if test "$ac_cv_enable_gdk_pixbuf" = no -a "$ac_cv_enable_imlib" = no; then
+ $ac_cv_enable_image_viewer_plugin = no
+ fi
+fi
+AM_CONDITIONAL(BUILD_IMAGE_VIEWER_PLUGIN, test x"$ac_cv_enable_image_viewer_plugin" = xyes)
+if test x"$ac_cv_enable_image_viewer_plugin" = xyes; then
+ PLUGINS="image $PLUGINS"
fi
AC_ARG_ENABLE(trayicon-plugin,
src/plugins/spamassassin/Makefile
src/plugins/mathml_viewer/Makefile
src/plugins/dillo_viewer/Makefile
+src/plugins/image_viewer/Makefile
src/plugins/trayicon/Makefile
faq/Makefile
faq/de/Makefile
messageview.c messageview.h \
headerview.c headerview.h \
textview.c textview.h \
- imageview.c imageview.h \
mimeview.c mimeview.h \
summary_search.c summary_search.h \
message_search.c message_search.h \
-I$(top_srcdir)/intl \
$(ASPELL_CFLAGS) \
$(GTK_CFLAGS) \
- $(GDK_IMLIB_CFLAGS) \
- $(GDK_PIXBUF_CFLAGS) \
$(GPGME_CFLAGS) \
$(OPENSSL_CFLAGS) \
-I$(includedir)
$(INTLLIBS) \
$(ASPELL_LIBS) \
$(GTK_LIBS) \
- $(GDK_IMLIB_LIBS) \
- $(GDK_PIXBUF_LIBS) \
$(GPGME_LIBS) \
$(LDAP_LIBS) \
$(OPENSSL_LIBS) \
+++ /dev/null
-/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 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
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <glib.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtkpixmap.h>
-
-#if HAVE_GDK_PIXBUF
-# include <gdk-pixbuf/gdk-pixbuf.h>
-#else
-#if HAVE_GDK_IMLIB
-# include <gdk_imlib.h>
-#endif
-#endif /* HAVE_GDK_PIXBUF */
-
-#include "intl.h"
-#include "prefs_common.h"
-#include "procmime.h"
-#include "imageview.h"
-#include "utils.h"
-
-ImageView *imageview_create(void)
-{
- ImageView *imageview;
- GtkWidget *scrolledwin;
-
- debug_print("Creating image view...\n");
- imageview = g_new0(ImageView, 1);
-
- scrolledwin = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_widget_set_usize(scrolledwin, prefs_common.mainview_width, -1);
-
- gtk_widget_show_all(scrolledwin);
-
- imageview->scrolledwin = scrolledwin;
- imageview->image = NULL;
-
- return imageview;
-}
-
-void imageview_init(ImageView *imageview)
-{
-}
-
-#if HAVE_GDK_PIXBUF
-void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo,
- const gchar *file, gboolean resize)
-{
- GdkPixbuf *pixbuf;
- GdkPixbuf *pixbuf_scaled;
- GdkPixmap *pixmap;
- GdkBitmap *mask;
- gint avail_width;
- gint avail_height;
- gint new_width;
- gint new_height;
-
- g_return_if_fail(imageview != NULL);
-
- imageview_clear(imageview);
-
- pixbuf = gdk_pixbuf_new_from_file(file);
-
- if (!pixbuf) {
- g_warning("Can't load the image.");
- return;
- }
-
- if (imageview->messageview->mainwin)
- main_window_cursor_wait(imageview->messageview->mainwin);
-
- if (resize) {
- avail_width = imageview->scrolledwin->parent->allocation.width;
- avail_height = imageview->scrolledwin->parent->allocation.height;
- if (avail_width > 8) avail_width -= 8;
- if (avail_height > 8) avail_height -= 8;
-
- imageview_get_resized_size(gdk_pixbuf_get_width(pixbuf),
- gdk_pixbuf_get_height(pixbuf),
- avail_width, avail_height,
- &new_width, &new_height);
-
- pixbuf_scaled = gdk_pixbuf_scale_simple
- (pixbuf, new_width, new_height, GDK_INTERP_BILINEAR);
- gdk_pixbuf_unref(pixbuf);
- pixbuf = pixbuf_scaled;
- }
-
- gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &mask, 0);
-
- if (!imageview->image) {
- imageview->image = gtk_pixmap_new(pixmap, mask);
-
- gtk_scrolled_window_add_with_viewport
- (GTK_SCROLLED_WINDOW(imageview->scrolledwin),
- imageview->image);
- } else
- gtk_pixmap_set(GTK_PIXMAP(imageview->image), pixmap, mask);
-
- gtk_widget_show(imageview->image);
-
- gdk_pixbuf_unref(pixbuf);
-
- if (imageview->messageview->mainwin)
- main_window_cursor_normal(imageview->messageview->mainwin);
-}
-#else
-#if HAVE_GDK_IMLIB
-void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo,
- const gchar *file, gboolean resize)
-{
- GdkImlibImage *im;
- gint avail_width;
- gint avail_height;
- gint new_width;
- gint new_height;
-
- g_return_if_fail(imageview != NULL);
-
- imageview_clear(imageview);
-
- im = gdk_imlib_load_image((gchar *)file);
-
- if (!im) {
- g_warning("Can't load the image.");
- return;
- }
-
- if (imageview->messageview->mainwin)
- main_window_cursor_wait(imageview->messageview->mainwin);
-
- if (resize) {
- avail_width = imageview->scrolledwin->parent->allocation.width;
- avail_height = imageview->scrolledwin->parent->allocation.height;
- if (avail_width > 8) avail_width -= 8;
- if (avail_height > 8) avail_height -= 8;
-
- imageview_get_resized_size(im->rgb_width, im->rgb_height,
- avail_width, avail_height,
- &new_width, &new_height);
- } else {
- new_width = im->rgb_width;
- new_height = im->rgb_height;
- }
-
- gdk_imlib_render(im, new_width, new_height);
-
- if (!imageview->image) {
- imageview->image = gtk_pixmap_new(gdk_imlib_move_image(im),
- gdk_imlib_move_mask(im));
-
- gtk_scrolled_window_add_with_viewport
- (GTK_SCROLLED_WINDOW(imageview->scrolledwin),
- imageview->image);
- } else
- gtk_pixmap_set(GTK_PIXMAP(imageview->image),
- gdk_imlib_move_image(im),
- gdk_imlib_move_mask(im));
-
- gtk_widget_show(imageview->image);
-
- gdk_imlib_destroy_image(im);
-
- if (imageview->messageview->mainwin)
- main_window_cursor_normal(imageview->messageview->mainwin);
-}
-#else
-void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo,
- const gchar *file, gboolean resize)
-{
-}
-#endif /* HAVE_GDK_IMLIB */
-#endif /* HAVE_GDK_PIXBUF */
-
-void imageview_clear(ImageView *imageview)
-{
- GtkAdjustment *hadj, *vadj;
-
- if (imageview->image)
- gtk_pixmap_set(GTK_PIXMAP(imageview->image), NULL, NULL);
- hadj = gtk_scrolled_window_get_hadjustment
- (GTK_SCROLLED_WINDOW(imageview->scrolledwin));
- gtk_adjustment_set_value(hadj, 0.0);
- vadj = gtk_scrolled_window_get_vadjustment
- (GTK_SCROLLED_WINDOW(imageview->scrolledwin));
- gtk_adjustment_set_value(vadj, 0.0);
-}
-
-void imageview_destroy(ImageView *imageview)
-{
- g_free(imageview);
-}
-
-void imageview_get_resized_size(gint w, gint h, gint aw, gint ah,
- gint *sw, gint *sh)
-{
- gfloat wratio = 1.0;
- gfloat hratio = 1.0;
- gfloat ratio = 1.0;
-
- if (w > aw)
- wratio = (gfloat)aw / (gfloat)w;
- if (h > ah)
- hratio = (gfloat)ah / (gfloat)h;
-
- ratio = (wratio > hratio) ? hratio : wratio;
-
- *sw = (gint)(w * ratio);
- *sh = (gint)(h * ratio);
-
- /* be paranoid */
- if (*sw <= 0 || *sh <= 0) {
- *sw = w;
- *sh = h;
- }
-}
#include "headerview.h"
#include "summaryview.h"
#include "textview.h"
-#include "imageview.h"
#include "mimeview.h"
#include "procmsg.h"
#include "procheader.h"
GtkWidget *vbox;
HeaderView *headerview;
TextView *textview;
- ImageView *imageview;
MimeView *mimeview;
NoticeView *noticeview;
textview = textview_create();
textview->messageview = messageview;
- imageview = imageview_create();
- imageview->messageview = messageview;
-
mimeview = mimeview_create();
mimeview->textview = textview_create();
mimeview->textview->messageview = messageview;
- mimeview->imageview = imageview;
mimeview->messageview = messageview;
vbox = gtk_vbox_new(FALSE, 0);
/* to remove without destroyed */
gtk_widget_ref(GTK_WIDGET_PTR(textview));
- gtk_widget_ref(GTK_WIDGET_PTR(imageview));
gtk_widget_ref(GTK_WIDGET_PTR(mimeview));
gtk_widget_ref(GTK_WIDGET_PTR(mimeview->textview));
messageview->window = NULL;
messageview->headerview = headerview;
messageview->textview = textview;
- messageview->imageview = imageview;
messageview->mimeview = mimeview;
messageview->noticeview = noticeview;
messageview->mainwin = mainwin;
{
headerview_init(messageview->headerview);
textview_init(messageview->textview);
- imageview_init(messageview->imageview);
mimeview_init(messageview->mimeview);
/*messageview_set_font(messageview);*/
messageview_change_view_type(messageview, MVIEW_TEXT);
headerview_clear(messageview->headerview);
textview_clear(messageview->textview);
- imageview_clear(messageview->imageview);
noticeview_hide(messageview->noticeview);
}
void messageview_destroy(MessageView *messageview)
{
GtkWidget *textview = GTK_WIDGET_PTR(messageview->textview);
- GtkWidget *imageview = GTK_WIDGET_PTR(messageview->imageview);
GtkWidget *mimeview = GTK_WIDGET_PTR(messageview->mimeview);
debug_print("destroy messageview\n");
headerview_destroy(messageview->headerview);
textview_destroy(messageview->textview);
- imageview_destroy(messageview->imageview);
mimeview_destroy(messageview->mimeview);
noticeview_destroy(messageview->noticeview);
g_free(messageview);
gtk_widget_unref(textview);
- gtk_widget_unref(imageview);
gtk_widget_unref(mimeview);
}
#include "mainwindow.h"
#include "headerview.h"
#include "textview.h"
-#include "imageview.h"
#include "mimeview.h"
#include "noticeview.h"
#include "procmsg.h"
HeaderView *headerview;
TextView *textview;
- ImageView *imageview;
MimeView *mimeview;
NoticeView *noticeview;
GtkCTreeNode *parent);
static void mimeview_show_message_part (MimeView *mimeview,
MimeInfo *partinfo);
-static void mimeview_show_image_part (MimeView *mimeview,
- MimeInfo *partinfo);
static void mimeview_change_view_type (MimeView *mimeview,
MimeViewType type);
static void mimeview_clear (MimeView *mimeview);
MimeView *mimeview);
static void mimeview_display_as_text (MimeView *mimeview);
-static void mimeview_show_image (MimeView *mimeview);
static void mimeview_save_as (MimeView *mimeview);
static void mimeview_save_all (MimeView *mimeview);
static void mimeview_launch (MimeView *mimeview);
{N_("/_Open"), NULL, mimeview_launch, 0, NULL},
{N_("/Open _with..."), NULL, mimeview_open_with, 0, NULL},
{N_("/_Display as text"), NULL, mimeview_display_as_text, 0, NULL},
- {N_("/_Display image"), NULL, mimeview_show_image, 0, NULL},
{N_("/_Save as..."), NULL, mimeview_save_as, 0, NULL},
{N_("/Save _all..."), NULL, mimeview_save_all, 0, NULL}
#if USE_GPGME
fclose(fp);
}
-static void mimeview_show_image_part(MimeView *mimeview, MimeInfo *partinfo)
-{
- gchar *filename;
-
- if (!partinfo) return;
-
- filename = procmime_get_tmp_file_name(partinfo);
-
- if (procmime_get_part(filename, mimeview->file, partinfo) < 0)
- alertpanel_error
- (_("Can't get the part of multipart message."));
- else {
- mimeview_change_view_type(mimeview, MIMEVIEW_IMAGE);
- /* Workaround for the GTK+ bug with handling scroll adjustments
- * in GtkViewport */
- imageview_clear(mimeview->imageview);
- imageview_show_image(mimeview->imageview, partinfo, filename,
- prefs_common.resize_image);
- unlink(filename);
- }
-
- g_free(filename);
-}
-
static MimeViewer *get_viewer_for_content_type(MimeView *mimeview, const gchar *content_type)
{
GSList *cur;
static void mimeview_change_view_type(MimeView *mimeview, MimeViewType type)
{
TextView *textview = mimeview->textview;
- ImageView *imageview = mimeview->imageview;
GList *children;
if ((mimeview->type != MIMEVIEW_VIEWER) &&
}
switch (type) {
- case MIMEVIEW_IMAGE:
- gtk_container_add(GTK_CONTAINER(mimeview->mime_vbox),
- GTK_WIDGET_PTR(imageview));
- break;
case MIMEVIEW_TEXT:
gtk_container_add(GTK_CONTAINER(mimeview->mime_vbox),
GTK_WIDGET_PTR(textview));
gtk_clist_clear(clist);
textview_clear(mimeview->textview);
- imageview_clear(mimeview->imageview);
if (mimeview->mimeviewer != NULL)
mimeview->mimeviewer->clear_viewer(mimeview->mimeviewer);
mimeview_show_message_part(mimeview, partinfo);
break;
-#if (HAVE_GDK_PIXBUF || HAVE_GDK_IMLIB)
- case MIME_IMAGE:
- mimeview->textview->default_text = TRUE;
- if (prefs_common.display_img)
- mimeview_show_image_part(mimeview, partinfo);
- else {
- mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
- textview_show_mime_part(mimeview->textview, partinfo);
- }
- break;
-#endif
default:
mimeview->textview->default_text = TRUE;
mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
menu_set_sensitive(mimeview->popupfactory,
"/Open", TRUE);
-#if (HAVE_GDK_PIXBUF || HAVE_GDK_IMLIB)
- if (partinfo && (partinfo->mime_type == MIME_IMAGE))
- menu_set_sensitive(mimeview->popupfactory,
- "/Display image", TRUE);
-#endif
#if USE_GPGME
menu_set_sensitive(mimeview->popupfactory,
"/Check signature",
KEY_PRESS_EVENT_STOP();
mimeview_display_as_text(mimeview);
return TRUE;
- case GDK_i:
- BREAK_ON_MODIFIER_KEY();
- KEY_PRESS_EVENT_STOP();
- mimeview_show_image(mimeview);
- return TRUE;
case GDK_l:
BREAK_ON_MODIFIER_KEY();
KEY_PRESS_EVENT_STOP();
mimeview_show_message_part(mimeview, partinfo);
}
-static void mimeview_show_image(MimeView *mimeview)
-{
- MimeInfo *partinfo;
-
- if (!mimeview->opened) return;
-
- partinfo = gtk_ctree_node_get_row_data
- (GTK_CTREE(mimeview->ctree), mimeview->opened);
- mimeview_show_image_part(mimeview, partinfo);
-}
-
static void mimeview_save_as(MimeView *mimeview)
{
gchar *filename;
typedef struct _MimeViewer MimeViewer;
#include "textview.h"
-#include "imageview.h"
#include "messageview.h"
#include "procmime.h"
typedef enum
{
MIMEVIEW_TEXT,
- MIMEVIEW_IMAGE,
MIMEVIEW_VIEWER,
} MimeViewType;
GtkCTreeNode *opened;
TextView *textview;
- ImageView *imageview;
MimeViewer *mimeviewer;
MessageView *messageview;
dillo_viewer_dir = dillo_viewer
endif
+if BUILD_IMAGE_VIEWER_PLUGIN
+image_viewer_dir = image_viewer
+endif
+
if BUILD_TRAYICON_PLUGIN
trayicon_dir = trayicon
endif
$(spamassasssin_dir) \
$(mathml_viewer_dir) \
$(dillo_viewer_dir) \
+ $(image_viewer_dir) \
$(trayicon_dir)
--- /dev/null
+.deps
+.libs
+Makefile
+Makefile.in
+*.o
+*.la
+*.lo
\ No newline at end of file
--- /dev/null
+plugindir = $(pkglibdir)/plugins
+
+plugin_LTLIBRARIES = image_viewer.la
+
+image_viewer_la_SOURCES = \
+ plugin.c \
+ viewer.c viewer.h
+
+image_viewer_la_LDFLAGS = \
+ -avoid-version -module \
+ $(GTK_LIBS) \
+ $(GDK_IMLIB_LIBS) \
+ $(GDK_PIXBUF_LIBS)
+
+INCLUDES = \
+ -I../.. \
+ -I../../common \
+ -I../../gtk
+
+CPPFLAGS = \
+ $(ASPELL_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(GDK_IMLIB_CFLAGS) \
+ $(GDK_PIXBUF_CFLAGS)
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef __IMAGEVIEW_H__
-#define __IMAGEVIEW_H__
+#include "viewer.h"
-#include <glib.h>
-#include <gtk/gtkwidget.h>
-
-typedef struct _ImageView ImageView;
-
-#include "messageview.h"
-#include "procmime.h"
+gint plugin_init(gchar **error)
+{
+ mimeview_register_viewer_factory(&image_viewer_factory);
+ return 0;
+}
-struct _ImageView
+void plugin_done()
{
- GtkWidget *scrolledwin;
- GtkWidget *image;
+ mimeview_unregister_viewer_factory(&image_viewer_factory);
+}
- MessageView *messageview;
-};
+const gchar *plugin_name()
+{
+ return "Image Viewer";
+}
-ImageView *imageview_create (void);
-void imageview_init (ImageView *imageview);
-void imageview_show_image (ImageView *imageview,
- MimeInfo *mimeinfo,
- const gchar *file,
- gboolean resize);
-void imageview_clear (ImageView *imageview);
-void imageview_destroy (ImageView *imageview);
-void imageview_get_resized_size (gint w, gint h, gint aw, gint ah,
- gint *sw, gint *sh);
+const gchar *plugin_desc()
+{
+ return "";
+}
-#endif /* __IMAGEVIEW_H__ */
+const gchar *plugin_type()
+{
+ return "GTK";
+}
--- /dev/null
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 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
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtkpixmap.h>
+
+#if HAVE_GDK_PIXBUF
+# include <gdk-pixbuf/gdk-pixbuf.h>
+#else
+#if HAVE_GDK_IMLIB
+# include <gdk_imlib.h>
+#endif
+#endif /* HAVE_GDK_PIXBUF */
+
+#include "intl.h"
+#include "procmime.h"
+#include "utils.h"
+#include "mimeview.h"
+
+static gboolean resize = FALSE;
+
+typedef struct _ImageViewer ImageViewer;
+
+MimeViewerFactory image_viewer_factory;
+static void image_viewer_get_resized_size(gint w, gint h, gint aw, gint ah,
+ gint * sw, gint * sh);
+static void image_viewer_clear_viewer(MimeViewer *imageviewer);
+
+struct _ImageViewer
+{
+ MimeViewer mimeviewer;
+
+ GtkWidget *scrolledwin;
+ GtkWidget *image;
+};
+
+static GtkWidget *image_viewer_get_widget(MimeViewer *_mimeviewer)
+{
+ ImageViewer *imageviewer = (ImageViewer *) _mimeviewer;
+
+ debug_print("image_viewer_get_widget\n");
+
+ return imageviewer->scrolledwin;
+}
+
+#if HAVE_GDK_PIXBUF
+static void image_viewer_show_mimepart(MimeViewer *_mimeviewer, const gchar *file, MimeInfo *mimeinfo)
+{
+ ImageViewer *imageviewer = (ImageViewer *) _mimeviewer;
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf_scaled;
+ GdkPixmap *pixmap;
+ GdkBitmap *mask;
+ gint avail_width;
+ gint avail_height;
+ gint new_width;
+ gint new_height;
+ gchar *imgfile;
+
+ debug_print("image_viewer_show_mimepart\n");
+
+ g_return_if_fail(imageviewer != NULL);
+
+ image_viewer_clear_viewer(_mimeviewer);
+
+ imgfile = procmime_get_tmp_file_name(mimeinfo);
+ if (procmime_get_part(imgfile, file, mimeinfo) < 0) {
+ g_warning("Can't get mimepart file");
+ g_free(imgfile);
+ return;
+ }
+
+ pixbuf = gdk_pixbuf_new_from_file(imgfile);
+ unlink(imgfile);
+ g_free(imgfile);
+ if (!pixbuf) {
+ g_warning("Can't load the image.");
+ return;
+ }
+
+ if (resize) {
+ avail_width = imageviewer->scrolledwin->parent->allocation.width;
+ avail_height = imageviewer->scrolledwin->parent->allocation.height;
+ if (avail_width > 8) avail_width -= 8;
+ if (avail_height > 8) avail_height -= 8;
+
+ image_viewer_get_resized_size(gdk_pixbuf_get_width(pixbuf),
+ gdk_pixbuf_get_height(pixbuf),
+ avail_width, avail_height,
+ &new_width, &new_height);
+
+ pixbuf_scaled = gdk_pixbuf_scale_simple
+ (pixbuf, new_width, new_height, GDK_INTERP_BILINEAR);
+ gdk_pixbuf_unref(pixbuf);
+ pixbuf = pixbuf_scaled;
+ }
+
+ gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &mask, 0);
+
+ if (!imageviewer->image) {
+ imageviewer->image = gtk_pixmap_new(pixmap, mask);
+
+ gtk_scrolled_window_add_with_viewport
+ (GTK_SCROLLED_WINDOW(imageviewer->scrolledwin),
+ imageviewer->image);
+ } else
+ gtk_pixmap_set(GTK_PIXMAP(imageviewer->image), pixmap, mask);
+
+ gtk_widget_show(imageviewer->image);
+
+ gdk_pixbuf_unref(pixbuf);
+}
+#else
+#if HAVE_GDK_IMLIB
+static void image_viewer_show_mimepart(MimeViewer *_mimeviewer, const gchar *file, MimeInfo *mimeinfo)
+{
+ ImageViewer *imageviewer = (ImageViewer *) _mimeviewer;
+ GdkImlibImage *im;
+ gint avail_width;
+ gint avail_height;
+ gint new_width;
+ gint new_height;
+ gchar *imgfile;
+
+ debug_print("image_viewer_show_mimepart\n");
+
+ g_return_if_fail(imageviewer != NULL);
+
+ image_viewer_clear_viewer(imageviewer);
+
+ imgfile = procmime_get_tmp_file_name(mimeinfo);
+ if (procmime_get_part(imgfile, file, mimeinfo) < 0) {
+ g_warning("Can't get mimepart file");
+ g_free(imgfile);
+ return;
+ }
+
+ im = gdk_imlib_load_image(imgfile);
+ unlink(imgfile);
+ g_free(imgfile);
+ if (!im) {
+ g_warning("Can't load the image.");
+ return;
+ }
+
+ if (resize) {
+ avail_width = imageviewer->scrolledwin->parent->allocation.width;
+ avail_height = imageviewer->scrolledwin->parent->allocation.height;
+ if (avail_width > 8) avail_width -= 8;
+ if (avail_height > 8) avail_height -= 8;
+
+ image_viewer_get_resized_size(im->rgb_width, im->rgb_height,
+ avail_width, avail_height,
+ &new_width, &new_height);
+ } else {
+ new_width = im->rgb_width;
+ new_height = im->rgb_height;
+ }
+
+ gdk_imlib_render(im, new_width, new_height);
+
+ if (!imageviewer->image) {
+ imageviewer->image = gtk_pixmap_new(gdk_imlib_move_image(im),
+ gdk_imlib_move_mask(im));
+
+ gtk_scrolled_window_add_with_viewport
+ (GTK_SCROLLED_WINDOW(imageviewer->scrolledwin),
+ imageviewer->image);
+ } else
+ gtk_pixmap_set(GTK_PIXMAP(imageviewer->image),
+ gdk_imlib_move_image(im),
+ gdk_imlib_move_mask(im));
+
+ gtk_widget_show(imageviewer->image);
+
+ gdk_imlib_destroy_image(im);
+}
+#endif /* HAVE_GDK_IMLIB */
+#endif /* HAVE_GDK_PIXBUF */
+
+static void image_viewer_clear_viewer(MimeViewer *_mimeviewer)
+{
+ ImageViewer *imageviewer = (ImageViewer *) _mimeviewer;
+ GtkAdjustment *hadj, *vadj;
+
+ debug_print("image_viewer_clear_viewer\n");
+
+ if (imageviewer->image)
+ gtk_pixmap_set(GTK_PIXMAP(imageviewer->image), NULL, NULL);
+ hadj = gtk_scrolled_window_get_hadjustment
+ (GTK_SCROLLED_WINDOW(imageviewer->scrolledwin));
+ gtk_adjustment_set_value(hadj, 0.0);
+ vadj = gtk_scrolled_window_get_vadjustment
+ (GTK_SCROLLED_WINDOW(imageviewer->scrolledwin));
+ gtk_adjustment_set_value(vadj, 0.0);
+}
+
+static void image_viewer_destroy_viewer(MimeViewer *_mimeviewer)
+{
+ ImageViewer *imageviewer = (ImageViewer *) _mimeviewer;
+
+ debug_print("image_viewer_destroy_viewer\n");
+
+ image_viewer_clear_viewer(_mimeviewer);
+ gtk_widget_unref(imageviewer->scrolledwin);
+ g_free(imageviewer);
+}
+
+static void image_viewer_get_resized_size(gint w, gint h, gint aw, gint ah,
+ gint *sw, gint *sh)
+{
+ gfloat wratio = 1.0;
+ gfloat hratio = 1.0;
+ gfloat ratio = 1.0;
+
+ if (w > aw)
+ wratio = (gfloat)aw / (gfloat)w;
+ if (h > ah)
+ hratio = (gfloat)ah / (gfloat)h;
+
+ ratio = (wratio > hratio) ? hratio : wratio;
+
+ *sw = (gint)(w * ratio);
+ *sh = (gint)(h * ratio);
+
+ /* be paranoid */
+ if (*sw <= 0 || *sh <= 0) {
+ *sw = w;
+ *sh = h;
+ }
+}
+
+MimeViewer *image_viewer_create(void)
+{
+ ImageViewer *imageviewer;
+ GtkWidget *scrolledwin;
+
+ debug_print("Creating image view...\n");
+ imageviewer = g_new0(ImageViewer, 1);
+ imageviewer->mimeviewer.factory = &image_viewer_factory;
+
+ imageviewer->mimeviewer.get_widget = image_viewer_get_widget;
+ imageviewer->mimeviewer.show_mimepart = image_viewer_show_mimepart;
+ imageviewer->mimeviewer.clear_viewer = image_viewer_clear_viewer;
+ imageviewer->mimeviewer.destroy_viewer = image_viewer_destroy_viewer;
+
+ scrolledwin = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_widget_ref(scrolledwin);
+
+ gtk_widget_show_all(scrolledwin);
+
+ imageviewer->scrolledwin = scrolledwin;
+ imageviewer->image = NULL;
+
+ return (MimeViewer *) imageviewer;
+}
+
+MimeViewerFactory image_viewer_factory =
+{
+ "image/*",
+ 0,
+
+ image_viewer_create,
+};
--- /dev/null
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2003 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
+ * 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.
+ */
+
+#ifndef VIEWER_H
+#define VIEWER_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "mimeview.h"
+
+extern MimeViewerFactory image_viewer_factory;
+
+#endif
GtkObject *spinbtn_scrollstep_adj;
GtkWidget *chkbtn_halfpage;
- GtkWidget *chkbtn_display_img;
- GtkWidget *chkbtn_resize_image;
-
GtkWidget *chkbtn_attach_desc;
} message;
&message.chkbtn_halfpage,
prefs_set_data_from_toggle, prefs_set_toggle},
- {"display_img", "TRUE", &prefs_common.display_img, P_BOOL,
- &message.chkbtn_display_img,
- prefs_set_data_from_toggle, prefs_set_toggle},
- {"resize_image", "TRUE", &prefs_common.resize_image, P_BOOL,
- &message.chkbtn_resize_image,
- prefs_set_data_from_toggle, prefs_set_toggle},
-
{"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL,
NULL, NULL, NULL},
GtkWidget *spinbtn_scrollstep;
GtkWidget *chkbtn_halfpage;
- GtkWidget *chkbtn_display_img;
- GtkWidget *chkbtn_resize_image;
-
GtkWidget *chkbtn_attach_desc;
vbox1 = gtk_vbox_new (FALSE, VSPACING);
gtk_widget_show (vbox3);
gtk_box_pack_start (GTK_BOX (vbox1), vbox3, FALSE, FALSE, 0);
- PACK_CHECK_BUTTON(vbox3, chkbtn_display_img,
- _("Automatically display attached images"));
-
- PACK_CHECK_BUTTON(vbox3, chkbtn_resize_image,
- _("Resize attached images"));
-
PACK_CHECK_BUTTON(vbox3, chkbtn_attach_desc,
_("Show attachment descriptions (rather than names)"));
message.spinbtn_scrollstep_adj = spinbtn_scrollstep_adj;
message.chkbtn_halfpage = chkbtn_halfpage;
- message.chkbtn_display_img = chkbtn_display_img;
- message.chkbtn_resize_image = chkbtn_resize_image;
-
message.chkbtn_attach_desc = chkbtn_attach_desc;
}
gint scroll_step;
gboolean scroll_halfpage;
- gboolean display_img;
- gboolean resize_image;
-
gchar *force_charset;
gboolean show_other_header;
TEXT_INSERT(_("To display this part as a text message, select "));
TEXT_INSERT(_("`Display as text', or press `t' key.\n\n"));
- TEXT_INSERT(_("To display this part as an image, select "));
- TEXT_INSERT(_("`Display image', or press `i' key.\n\n"));
-
TEXT_INSERT(_("To open this part with external program, select "));
TEXT_INSERT(_("`Open' or `Open with...', "));
TEXT_INSERT(_("or double-click, or click the center button, "));