+Wed Jan 5 02:33:06 2005 Jonathan Blandford <jrb@redhat.com>
+
+ * backend/ev-document-misc.[ch]: New misc file to do simple drop
+ shadows.
+
+ * pdf/xpdf/pdf-document.cc: use the drop shadows in both types of
+ thumbnails..
+
Tue Jan 4 22:32:32 2005 Jonathan Blandford <jrb@redhat.com>
* pdf/xpdf/pdf-document.cc
ev-document-find.h \
ev-ps-exporter.c \
ev-ps-exporter.h \
+ ev-document-misc.h \
+ ev-document-misc.c \
$(NULL)
BUILT_SOURCES= \
--- /dev/null
+
+#include "ev-document-misc.h"
+
+/* Returns a new GdkPixbuf that is suitable for placing in the thumbnail view.
+ * It is four pixels wider and taller than the source. If source_pixbuf is not
+ * NULL, then it will fill the return pixbuf with the contents of
+ * source_pixbuf. */
+GdkPixbuf *
+ev_document_misc_get_thumbnail_frame (int width,
+ int height,
+ GdkPixbuf *source_pixbuf)
+{
+ GdkPixbuf *retval;
+ guchar *data;
+ gint rowstride;
+
+ if (source_pixbuf)
+ g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL);
+
+ if (source_pixbuf) {
+ width = gdk_pixbuf_get_width (source_pixbuf);
+ height = gdk_pixbuf_get_height (source_pixbuf);
+ }
+
+ /* make sure no one is passing us garbage */
+ g_assert (width > 0 && height > 0);
+
+ retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ TRUE, 8,
+ width + 4,
+ height + 4);
+ gdk_pixbuf_fill (retval, 0x000000ff);
+ if (source_pixbuf)
+ gdk_pixbuf_copy_area (source_pixbuf, 0, 0,
+ width,
+ height,
+ retval,
+ 1, 1);
+ /* Add the corner */
+ data = gdk_pixbuf_get_pixels (retval);
+ rowstride = gdk_pixbuf_get_rowstride (retval);
+ data [(width + 2) * 4 + 3] = 0;
+ data [(width + 3) * 4 + 3] = 0;
+ data [(width + 2) * 4 + (rowstride * 1) + 3] = 0;
+ data [(width + 3) * 4 + (rowstride * 1) + 3] = 0;
+
+ data [(height + 2) * rowstride + 3] = 0;
+ data [(height + 3) * rowstride + 3] = 0;
+ data [(height + 2) * rowstride + 4 + 3] = 0;
+ data [(height + 3) * rowstride + 4 + 3] = 0;
+
+ return retval;
+}
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2000-2003 Marco Pesenti Gritti
+ *
+ * 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, 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.
+ *
+ * $Id$
+ */
+
+#ifndef EV_DOCUMENT_MISC_H
+#define EV_DOCUMENT_MISC_H
+
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+G_BEGIN_DECLS
+
+
+GdkPixbuf *ev_document_misc_get_thumbnail_frame (int width,
+ int height,
+ GdkPixbuf *source_pixbuf);
+
+G_END_DECLS
+
+#endif /* EV_DOCUMENT_MISC_H */
#include "ev-document-find.h"
#include "gpdf-g-switch.h"
#include "ev-document-bookmarks.h"
+#include "ev-document-misc.h"
#include "ev-document-thumbnails.h"
#include "GlobalParams.h"
GDKSplashOutputDev *output;
GdkPixbuf *pixbuf;
GdkPixbuf *shadow;
- gint rowstride;
- guchar *data;
pixmap = gdk_pixmap_new (pdf_document->target,
width, height, -1);
gdk_drawable_unref (pixmap);
delete output;
- shadow = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- TRUE, 8,
- width + 4,
- height + 4);
- gdk_pixbuf_fill (shadow, 0x000000ff);
- gdk_pixbuf_copy_area (pixbuf, 0, 0,
- width,
- height,
- shadow,
- 1, 1);
+ shadow = ev_document_misc_get_thumbnail_frame (-1, -1, pixbuf);
g_object_unref (pixbuf);
- /* Add the corner */
- data = gdk_pixbuf_get_pixels (shadow);
- rowstride = gdk_pixbuf_get_rowstride (shadow);
- data [(width + 2) * 4 + 3] = 0;
- data [(width + 3) * 4 + 3] = 0;
- data [(width + 2) * 4 + (rowstride * 1) + 3] = 0;
- data [(width + 3) * 4 + (rowstride * 1) + 3] = 0;
-
- data [(height + 2) * rowstride + 3] = 0;
- data [(height + 3) * rowstride + 3] = 0;
- data [(height + 2) * rowstride + 4 + 3] = 0;
- data [(height + 3) * rowstride + 4 + 3] = 0;
-
return shadow;
}
Object the_thumb;
Thumb *thumb = NULL;
gboolean have_ethumbs = FALSE;
+ gdouble page_ratio;
+ gint dest_height;
/* getPage seems to want page + 1 for some reason; */
the_page = pdf_document->doc->getCatalog ()->getPage (page + 1);
the_page->getThumb(&the_thumb);
+ page_ratio = the_page->getHeight () / the_page->getWidth ();
+ dest_height = (gint) (width * page_ratio);
+
+
if (!(the_thumb.isNull () || the_thumb.isNone())) {
/* Build the thumbnail object */
thumb = new Thumb(pdf_document->doc->getXRef (),
GdkPixbuf *tmp_pixbuf;
data = thumb->getPixbufData();
- /* FISME: scale the image if it's not an appropriate size */
tmp_pixbuf = gdk_pixbuf_new_from_data (data,
GDK_COLORSPACE_RGB,
FALSE,
thumb->getHeight (),
thumb->getWidth () * 3,
NULL, NULL);
-
- thumbnail = tmp_pixbuf;
+ /* FIXME: do we want to check that the thumb's size isn't ridiculous?? */
+ thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
+ g_object_unref (tmp_pixbuf);
} else {
- gdouble page_ratio;
gdouble scale_factor;
- gint dest_height;
- page_ratio = the_page->getHeight () / the_page->getWidth ();
scale_factor = (gdouble)width / the_page->getWidth ();
- dest_height = (gint) (width * page_ratio);
thumbnail = pdf_document_thumbnails_get_page_pixbuf (pdf_document,
scale_factor,
page,
width,
dest_height);
-
- /* FIXME: Actually get the image... */
}
return thumbnail;
ev-sidebar-thumbnails.h \
ev-stock-icons.c \
ev-stock-icons.h \
- ev-utils.c \
- ev-utils.h \
main.c \
$(NULL)
#include "ev-document-thumbnails.h"
#include "ev-utils.h"
-#define THUMBNAIL_WIDTH 96
+#define THUMBNAIL_WIDTH 75
/* Amount of time we devote to each iteration of the idle, in microseconds */
#define IDLE_WORK_LENGTH 5000
{
GtkWidget *swindow;
EvSidebarThumbnailsPrivate *priv;
+ GtkCellRenderer *renderer;
priv = ev_sidebar_thumbnails->priv = EV_SIDEBAR_THUMBNAILS_GET_PRIVATE (ev_sidebar_thumbnails);
priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->list_store));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);
+ renderer = g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF,
+ "xpad", 2,
+ "ypad", 2,
+ NULL);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->tree_view), -1,
- NULL, gtk_cell_renderer_pixbuf_new (),
- "pixbuf", 1, NULL);
+ NULL, renderer,
+ "pixbuf", 1,
+ NULL);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->tree_view), -1,
NULL, gtk_cell_renderer_text_new (),
- "text", 0, NULL);
+ "markup", 0, NULL);
g_object_unref (priv->list_store);
do_one_iteration (EvSidebarThumbnails *ev_sidebar_thumbnails)
{
EvSidebarThumbnailsPrivate *priv = ev_sidebar_thumbnails->priv;
- GdkPixbuf *tmp, *pixbuf;
+ GdkPixbuf *pixbuf;
GtkTreePath *path;
GtkTreeIter iter;
- tmp = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (priv->document),
- priv->current_page, THUMBNAIL_WIDTH);
+ pixbuf = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (priv->document),
+ priv->current_page, THUMBNAIL_WIDTH);
-#if 0
- /* Don't add the shadow for now, as it's really slow */
- pixbuf = g_object_ref (tmp);
-#else
- /* Add shadow */
- pixbuf = ev_pixbuf_add_shadow (tmp, 5, 0, 0, 0.5);
-#endif
path = gtk_tree_path_new_from_indices (priv->current_page, -1);
gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->list_store), &iter, path);
gtk_tree_path_free (path);
COLUMN_PIXBUF, pixbuf,
-1);
- g_object_unref (tmp);
g_object_unref (pixbuf);
priv->current_page++;
GtkTreeIter iter;
gchar *page;
- page = g_strdup_printf ("Page %d", i + 1);
+ page = g_strdup_printf ("<i>%d</i>", i + 1);
gtk_list_store_append (sidebar_thumbnails->priv->list_store,
&iter);
gtk_list_store_set (sidebar_thumbnails->priv->list_store,