Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2005-01-05 07:35:14 (GMT)
committer Jonathan Blandford <jrb@src.gnome.org>2005-01-05 07:35:14 (GMT)
commit0e58d20fc6c22fc95b8236d3d53079c062a0041d (patch)
treed8a4592298ca1ec061e310720c85eebb497c7dce
parent2b344d828d68b28027426df8ce71e4d034a0ebba (diff)
New misc file to do simple drop shadows.
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..
-rw-r--r--ChangeLog8
-rw-r--r--backend/Makefile.am2
-rw-r--r--backend/ev-document-misc.c53
-rw-r--r--backend/ev-document-misc.h37
-rw-r--r--pdf/xpdf/pdf-document.cc45
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/ev-sidebar-thumbnails.c30
7 files changed, 125 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 7283859..46f7334 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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
diff --git a/backend/Makefile.am b/backend/Makefile.am
index 1e77a35..e2c3245 100644
--- a/backend/Makefile.am
+++ b/backend/Makefile.am
@@ -21,6 +21,8 @@ libevbackend_la_SOURCES= \
ev-document-find.h \
ev-ps-exporter.c \
ev-ps-exporter.h \
+ ev-document-misc.h \
+ ev-document-misc.c \
$(NULL)
BUILT_SOURCES= \
diff --git a/backend/ev-document-misc.c b/backend/ev-document-misc.c
new file mode 100644
index 0000000..ca818b7
--- /dev/null
+++ b/backend/ev-document-misc.c
@@ -0,0 +1,53 @@
+
+#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;
+}
diff --git a/backend/ev-document-misc.h b/backend/ev-document-misc.h
new file mode 100644
index 0000000..1fae363
--- /dev/null
+++ b/backend/ev-document-misc.h
@@ -0,0 +1,37 @@
+/* -*- 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 */
diff --git a/pdf/xpdf/pdf-document.cc b/pdf/xpdf/pdf-document.cc
index 4abe9ff..76229db 100644
--- a/pdf/xpdf/pdf-document.cc
+++ b/pdf/xpdf/pdf-document.cc
@@ -25,6 +25,7 @@
#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"
@@ -1023,8 +1024,6 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document,
GDKSplashOutputDev *output;
GdkPixbuf *pixbuf;
GdkPixbuf *shadow;
- gint rowstride;
- guchar *data;
pixmap = gdk_pixmap_new (pdf_document->target,
width, height, -1);
@@ -1050,31 +1049,9 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document,
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;
}
@@ -1089,11 +1066,17 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
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 (),
@@ -1107,7 +1090,6 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
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,
@@ -1116,24 +1098,19 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails
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;
diff --git a/shell/Makefile.am b/shell/Makefile.am
index b528da9..87ef0f1 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -41,8 +41,6 @@ evince_SOURCES= \
ev-sidebar-thumbnails.h \
ev-stock-icons.c \
ev-stock-icons.h \
- ev-utils.c \
- ev-utils.h \
main.c \
$(NULL)
diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c
index a80f24e..4154be3 100644
--- a/shell/ev-sidebar-thumbnails.c
+++ b/shell/ev-sidebar-thumbnails.c
@@ -33,7 +33,7 @@
#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
@@ -96,6 +96,7 @@ ev_sidebar_thumbnails_init (EvSidebarThumbnails *ev_sidebar_thumbnails)
{
GtkWidget *swindow;
EvSidebarThumbnailsPrivate *priv;
+ GtkCellRenderer *renderer;
priv = ev_sidebar_thumbnails->priv = EV_SIDEBAR_THUMBNAILS_GET_PRIVATE (ev_sidebar_thumbnails);
@@ -103,12 +104,17 @@ ev_sidebar_thumbnails_init (EvSidebarThumbnails *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);
@@ -138,20 +144,13 @@ static gboolean
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);
@@ -160,7 +159,6 @@ do_one_iteration (EvSidebarThumbnails *ev_sidebar_thumbnails)
COLUMN_PIXBUF, pixbuf,
-1);
- g_object_unref (tmp);
g_object_unref (pixbuf);
priv->current_page++;
@@ -229,7 +227,7 @@ ev_sidebar_thumbnails_set_document (EvSidebarThumbnails *sidebar_thumbnails,
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,