2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999,2000 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <gtk/gtkscrolledwindow.h>
26 #include <gtk/gtkpixmap.h>
29 # include <gdk-pixbuf/gdk-pixbuf.h>
32 # include <gdk_imlib.h>
34 #endif /* HAVE_GDK_PIXBUF */
37 #include "mainwindow.h"
38 #include "prefs_common.h"
40 #include "imageview.h"
43 ImageView *imageview_create(void)
46 GtkWidget *scrolledwin;
48 debug_print(_("Creating image view...\n"));
49 imageview = g_new0(ImageView, 1);
51 scrolledwin = gtk_scrolled_window_new(NULL, NULL);
52 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
54 GTK_POLICY_AUTOMATIC);
55 gtk_widget_set_usize(scrolledwin, prefs_common.mainview_width, -1);
57 gtk_widget_show_all(scrolledwin);
59 imageview->scrolledwin = scrolledwin;
60 imageview->image = NULL;
65 void imageview_init(ImageView *imageview)
70 void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo,
77 pixbuf = gdk_pixbuf_new_from_file(file);
80 g_warning(_("Can't load the image."));
82 gtk_widget_hide(imageview->image);
86 if (imageview->messageview->mainwin)
87 main_window_cursor_wait(imageview->messageview->mainwin);
89 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &mask, 0);
91 if (!imageview->image) {
92 imageview->image = gtk_pixmap_new(pixmap, mask);
94 gtk_scrolled_window_add_with_viewport
95 (GTK_SCROLLED_WINDOW(imageview->scrolledwin),
98 gtk_pixmap_set(GTK_PIXMAP(imageview->image), pixmap, mask);
100 gtk_widget_show(imageview->image);
102 gdk_pixbuf_unref(pixbuf);
104 if (imageview->messageview->mainwin)
105 main_window_cursor_normal(imageview->messageview->mainwin);
109 void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo,
114 im = gdk_imlib_load_image((gchar *)file);
117 g_warning(_("Can't load the image."));
118 if (imageview->image)
119 gtk_widget_hide(imageview->image);
123 if (imageview->messageview->mainwin)
124 main_window_cursor_wait(imageview->messageview->mainwin);
126 gdk_imlib_render(im, im->rgb_width, im->rgb_height);
128 if (!imageview->image) {
129 imageview->image = gtk_pixmap_new(gdk_imlib_move_image(im),
130 gdk_imlib_move_mask(im));
132 gtk_scrolled_window_add_with_viewport
133 (GTK_SCROLLED_WINDOW(imageview->scrolledwin),
136 gtk_pixmap_set(GTK_PIXMAP(imageview->image),
137 gdk_imlib_move_image(im),
138 gdk_imlib_move_mask(im));
140 gtk_widget_show(imageview->image);
142 gdk_imlib_destroy_image(im);
144 if (imageview->messageview->mainwin)
145 main_window_cursor_normal(imageview->messageview->mainwin);
148 void imageview_show_image(ImageView *imageview, MimeInfo *mimeinfo,
152 #endif /* HAVE_GDK_IMLIB */
153 #endif /* HAVE_GDK_PIXBUF */
155 void imageview_destroy(ImageView *imageview)