0.8.11claws46
authorChristoph Hohmann <reboot@gmx.ch>
Tue, 25 Mar 2003 20:07:15 +0000 (20:07 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Tue, 25 Mar 2003 20:07:15 +0000 (20:07 +0000)
* 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]

17 files changed:
ChangeLog.claws
configure.ac
src/Makefile.am
src/imageview.c [deleted file]
src/messageview.c
src/messageview.h
src/mimeview.c
src/mimeview.h
src/plugins/Makefile.am
src/plugins/image_viewer/.cvsignore [new file with mode: 0644]
src/plugins/image_viewer/Makefile.am [new file with mode: 0644]
src/plugins/image_viewer/plugin.c [moved from src/imageview.h with 52% similarity]
src/plugins/image_viewer/viewer.c [new file with mode: 0644]
src/plugins/image_viewer/viewer.h [new file with mode: 0644]
src/prefs_common.c
src/prefs_common.h
src/textview.c

index 1b87983..26f231c 100644 (file)
@@ -1,3 +1,20 @@
+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
index 2d9f254..f160d03 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 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
@@ -335,28 +335,6 @@ else
        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]],
@@ -409,10 +387,40 @@ 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"
+       [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,
@@ -443,6 +451,7 @@ src/plugins/demo/Makefile
 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
index d2f649b..29e6a94 100644 (file)
@@ -10,7 +10,6 @@ sylpheed_SOURCES = \
        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 \
@@ -208,8 +207,6 @@ INCLUDES = \
        -I$(top_srcdir)/intl \
         $(ASPELL_CFLAGS)    \
        $(GTK_CFLAGS) \
-       $(GDK_IMLIB_CFLAGS) \
-       $(GDK_PIXBUF_CFLAGS) \
        $(GPGME_CFLAGS) \
        $(OPENSSL_CFLAGS) \
        -I$(includedir)
@@ -219,8 +216,6 @@ sylpheed_LDADD = \
        $(INTLLIBS) \
        $(ASPELL_LIBS) \
        $(GTK_LIBS) \
-       $(GDK_IMLIB_LIBS) \
-       $(GDK_PIXBUF_LIBS) \
        $(GPGME_LIBS) \
        $(LDAP_LIBS) \
        $(OPENSSL_LIBS) \
diff --git a/src/imageview.c b/src/imageview.c
deleted file mode 100644 (file)
index 7edad32..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * 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;
-       }
-}
index cf89394..effc435 100644 (file)
@@ -36,7 +36,6 @@
 #include "headerview.h"
 #include "summaryview.h"
 #include "textview.h"
-#include "imageview.h"
 #include "mimeview.h"
 #include "procmsg.h"
 #include "procheader.h"
@@ -92,7 +91,6 @@ MessageView *messageview_create(MainWindow *mainwin)
        GtkWidget *vbox;
        HeaderView *headerview;
        TextView *textview;
-       ImageView *imageview;
        MimeView *mimeview;
        NoticeView *noticeview;
 
@@ -108,13 +106,9 @@ MessageView *messageview_create(MainWindow *mainwin)
        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);
@@ -127,7 +121,6 @@ MessageView *messageview_create(MainWindow *mainwin)
 
        /* 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));
 
@@ -136,7 +129,6 @@ MessageView *messageview_create(MainWindow *mainwin)
        messageview->window     = NULL;
        messageview->headerview = headerview;
        messageview->textview   = textview;
-       messageview->imageview  = imageview;
        messageview->mimeview   = mimeview;
        messageview->noticeview = noticeview;
        messageview->mainwin    = mainwin;
@@ -245,7 +237,6 @@ void messageview_init(MessageView *messageview)
 {
        headerview_init(messageview->headerview);
        textview_init(messageview->textview);
-       imageview_init(messageview->imageview);
        mimeview_init(messageview->mimeview);
        /*messageview_set_font(messageview);*/
 
@@ -606,20 +597,17 @@ void messageview_clear(MessageView *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);
 
@@ -634,7 +622,6 @@ void messageview_destroy(MessageView *messageview)
        g_free(messageview);
 
        gtk_widget_unref(textview);
-       gtk_widget_unref(imageview);
        gtk_widget_unref(mimeview);
 }
 
index 8cdfae2..57ee9fe 100644 (file)
@@ -28,7 +28,6 @@ typedef struct _MessageView           MessageView;
 #include "mainwindow.h"
 #include "headerview.h"
 #include "textview.h"
-#include "imageview.h"
 #include "mimeview.h"
 #include "noticeview.h"
 #include "procmsg.h"
@@ -55,7 +54,6 @@ struct _MessageView
 
        HeaderView *headerview;
        TextView *textview;
-       ImageView *imageview;
        MimeView *mimeview;
        NoticeView *noticeview;
 
index db5e0a1..7f47500 100644 (file)
@@ -72,8 +72,6 @@ static GtkCTreeNode *mimeview_append_part     (MimeView       *mimeview,
                                                 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);
