From 809ca307a8b35886451648e3ae7d794a2a20c63e Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 22 Dec 2004 17:20:51 +0000 Subject: Add pixbuf backend. 2004-12-22 Anders Carlsson * Makefile.am: * configure.ac: * pixbuf/Makefile.am: * pixbuf/pixbuf-document.c: (G_DEFINE_TYPE_WITH_CODE), (pixbuf_document_load), (pixbuf_document_get_n_pages), (pixbuf_document_set_page), (pixbuf_document_get_page), (pixbuf_document_set_target), (pixbuf_document_set_scale), (pixbuf_document_set_page_offset), (pixbuf_document_get_page_size), (pixbuf_document_render), (pixbuf_document_begin_find), (pixbuf_document_end_find), (pixbuf_document_finalize), (pixbuf_document_class_init), (pixbuf_document_document_iface_init), (pixbuf_document_init): * pixbuf/pixbuf-document.h: * shell/Makefile.am: * shell/ev-application.c: (ev_application_open): * shell/ev-window.c: (mime_type_supported_by_gdk_pixbuf), (ev_window_open): Add pixbuf backend. --- (limited to 'shell/ev-window.c') diff --git a/shell/ev-window.c b/shell/ev-window.c index b23a1a6..19a0c52 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -36,6 +36,7 @@ #include "eggfindbar.h" #include "pdf-document.h" +#include "pixbuf-document.h" #include "gtkgs.h" #include @@ -205,6 +206,44 @@ unable_to_load (EvWindow *ev_window, gtk_widget_destroy (dialog); } +/* Would be nice to have this in gdk-pixbuf */ +static gboolean +mime_type_supported_by_gdk_pixbuf (const gchar *mime_type) +{ + GSList *formats, *list; + gboolean retval = FALSE; + + formats = gdk_pixbuf_get_formats (); + + list = formats; + while (list) { + GdkPixbufFormat *format = list->data; + int i; + gchar **mime_types; + + if (gdk_pixbuf_format_is_disabled (format)) + continue; + + mime_types = gdk_pixbuf_format_get_mime_types (format); + + for (i = 0; mime_types[i] != NULL; i++) { + if (strcmp (mime_types[i], mime_type) == 0) { + retval = TRUE; + break; + } + } + + if (retval) + break; + + list = list->next; + } + + g_slist_free (formats); + + return retval; +} + void ev_window_open (EvWindow *ev_window, const char *uri) { @@ -217,7 +256,9 @@ ev_window_open (EvWindow *ev_window, const char *uri) document = g_object_new (PDF_TYPE_DOCUMENT, NULL); else if (!strcmp (mime_type, "application/postscript")) document = g_object_new (GTK_GS_TYPE, NULL); - + else if (mime_type_supported_by_gdk_pixbuf (mime_type)) + document = g_object_new (PIXBUF_TYPE_DOCUMENT, NULL); + if (document) { GError *error = NULL; -- cgit v0.9.1