Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/thumbnailer
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2005-04-18 20:37:04 (GMT)
committer David Malcolm <dave_malcolm@src.gnome.org>2005-04-18 20:37:04 (GMT)
commitf332d42bc834d6a7b0ec58bb8e073e63bc619f63 (patch)
treecccfc8a309b52f379be170146673cbfa5fd5b678 /thumbnailer
parent594edf9b1277d5ec88892c2ea02c2bdc2f2e8b0e (diff)
New files, handling the mapping from mimetypes to backends
2005-04-18 David Malcolm <dmalcolm@redhat.com> * shell/ev-document-types.h: * shell/ev-document-types.c: New files, handling the mapping from mimetypes to backends * shell/ev-window.c: * thumbnailer/evince-thumbnailer.c: Use the ev-document-types code * shell/Makefile.am: Added new convenience library libevbackendfactory_la, containing the new mimetype->backend logic; moved the backends into it. * thumbnailer/Makefile.am: Make the thumbnailer link with the libevbackend.la convenience library, rather than having a duplicate of the backend logic here.
Diffstat (limited to 'thumbnailer')
-rw-r--r--thumbnailer/Makefile.am8
-rw-r--r--thumbnailer/evince-thumbnailer.c65
2 files changed, 44 insertions, 29 deletions
diff --git a/thumbnailer/Makefile.am b/thumbnailer/Makefile.am
index c74910e..81575eb 100644
--- a/thumbnailer/Makefile.am
+++ b/thumbnailer/Makefile.am
@@ -7,6 +7,7 @@ INCLUDES= \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/pdf \
-I$(top_srcdir)/backend \
+ -I$(top_srcdir)/shell \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
-DGNOMEICONDIR=\""$(datadir)/pixmaps"\" \
$(THUMBNAILER_CFLAGS) \
@@ -19,11 +20,10 @@ evince_thumbnailer_SOURCES= \
evince-thumbnailer.c
$(NULL)
-evince_thumbnailer_LDADD= \
- $(THUMBNAILER_LIBS) \
+evince_thumbnailer_LDADD= \
+ $(THUMBNAILER_LIBS) \
$(top_builddir)/lib/libev.la \
- $(top_builddir)/pdf/libpdfdocument.la \
- $(top_builddir)/backend/libevbackend.la \
+ $(top_builddir)/shell/libevbackendfactory.la \
$(NULL)
pixmapdir = $(pkgdatadir)
diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c
index d31e70f..f9930bb 100644
--- a/thumbnailer/evince-thumbnailer.c
+++ b/thumbnailer/evince-thumbnailer.c
@@ -16,14 +16,13 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <ev-poppler.h>
-
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include <ev-document.h>
+#include <ev-document-types.h>
#include <ev-document-thumbnails.h>
#include <string.h>
@@ -37,16 +36,18 @@ evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail, int size)
char *mime_type;
GError *error = NULL;
GdkPixbuf *pixbuf;
+ GType document_type;
mime_type = gnome_vfs_get_mime_type (uri);
if (mime_type == NULL)
return FALSE;
- if (!strcmp (mime_type, "application/pdf"))
- document = g_object_new (PDF_TYPE_DOCUMENT, NULL);
- else
+ document_type = ev_document_type_lookup (mime_type);
+ if (document_type==G_TYPE_INVALID)
return FALSE;
+ document = g_object_new (document_type, NULL);
+
if (!ev_document_load (document, uri, &error)) {
if (error->domain == EV_DOCUMENT_ERROR &&
error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
@@ -56,30 +57,44 @@ evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail, int size)
return FALSE;
}
+ if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
+ return FALSE;
+ }
+
pixbuf = ev_document_thumbnails_get_thumbnail
(EV_DOCUMENT_THUMBNAILS (document), 1, size, FALSE);
if (pixbuf != NULL) {
- GdkPixbuf *pdflogo;
-
- pdflogo = gdk_pixbuf_new_from_file (DATADIR"/pdf-icon.png", NULL);
- if (pdflogo != NULL) {
- int delta_height, delta_width;
-
- delta_width = gdk_pixbuf_get_width (pixbuf) -
- gdk_pixbuf_get_width (pdflogo);
- delta_height = gdk_pixbuf_get_height (pixbuf) -
- gdk_pixbuf_get_height (pdflogo);
-
- gdk_pixbuf_composite (pdflogo, pixbuf,
- delta_width, delta_height,
- gdk_pixbuf_get_width (pdflogo),
- gdk_pixbuf_get_height (pdflogo),
- delta_width, delta_height,
- 1, 1,
- GDK_INTERP_NEAREST, 100);
-
- gdk_pixbuf_unref (pdflogo);
+ const char *overlaid_icon_name = NULL;
+
+ if (strcmp(mime_type,"application/pdf")==0) {
+ overlaid_icon_name = "pdf-icon.png";
+ }
+
+ if (overlaid_icon_name) {
+ GdkPixbuf *overlaid_pixbuf;
+
+ gchar *overlaid_icon_path = g_strdup_printf ("%s/%s", DATADIR, overlaid_icon_name);
+ overlaid_pixbuf = gdk_pixbuf_new_from_file (overlaid_icon_path, NULL);
+ g_free (overlaid_icon_path);
+ if (overlaid_pixbuf != NULL) {
+ int delta_height, delta_width;
+
+ delta_width = gdk_pixbuf_get_width (pixbuf) -
+ gdk_pixbuf_get_width (overlaid_pixbuf);
+ delta_height = gdk_pixbuf_get_height (pixbuf) -
+ gdk_pixbuf_get_height (overlaid_pixbuf);
+
+ gdk_pixbuf_composite (overlaid_pixbuf, pixbuf,
+ delta_width, delta_height,
+ gdk_pixbuf_get_width (overlaid_pixbuf),
+ gdk_pixbuf_get_height (overlaid_pixbuf),
+ delta_width, delta_height,
+ 1, 1,
+ GDK_INTERP_NEAREST, 100);
+
+ gdk_pixbuf_unref (overlaid_pixbuf);
+ }
}
if (gdk_pixbuf_save (pixbuf, thumbnail, "png", NULL, NULL)) {
gdk_pixbuf_unref (pixbuf);