From 5b49da80cac07713c01828d33be33e23d2895b98 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sat, 4 Dec 2010 14:28:13 +0100 Subject: [PATCH] backend: Remove pixbuf backend Evince is a document viewer, not an image viewer. Eog does the latter job much better than evince ever could. Bug #630307. --- backend/Makefile.am | 4 - backend/pixbuf/Makefile.am | 30 --- backend/pixbuf/pixbuf-document.c | 174 ------------------ backend/pixbuf/pixbuf-document.h | 38 ---- .../pixbuf/pixbufdocument.evince-backend.in | 4 - configure.ac | 21 --- libdocument/ev-document-factory.c | 78 -------- 7 files changed, 349 deletions(-) delete mode 100644 backend/pixbuf/Makefile.am delete mode 100644 backend/pixbuf/pixbuf-document.c delete mode 100644 backend/pixbuf/pixbuf-document.h delete mode 100644 backend/pixbuf/pixbufdocument.evince-backend.in diff --git a/backend/Makefile.am b/backend/Makefile.am index 85f4ff15..da9dc8c6 100644 --- a/backend/Makefile.am +++ b/backend/Makefile.am @@ -10,10 +10,6 @@ if ENABLE_PS SUBDIRS += ps endif -if ENABLE_PIXBUF -SUBDIRS += pixbuf -endif - if ENABLE_DJVU SUBDIRS += djvu endif diff --git a/backend/pixbuf/Makefile.am b/backend/pixbuf/Makefile.am deleted file mode 100644 index cbcf62b2..00000000 --- a/backend/pixbuf/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/libdocument \ - -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ - -DEVINCE_COMPILATION \ - $(BACKEND_CFLAGS) \ - $(WARN_CFLAGS) \ - $(DISABLE_DEPRECATED) - -backend_LTLIBRARIES = libpixbufdocument.la - -libpixbufdocument_la_SOURCES = \ - pixbuf-document.c \ - pixbuf-document.h - -libpixbufdocument_la_LDFLAGS = $(BACKEND_LIBTOOL_FLAGS) -libpixbufdocument_la_LIBADD = \ - $(top_builddir)/libdocument/libevdocument3.la \ - $(BACKEND_LIBS) - -backend_in_files = pixbufdocument.evince-backend.in -backend_DATA = $(backend_in_files:.evince-backend.in=.evince-backend) - -EXTRA_DIST = $(backend_in_files) - -CLEANFILES = $(backend_DATA) - -@EV_INTLTOOL_EVINCE_BACKEND_RULE@ - --include $(top_srcdir)/git.mk diff --git a/backend/pixbuf/pixbuf-document.c b/backend/pixbuf/pixbuf-document.c deleted file mode 100644 index ae7b4376..00000000 --- a/backend/pixbuf/pixbuf-document.c +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ -/* - * Copyright (C) 2004, Anders Carlsson - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include - -#include "pixbuf-document.h" -#include "ev-document-misc.h" -#include "ev-file-helpers.h" - -struct _PixbufDocumentClass -{ - EvDocumentClass parent_class; -}; - -struct _PixbufDocument -{ - EvDocument parent_instance; - - GdkPixbuf *pixbuf; - - gchar *uri; -}; - -typedef struct _PixbufDocumentClass PixbufDocumentClass; - -EV_BACKEND_REGISTER (PixbufDocument, pixbuf_document) - -static gboolean -pixbuf_document_load (EvDocument *document, - const char *uri, - GError **error) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - - gchar *filename; - GdkPixbuf *pixbuf; - - /* FIXME: We could actually load uris */ - filename = g_filename_from_uri (uri, NULL, error); - if (!filename) - return FALSE; - - pixbuf = gdk_pixbuf_new_from_file (filename, error); - - if (!pixbuf) - return FALSE; - - pixbuf_document->pixbuf = pixbuf; - g_free (pixbuf_document->uri); - pixbuf_document->uri = g_strdup (uri); - - return TRUE; -} - -static gboolean -pixbuf_document_save (EvDocument *document, - const char *uri, - GError **error) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - - return ev_xfer_uri_simple (pixbuf_document->uri, uri, error); -} - -static int -pixbuf_document_get_n_pages (EvDocument *document) -{ - return 1; -} - -static void -pixbuf_document_get_page_size (EvDocument *document, - EvPage *page, - double *width, - double *height) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - - *width = gdk_pixbuf_get_width (pixbuf_document->pixbuf); - *height = gdk_pixbuf_get_height (pixbuf_document->pixbuf); -} - -static cairo_surface_t * -pixbuf_document_render (EvDocument *document, - EvRenderContext *rc) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - GdkPixbuf *scaled_pixbuf, *rotated_pixbuf; - cairo_surface_t *surface; - - scaled_pixbuf = gdk_pixbuf_scale_simple ( - pixbuf_document->pixbuf, - (gdk_pixbuf_get_width (pixbuf_document->pixbuf) * rc->scale) + 0.5, - (gdk_pixbuf_get_height (pixbuf_document->pixbuf) * rc->scale) + 0.5, - GDK_INTERP_BILINEAR); - - rotated_pixbuf = gdk_pixbuf_rotate_simple (scaled_pixbuf, 360 - rc->rotation); - g_object_unref (scaled_pixbuf); - - surface = ev_document_misc_surface_from_pixbuf (rotated_pixbuf); - g_object_unref (rotated_pixbuf); - - return surface; -} - -static GdkPixbuf * -pixbuf_document_get_thumbnail (EvDocument *document, - EvRenderContext *rc) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document); - GdkPixbuf *pixbuf, *rotated_pixbuf; - gint width, height; - - width = (gint) (gdk_pixbuf_get_width (pixbuf_document->pixbuf) * rc->scale); - height = (gint) (gdk_pixbuf_get_height (pixbuf_document->pixbuf) * rc->scale); - - pixbuf = gdk_pixbuf_scale_simple (pixbuf_document->pixbuf, - width, height, - GDK_INTERP_BILINEAR); - - rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation); - g_object_unref (pixbuf); - - return rotated_pixbuf; -} - -static void -pixbuf_document_finalize (GObject *object) -{ - PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (object); - - g_object_unref (pixbuf_document->pixbuf); - g_free (pixbuf_document->uri); - - G_OBJECT_CLASS (pixbuf_document_parent_class)->finalize (object); -} - -static void -pixbuf_document_class_init (PixbufDocumentClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass); - - gobject_class->finalize = pixbuf_document_finalize; - - ev_document_class->load = pixbuf_document_load; - ev_document_class->save = pixbuf_document_save; - ev_document_class->get_n_pages = pixbuf_document_get_n_pages; - ev_document_class->get_page_size = pixbuf_document_get_page_size; - ev_document_class->render = pixbuf_document_render; - ev_document_class->get_thumbnail = pixbuf_document_get_thumbnail; -} - -static void -pixbuf_document_init (PixbufDocument *pixbuf_document) -{ -} diff --git a/backend/pixbuf/pixbuf-document.h b/backend/pixbuf/pixbuf-document.h deleted file mode 100644 index 6f34372d..00000000 --- a/backend/pixbuf/pixbuf-document.h +++ /dev/null @@ -1,38 +0,0 @@ -/* pdfdocument.h: Implementation of EvDocument for pixbufs - * Copyright (C) 2004, Anders Carlsson - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __PIXBUF_DOCUMENT_H__ -#define __PIXBUF_DOCUMENT_H__ - -#include "ev-document.h" - -G_BEGIN_DECLS - -#define PIXBUF_TYPE_DOCUMENT (pixbuf_document_get_type ()) -#define PIXBUF_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIXBUF_TYPE_DOCUMENT, PixbufDocument)) -#define PIXBUF_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIXBUF_TYPE_DOCUMENT)) - -typedef struct _PixbufDocument PixbufDocument; - -GType pixbuf_document_get_type (void) G_GNUC_CONST; - -G_MODULE_EXPORT GType register_evince_backend (GTypeModule *module); - -G_END_DECLS - -#endif /* __PIXBUF_DOCUMENT_H__ */ diff --git a/backend/pixbuf/pixbufdocument.evince-backend.in b/backend/pixbuf/pixbufdocument.evince-backend.in deleted file mode 100644 index 9beb526b..00000000 --- a/backend/pixbuf/pixbufdocument.evince-backend.in +++ /dev/null @@ -1,4 +0,0 @@ -[Evince Backend] -Module=pixbufdocument -_TypeDescription=Images -MimeType=image/*; diff --git a/configure.ac b/configure.ac index 19762092..d0712b28 100644 --- a/configure.ac +++ b/configure.ac @@ -633,22 +633,6 @@ AM_CONDITIONAL(WITH_TYPE1_FONTS, test x$enable_type1_fonts = xyes) dnl ================== End of dvi checks =================================================== -dnl ================== pixbuf checks =================================================== - -AC_ARG_ENABLE(pixbuf, - [AS_HELP_STRING([--enable-pixbuf], - [Compile with support of pixbuf])], - [enable_pixbuf=$enableval], - [enable_pixbuf=no]) - -if test "x$enable_pixbuf" = "xyes"; then - AC_DEFINE([ENABLE_PIXBUF], [1], [Enable pixbuf support.]) -fi - -AM_CONDITIONAL(ENABLE_PIXBUF, test x$enable_pixbuf = xyes) - -dnl ================== End of pixbuf checks =================================================== - dnl ================== comic book checks =================================================== AC_ARG_ENABLE(comics, @@ -708,9 +692,6 @@ fi if test "x$enable_comics" = "xyes"; then EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES}application/x-cbr;application/x-cbz;application/x-cb7;application/x-cbt;" fi -if test "x$enable_pixbuf" = "xyes"; then - EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES}image/*;" -fi if test "x$enable_xps" = "xyes"; then EVINCE_MIME_TYPES="${EVINCE_MIME_TYPES}application/oxps;application/vnd.ms-xpsdocument;" fi @@ -789,7 +770,6 @@ backend/djvu/Makefile backend/dvi/Makefile backend/dvi/mdvi-lib/Makefile backend/pdf/Makefile -backend/pixbuf/Makefile backend/ps/Makefile backend/tiff/Makefile backend/xps/Makefile @@ -873,7 +853,6 @@ Configure summary: TIFF Backend.......: $enable_tiff DJVU Backend.......: $enable_djvu DVI Backend........: $enable_dvi - Pixbuf Backend.....: $enable_pixbuf Comics Backend.....: $enable_comics XPS Backend........: $enable_xps " diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c index 0ace5ec8..2bed3906 100644 --- a/libdocument/ev-document-factory.c +++ b/libdocument/ev-document-factory.c @@ -33,58 +33,6 @@ #include "ev-document-factory.h" #include "ev-file-helpers.h" -#ifdef ENABLE_PIXBUF -static GList* -gdk_pixbuf_mime_type_list () -{ - GSList *formats, *list; - GList *result = NULL; - - formats = gdk_pixbuf_get_formats (); - for (list = formats; list != NULL; list = list->next) { - GdkPixbufFormat *format = list->data; - gchar **mime_types; - - if (gdk_pixbuf_format_is_disabled (format)) - continue; - - mime_types = gdk_pixbuf_format_get_mime_types (format); - result = g_list_prepend (result, mime_types); - } - g_slist_free (formats); - - return result; -} - -/* Would be nice to have this in gdk-pixbuf */ -static gboolean -mime_type_supported_by_gdk_pixbuf (const gchar *mime_type) -{ - GList *mime_types; - GList *list; - gboolean retval = FALSE; - - mime_types = gdk_pixbuf_mime_type_list (); - for (list = mime_types; list; list = list->next) { - gchar **mtypes = (gchar **)list->data; - const gchar *mtype; - gint i = 0; - - while ((mtype = mtypes[i++])) { - if (strcmp (mtype, mime_type) == 0) { - retval = TRUE; - break; - } - } - } - - g_list_foreach (mime_types, (GFunc)g_strfreev, NULL); - g_list_free (mime_types); - - return retval; -} -#endif /* ENABLE_PIXBUF */ - static EvCompressionType get_compression_from_mime_type (const gchar *mime_type) { @@ -149,12 +97,6 @@ get_document_from_uri (const char *uri, } document = ev_backends_manager_get_document (mime_type); - -#ifdef ENABLE_PIXBUF - if (!document && mime_type_supported_by_gdk_pixbuf (mime_type)) - document = ev_backends_manager_get_document ("image/*"); -#endif /* ENABLE_PIXBUF */ - if (document == NULL) { gchar *content_type, *mime_desc = NULL; @@ -304,26 +246,6 @@ file_filter_add_mime_types (EvTypeInfo *info, GtkFileFilter *filter) const gchar *mime_type; gint i = 0; -#ifdef ENABLE_PIXBUF - if (g_ascii_strcasecmp (info->mime_types[0], "image/*") == 0) { - GList *pixbuf_types, *l; - - pixbuf_types = gdk_pixbuf_mime_type_list (); - for (l = pixbuf_types; l; l = g_list_next (l)) { - gchar **mime_types = (gchar **)l->data; - gint j = 0; - - while ((mime_type = mime_types[j++])) - gtk_file_filter_add_mime_type (filter, mime_type); - - g_strfreev (mime_types); - } - g_list_free (pixbuf_types); - - return; - } -#endif /* ENABLE_PIXBUF */ - while ((mime_type = info->mime_types[i++])) gtk_file_filter_add_mime_type (filter, mime_type); } -- 2.43.0