@@ -101,7 +99,6 @@ static void mimeview_drag_data_get      (GtkWidget     *widget,
                                         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);
@@ -115,7 +112,6 @@ static GtkItemFactoryEntry mimeview_popup_entries[] =
        {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
@@ -483,30 +479,6 @@ static void mimeview_show_message_part(MimeView *mimeview, MimeInfo *partinfo)
        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;
@@ -562,7 +534,6 @@ static gboolean mimeview_show_part(MimeView *mimeview, MimeInfo *partinfo)
 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) && 
@@ -576,10 +547,6 @@ static void mimeview_change_view_type(MimeView *mimeview, MimeViewType type)
        }
 
        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));
@@ -604,7 +571,6 @@ static void mimeview_clear(MimeView *mimeview)
 
        gtk_clist_clear(clist);
        textview_clear(mimeview->textview);
-       imageview_clear(mimeview->imageview);
        if (mimeview->mimeviewer != NULL)
                mimeview->mimeviewer->clear_viewer(mimeview->mimeviewer);
 
@@ -647,17 +613,6 @@ static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
                        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);
@@ -737,11 +692,6 @@ static gint mimeview_button_pressed(GtkWidget *widget, GdkEventButton *event,
                        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",
@@ -828,11 +778,6 @@ static gint mimeview_key_pressed(GtkWidget *widget, GdkEventKey *event,
                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();
@@ -953,17 +898,6 @@ static void mimeview_display_as_text(MimeView *mimeview)
        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;
index 46d89d2..1551d28 100644 (file)
@@ -30,14 +30,12 @@ typedef struct _MimeViewerFactory   MimeViewerFactory;
 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;
 
@@ -59,7 +57,6 @@ struct _MimeView
        GtkCTreeNode *opened;
 
        TextView *textview;
-       ImageView *imageview;
        MimeViewer *mimeviewer;
 
        MessageView *messageview;
index ab83c20..d489af7 100644 (file)
@@ -14,6 +14,10 @@ if BUILD_DILLO_VIEWER_PLUGIN
 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
@@ -22,4 +26,5 @@ SUBDIRS = $(demo_dir) \
        $(spamassasssin_dir) \
        $(mathml_viewer_dir) \
        $(dillo_viewer_dir) \
+       $(image_viewer_dir) \
        $(trayicon_dir)
diff --git a/src/plugins/image_viewer/.cvsignore b/src/plugins/image_viewer/.cvsignore
new file mode 100644 (file)
index 0000000..9887868
--- /dev/null
@@ -0,0 +1,7 @@
+.deps
+.libs
+Makefile
+Makefile.in
+*.o
+*.la
+*.lo
\ No newline at end of file
diff --git a/src/plugins/image_viewer/Makefile.am b/src/plugins/image_viewer/Makefile.am
new file mode 100644 (file)
index 0000000..8ad0ce7
--- /dev/null
@@ -0,0 +1,25 @@
+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)
similarity index 52%
rename from src/imageview.h
rename to src/plugins/image_viewer/plugin.c
index fa524b1..89a1b21 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * 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";
+}
diff --git a/src/plugins/image_viewer/viewer.c b/src/plugins/image_viewer/viewer.c
new file mode 100644 (file)
index 0000000..9be3808
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * 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,
+};
diff --git a/src/plugins/image_viewer/viewer.h b/src/plugins/image_viewer/viewer.h
new file mode 100644 (file)
index 0000000..a5afc82
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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
index aafc7fe..349f22c 100644 (file)
@@ -187,9 +187,6 @@ static struct Message {
        GtkObject *spinbtn_scrollstep_adj;
        GtkWidget *chkbtn_halfpage;
 
-       GtkWidget *chkbtn_display_img;
-       GtkWidget *chkbtn_resize_image;
-
        GtkWidget *chkbtn_attach_desc;
 } message;
 
@@ -684,13 +681,6 @@ static PrefParam param[] = {
         &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},
 
@@ -2341,9 +2331,6 @@ static void prefs_message_create(void)
        GtkWidget *spinbtn_scrollstep;
        GtkWidget *chkbtn_halfpage;
 
-       GtkWidget *chkbtn_display_img;
-       GtkWidget *chkbtn_resize_image;
-
        GtkWidget *chkbtn_attach_desc;
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
@@ -2474,12 +2461,6 @@ static void prefs_message_create(void)
        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)"));
 
@@ -2497,9 +2478,6 @@ static void prefs_message_create(void)
        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;
 }
 
index 5fb7791..0209d8e 100644 (file)
@@ -210,9 +210,6 @@ struct _PrefsCommon
        gint scroll_step;
        gboolean scroll_halfpage;
 
-       gboolean display_img;
-       gboolean resize_image;
-
        gchar *force_charset;
 
        gboolean show_other_header;
index 235a7b9..bc412c9 100644 (file)
@@ -605,9 +605,6 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
        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, "));