diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-03-08 11:06:12 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-03-08 11:06:12 +0000 |
commit | a305abdfe054c5ef5e472d2d99723b4032308b1d (patch) | |
tree | 22f7d398e3c7718d84879e622df2c6e61d7eb34c | |
parent | 0ff75d10977146767ccc42c2e2915f75886a68bf (diff) |
also resize inline images.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@155 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | ChangeLog.ja | 10 | ||||
-rw-r--r-- | configure.in | 10 | ||||
-rw-r--r-- | src/about.c | 6 | ||||
-rw-r--r-- | src/imageview.c | 63 | ||||
-rw-r--r-- | src/imageview.h | 7 | ||||
-rw-r--r-- | src/mimeview.c | 2 | ||||
-rw-r--r-- | src/textview.c | 13 |
8 files changed, 66 insertions, 55 deletions
@@ -1,5 +1,15 @@ 2005-03-08 + * src/imageview.[ch]: imageview_get_resized_pixbuf(): new. + src/textview.c: textview_add_part(): follow the setting of + prefs_common.resize_image. + * src/configure.in + src/about.c + src/mimeview.c: removed enable-gdk-pixbuf option since gdk-pixbuf + is now built-in. + +2005-03-08 + * src/messageview.[ch] src/mimeview.[ch]: changed the implementation of switching Text/MIME view (enables smooth switching). diff --git a/ChangeLog.ja b/ChangeLog.ja index e54ee4ca..4a732767 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,15 @@ 2005-03-08 + * src/imageview.[ch]: imageview_get_resized_pixbuf(): 新規。 + src/textview.c: textview_add_part(): prefs_common.resize_image + の設定に従うようにした。 + * src/configure.in + src/about.c + src/mimeview.c: gdk-pixbuf は現在内蔵されているため、 + enable-gdk-pixbuf のオプションを削除。 + +2005-03-08 + * src/messageview.[ch] src/mimeview.[ch]: テキスト/MIME ビュー切り替えの実装を変更 (切り替えがスムーズになった)。 diff --git a/configure.in b/configure.in index 265111f1..64df089a 100644 --- a/configure.in +++ b/configure.in @@ -95,15 +95,6 @@ AC_SUBST(manualdir) faqdir='${prefix}/${DATADIRNAME}/${PACKAGE}/faq' AC_SUBST(faqdir) -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]) - -if test "$ac_cv_enable_gdk_pixbuf" = yes; then - AC_DEFINE(HAVE_GDK_PIXBUF, 1, Define if you use gdk-pixbuf to support image view) -fi - dnl GPGME is used to support OpenPGP AC_ARG_ENABLE(gpgme, [ --enable-gpgme Enable GnuPG support using GPGME [default=no]], @@ -343,7 +334,6 @@ dnl Output the configuration summary echo "" echo "$PACKAGE $VERSION" echo "" -echo "image support : $ac_cv_enable_gdk_pixbuf" echo "GnuPG : $ac_cv_enable_gpgme" echo "JPilot : $ac_cv_enable_jpilot" echo "LDAP : $ac_cv_enable_ldap" diff --git a/src/about.c b/src/about.c index a9cea2e5..795744fc 100644 --- a/src/about.c +++ b/src/about.c @@ -127,12 +127,6 @@ static void about_create(void) g_snprintf(buf, sizeof(buf), "Compiled-in features:%s", -#if HAVE_GDK_IMLIB - " gdk_imlib" -#endif -#if HAVE_GDK_PIXBUF - " gdk-pixbuf" -#endif #if USE_THREADS " gthread" #endif diff --git a/src/imageview.c b/src/imageview.c index 2aa70683..2f664dc8 100644 --- a/src/imageview.c +++ b/src/imageview.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2004 Hiroyuki Yamamoto + * Copyright (C) 1999-2005 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 @@ -25,10 +25,7 @@ #include <glib/gi18n.h> #include <gtk/gtkscrolledwindow.h> #include <gtk/gtkimage.h> - -#if HAVE_GDK_PIXBUF -# include <gdk-pixbuf/gdk-pixbuf.h> -#endif /* HAVE_GDK_PIXBUF */ +#include <gdk-pixbuf/gdk-pixbuf.h> #include "mainwindow.h" #include "prefs_common.h" @@ -85,15 +82,10 @@ void imageview_init(ImageView *imageview) { } -#if HAVE_GDK_PIXBUF void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo, const gchar *file, gboolean resize) { GdkPixbuf *pixbuf; - gint avail_width; - gint avail_height; - gint new_width; - gint new_height; GError *error = NULL; g_return_if_fail(imageview != NULL); @@ -119,21 +111,8 @@ void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo, imageview->resize = resize; if (resize) { - GdkPixbuf *pixbuf_scaled; - - 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; - - 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); - pixbuf = pixbuf_scaled; + pixbuf = imageview_get_resized_pixbuf + (pixbuf, imageview->scrolledwin->parent, 8); } else g_object_ref(pixbuf); @@ -146,16 +125,10 @@ void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo, } else gtk_image_set_from_pixbuf(GTK_IMAGE(imageview->image), pixbuf); - gdk_pixbuf_unref(pixbuf); + g_object_unref(pixbuf); gtk_widget_show(imageview->image); } -#else -void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo, - const gchar *file, gboolean resize) -{ -} -#endif /* HAVE_GDK_PIXBUF */ void imageview_clear(ImageView *imageview) { @@ -172,9 +145,7 @@ void imageview_clear(ImageView *imageview) gtk_adjustment_set_value(vadj, 0.0); if (imageview->image_data) { -#if HAVE_GDK_PIXBUF - gdk_pixbuf_unref((GdkPixbuf *)imageview->image_data); -#endif + g_object_unref(imageview->image_data); imageview->image_data = NULL; } } @@ -185,6 +156,28 @@ void imageview_destroy(ImageView *imageview) g_free(imageview); } +GdkPixbuf *imageview_get_resized_pixbuf(GdkPixbuf *pixbuf, GtkWidget *parent, + gint margin) +{ + gint avail_width; + gint avail_height; + gint new_width; + gint new_height; + + avail_width = parent->allocation.width; + avail_height = parent->allocation.height; + if (avail_width > margin) avail_width -= margin; + if (avail_height > margin) avail_height -= margin; + + get_resized_size(gdk_pixbuf_get_width(pixbuf), + gdk_pixbuf_get_height(pixbuf), + avail_width, avail_height, + &new_width, &new_height); + + return gdk_pixbuf_scale_simple + (pixbuf, new_width, new_height, GDK_INTERP_BILINEAR); +} + static void get_resized_size(gint w, gint h, gint aw, gint ah, gint *sw, gint *sh) { diff --git a/src/imageview.h b/src/imageview.h index 52269e3e..19146e7d 100644 --- a/src/imageview.h +++ b/src/imageview.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2004 Hiroyuki Yamamoto + * Copyright (C) 1999-2005 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 @@ -22,6 +22,7 @@ #include <glib.h> #include <gtk/gtkwidget.h> +#include <gdk-pixbuf/gdk-pixbuf.h> typedef struct _ImageView ImageView; @@ -49,4 +50,8 @@ void imageview_show_image (ImageView *imageview, void imageview_clear (ImageView *imageview); void imageview_destroy (ImageView *imageview); +GdkPixbuf *imageview_get_resized_pixbuf (GdkPixbuf *pixbuf, + GtkWidget *parent, + gint margin); + #endif /* __IMAGEVIEW_H__ */ diff --git a/src/mimeview.c b/src/mimeview.c index 124de6f8..d6529f8e 100644 --- a/src/mimeview.c +++ b/src/mimeview.c @@ -695,11 +695,9 @@ static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column, case MIME_MULTIPART: mimeview_show_message_part(mimeview, partinfo); break; -#if (HAVE_GDK_PIXBUF || HAVE_GDK_IMLIB) case MIME_IMAGE: mimeview_show_image_part(mimeview, partinfo); break; -#endif default: mimeview_change_view_type(mimeview, MIMEVIEW_TEXT); #if USE_GPGME diff --git a/src/textview.c b/src/textview.c index 81142690..8720f62b 100644 --- a/src/textview.c +++ b/src/textview.c @@ -30,6 +30,7 @@ #include <gtk/gtkvbox.h> #include <gtk/gtkscrolledwindow.h> #include <gtk/gtksignal.h> +#include <gdk-pixbuf/gdk-pixbuf.h> #include <stdio.h> #include <ctype.h> #include <string.h> @@ -37,6 +38,7 @@ #include "main.h" #include "summaryview.h" +#include "imageview.h" #include "procheader.h" #include "prefs_common.h" #include "codeconv.h" @@ -619,10 +621,19 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp) return; } + if (prefs_common.resize_image) { + GdkPixbuf *scaled; + + scaled = imageview_get_resized_pixbuf + (pixbuf, textview->text, 8); + g_object_unref(pixbuf); + pixbuf = scaled; + } + gtk_text_buffer_insert_pixbuf(buffer, &iter, pixbuf); gtk_text_buffer_insert(buffer, &iter, "\n", 1); - g_object_unref(G_OBJECT(pixbuf)); + g_object_unref(pixbuf); } } else { if (!mimeinfo->main && |