Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>2005-11-14 13:21:13 (GMT)
committer Nickolay V. Shmyrev <nshmyrev@src.gnome.org>2005-11-14 13:21:13 (GMT)
commit30582eef6d8c325d026e7db0301921ddba21dfec (patch)
treebad060c2e88f760d095a403156f615dfd6e7e205
parentae3f65853c9a38b242143559ad15b6df1f5244a6 (diff)
New CBR/CBZ backend for comic books.
2005-11-14 Nickolay V. Shmyrev <nshmyrev@yandex.ru> * Makefile.am: * backend/Makefile.am: * backend/ev-document-factory.c: * backend/ev-document-factory.h: * comics/Makefile.am: * comics/comics-document.c: (G_DEFINE_TYPE_WITH_CODE), (comics_document_load), (comics_document_save), (comics_document_get_n_pages), (comics_document_get_page_size), (get_page_size_area_prepared_cb), (comics_document_render_pixbuf) (render_pixbuf_size_prepared_cb), (comics_document_finalize), (comics_document_class_init), (comics_document_can_get_text), (comics_document_get_info), (comics_document_document_iface_init), (comics_document_init), (get_supported_image_extensions), (comics_document_thumbnails_get_geometry), (comics_document_thumbnails_get_thumbnail), (comics_document_thumbnails_get_dimensions), (comics_document_document_thumbnails_iface_init), (extract_argv): * comics/comics-document.h: * comics/ev-cbr-mime.xml: * configure.ac: * po/POTFILES.in: * shell/ev-application.c: (ev_application_register_service): * shell/ev-document-types.c: (ev_document_types_add_filters): * thumbnailer/Makefile.am: * thumbnailer/evince-thumbnailer-comics.schemas.in: New CBR/CBZ backend for comic books.
-rw-r--r--ChangeLog29
-rw-r--r--Makefile.am4
-rw-r--r--backend/Makefile.am6
-rw-r--r--backend/ev-document-factory.c9
-rw-r--r--backend/ev-document-factory.h3
-rw-r--r--comics/Makefile.am25
-rw-r--r--comics/comics-document.c486
-rw-r--r--comics/comics-document.h38
-rw-r--r--comics/ev-cbr-mime.xml18
-rw-r--r--configure.ac19
-rw-r--r--po/POTFILES.in1
-rw-r--r--shell/ev-application.c3
-rw-r--r--shell/ev-document-types.c10
-rw-r--r--thumbnailer/Makefile.am5
-rw-r--r--thumbnailer/evince-thumbnailer-comics.schemas.in55
15 files changed, 708 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 15f7929..a1d9881 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2005-11-14 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * Makefile.am:
+ * backend/Makefile.am:
+ * backend/ev-document-factory.c:
+ * backend/ev-document-factory.h:
+ * comics/Makefile.am:
+ * comics/comics-document.c: (G_DEFINE_TYPE_WITH_CODE),
+ (comics_document_load), (comics_document_save),
+ (comics_document_get_n_pages), (comics_document_get_page_size),
+ (get_page_size_area_prepared_cb), (comics_document_render_pixbuf) (render_pixbuf_size_prepared_cb), (comics_document_finalize),
+ (comics_document_class_init), (comics_document_can_get_text),
+ (comics_document_get_info), (comics_document_document_iface_init),
+ (comics_document_init), (get_supported_image_extensions),
+ (comics_document_thumbnails_get_geometry),
+ (comics_document_thumbnails_get_thumbnail),
+ (comics_document_thumbnails_get_dimensions),
+ (comics_document_document_thumbnails_iface_init), (extract_argv):
+ * comics/comics-document.h:
+ * comics/ev-cbr-mime.xml:
+ * configure.ac:
+ * po/POTFILES.in:
+ * shell/ev-application.c: (ev_application_register_service):
+ * shell/ev-document-types.c: (ev_document_types_add_filters):
+ * thumbnailer/Makefile.am:
+ * thumbnailer/evince-thumbnailer-comics.schemas.in:
+
+ New CBR/CBZ backend for comic books.
+
2005-11-10 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
* shell/main.c: (load_files_remote):
diff --git a/Makefile.am b/Makefile.am
index d748d98..5acc74f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,6 +20,10 @@ if ENABLE_DVI
SUBDIRS += dvi
endif
+if ENABLE_COMICS
+ SUBDIRS += comics
+endif
+
SUBDIRS += backend
# Library
diff --git a/backend/Makefile.am b/backend/Makefile.am
index 917215a..75509e6 100644
--- a/backend/Makefile.am
+++ b/backend/Makefile.am
@@ -7,6 +7,7 @@ INCLUDES= \
-I$(top_srcdir)/ps \
-I$(top_srcdir)/djvu \
-I$(top_srcdir)/dvi \
+ -I$(top_srcdir)/comics \
$(BACKEND_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED)
@@ -67,6 +68,11 @@ libevbackend_la_LIBADD += \
$(top_builddir)/dvi/libgtkdvi.la
endif
+if ENABLE_COMICS
+libevbackend_la_LIBADD += \
+ $(top_builddir)/comics/libcomicsdocument.la
+endif
+
BUILT_SOURCES= \
ev-backend-marshalers.h \
ev-backend-marshalers.c
diff --git a/backend/ev-document-factory.c b/backend/ev-document-factory.c
index 0f85c7c..7fed2b9 100644
--- a/backend/ev-document-factory.c
+++ b/backend/ev-document-factory.c
@@ -35,6 +35,9 @@
#ifdef ENABLE_DJVU
#include "djvu-document.h"
#endif
+#ifdef ENABLE_COMICS
+#include "comics-document.h"
+#endif
#include <string.h>
@@ -69,6 +72,12 @@ const EvDocumentType document_types[] = {
/* dvi: */
{"application/x-dvi", EV_BACKEND_DVI, dvi_document_get_type},
#endif
+
+#ifdef ENABLE_DVI
+ /* cbr/cbz: */
+ {"application/cbr", EV_BACKEND_COMICS, comics_document_get_type},
+ {"application/cbz", EV_BACKEND_COMICS, comics_document_get_type},
+#endif
};
#ifdef ENABLE_PIXBUF
diff --git a/backend/ev-document-factory.h b/backend/ev-document-factory.h
index 56be46d..f299730 100644
--- a/backend/ev-document-factory.h
+++ b/backend/ev-document-factory.h
@@ -31,7 +31,8 @@ typedef enum {
EV_BACKEND_TIFF,
EV_BACKEND_PIXBUF,
EV_BACKEND_DJVU,
- EV_BACKEND_DVI
+ EV_BACKEND_DVI,
+ EV_BACKEND_COMICS
} EvBackend;
EvDocument *ev_document_factory_get_document (const char *mime_type);
diff --git a/comics/Makefile.am b/comics/Makefile.am
new file mode 100644
index 0000000..22c9290
--- /dev/null
+++ b/comics/Makefile.am
@@ -0,0 +1,25 @@
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/backend \
+ -I$(top_srcdir)/lib \
+ $(LIB_CFLAGS)
+
+noinst_LTLIBRARIES = libcomicsdocument.la
+
+libcomicsdocument_la_SOURCES = \
+ comics-document.c \
+ comics-document.h
+
+# need to respect $XDG_DATA_DIR probably
+xdgmimedir = $(gnome_data)/mime/packages
+xdgmime_DATA = ev-cbr-mime.xml
+
+EXTRA_DIST = $(xdgmime_DATA)
+
+install-data-hook:
+ update-mime-database $(gnome_data)/mime
+
+uninstall-hook:
+ update-mime-database $(gnome_data)/mime
+
+
diff --git a/comics/comics-document.c b/comics/comics-document.c
new file mode 100644
index 0000000..aa7236a
--- /dev/null
+++ b/comics/comics-document.c
@@ -0,0 +1,486 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
+/*
+ * Copyright (C) 2005, Teemu Tervo <teemu.tervo@gmx.net>
+ *
+ * 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.
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <glib/gi18n.h>
+#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <libgnomevfs/gnome-vfs-xfer.h>
+
+#include "comics-document.h"
+#include "ev-document-misc.h"
+#include "ev-document-thumbnails.h"
+
+struct _ComicsDocumentClass
+{
+ GObjectClass parent_class;
+};
+
+struct _ComicsDocument
+{
+ GObject parent_instance;
+
+ gchar *archive;
+ GSList *page_names;
+ int n_pages;
+ char *extract_command;
+};
+
+typedef struct _ComicsDocumentClass ComicsDocumentClass;
+
+static void comics_document_document_iface_init (EvDocumentIface *iface);
+static void comics_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
+
+static GSList* get_supported_image_extensions (void);
+static void get_page_size_area_prepared_cb (GdkPixbufLoader *loader,
+ gpointer data);
+static void render_pixbuf_size_prepared_cb (GdkPixbufLoader *loader,
+ gint width,
+ gint height,
+ gpointer data);
+static char** extract_argv (EvDocument *document,
+ gint page);
+
+
+G_DEFINE_TYPE_WITH_CODE (
+ ComicsDocument, comics_document, G_TYPE_OBJECT,
+ {
+ G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT,
+ comics_document_document_iface_init);
+ G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
+ comics_document_document_thumbnails_iface_init);
+ } );
+
+static gboolean
+comics_document_load (EvDocument *document,
+ const char *uri,
+ GError **error)
+{
+ ComicsDocument *comics_document = COMICS_DOCUMENT (document);
+ GSList *supported_extensions;
+ gchar *list_files_command = NULL, *stdout, *quoted_file, *mime_type;
+ gchar **cbr_files;
+ gboolean success;
+ int i, retval;
+
+ comics_document->archive = g_filename_from_uri (uri, NULL, error);
+ g_return_val_if_fail (comics_document->archive != NULL, FALSE);
+
+ quoted_file = g_shell_quote (comics_document->archive);
+ mime_type = gnome_vfs_get_mime_type (uri);
+
+ /* FIXME, use proper cbr/cbz mime types once they're
+ * included in shared-mime-info */
+ if (!strcmp (mime_type, "application/cbr")) {
+ comics_document->extract_command =
+ g_strdup ("unrar p -c- -ierr");
+ list_files_command =
+ g_strdup_printf ("unrar vb -c- -- %s", quoted_file);
+ } else if (!strcmp (mime_type, "application/cbz")) {
+ comics_document->extract_command =
+ g_strdup ("unzip -p -C");
+ list_files_command =
+ g_strdup_printf ("zipinfo -1 -- %s", quoted_file);
+ }
+
+ g_free (quoted_file);
+
+ /* Get list of files in archive */
+ success = g_spawn_command_line_sync (list_files_command,
+ &stdout, NULL, &retval, error);
+ g_free (list_files_command);
+
+ if (!success) {
+ g_free (mime_type);
+ return FALSE;
+ } else if (retval != 0) {
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ EV_DOCUMENT_ERROR_INVALID,
+ _("File corrupted."));
+ g_free (mime_type);
+ return FALSE;
+ }
+
+ cbr_files = g_strsplit (stdout, "\n", 0);
+ supported_extensions = get_supported_image_extensions ();
+ for (i = 0; cbr_files[i] != NULL; i++) {
+ gchar *suffix = g_strrstr (cbr_files[i], ".");
+ if (!suffix)
+ continue;
+ suffix = g_ascii_strdown (suffix + 1, -1);
+
+ if (g_slist_find_custom (supported_extensions, suffix,
+ (GCompareFunc) strcmp) != NULL) {
+ comics_document->page_names =
+ g_slist_insert_sorted (
+ comics_document->page_names,
+ g_strdup (g_strstrip (cbr_files[i])),
+ (GCompareFunc) strcmp);
+ comics_document->n_pages++;
+ }
+
+ g_free (suffix);
+ }
+
+ g_free (stdout);
+ g_free (mime_type);
+ g_strfreev (cbr_files);
+ g_slist_foreach (supported_extensions, (GFunc) g_free, NULL);
+ g_slist_free (supported_extensions);
+
+ if (comics_document->n_pages == 0) {
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ EV_DOCUMENT_ERROR_INVALID,
+ _("No images found in archive %s"),
+ uri);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+static gboolean
+comics_document_save (EvDocument *document,
+ const char *uri,
+ GError **error)
+{
+ ComicsDocument *comics_document = COMICS_DOCUMENT (document);
+ GnomeVFSURI *source, *target;
+ GnomeVFSResult ret;
+
+ source = gnome_vfs_uri_new (comics_document->archive);
+ target = gnome_vfs_uri_new (uri);
+
+ ret = gnome_vfs_xfer_uri (source, target,
+ GNOME_VFS_XFER_DEFAULT,
+ GNOME_VFS_XFER_ERROR_MODE_ABORT,
+ GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+ NULL, NULL);
+
+ gnome_vfs_uri_unref (source);
+ gnome_vfs_uri_unref (target);
+
+ return ret == GNOME_VFS_OK;
+}
+
+static int
+comics_document_get_n_pages (EvDocument *document)
+{
+ return COMICS_DOCUMENT (document)->n_pages;
+}
+
+static void
+comics_document_get_page_size (EvDocument *document,
+ int page,
+ double *width,
+ double *height)
+{
+ GdkPixbufLoader *loader;
+ char **argv;
+ guchar buf[1024];
+ gboolean success, got_size = FALSE;
+ gint outpipe = -1;
+ GPid child_pid = -1;
+
+ argv = extract_argv (document, page);
+ success = g_spawn_async_with_pipes (NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
+ NULL, NULL,
+ &child_pid,
+ NULL, &outpipe, NULL, NULL);
+ g_strfreev (argv);
+ g_return_if_fail (success == TRUE);
+
+ loader = gdk_pixbuf_loader_new ();
+ g_signal_connect (loader, "area-prepared",
+ G_CALLBACK (get_page_size_area_prepared_cb),
+ &got_size);
+
+ while (outpipe >= 0) {
+ gssize bytes = read (outpipe, buf, 1024);
+
+ if (bytes > 0)
+ gdk_pixbuf_loader_write (loader, buf, bytes, NULL);
+ if (bytes <= 0 || got_size) {
+ close (outpipe);
+ outpipe = -1;
+ gdk_pixbuf_loader_close (loader, NULL);
+ }
+ }
+
+ if (gdk_pixbuf_loader_get_pixbuf (loader)) {
+ GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+ if (width)
+ *width = gdk_pixbuf_get_width (pixbuf);
+ if (height)
+ *height = gdk_pixbuf_get_height (pixbuf);
+ }
+
+ g_spawn_close_pid (child_pid);
+ g_object_unref (loader);
+}
+
+static void
+get_page_size_area_prepared_cb (GdkPixbufLoader *loader,
+ gpointer data)
+{
+ gboolean *got_size = data;
+ *got_size = TRUE;
+}
+
+static GdkPixbuf *
+comics_document_render_pixbuf (EvDocument *document,
+ EvRenderContext *rc)
+{
+ GdkPixbufLoader *loader;
+ GdkPixbuf *rotated_pixbuf;
+ char **argv;
+ guchar buf[4096];
+ gboolean success;
+ gint outpipe = -1;
+ GPid child_pid = -1;
+
+ argv = extract_argv (document, rc->page);
+ success = g_spawn_async_with_pipes (NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH
+ | G_SPAWN_STDERR_TO_DEV_NULL,
+ NULL, NULL,
+ &child_pid,
+ NULL, &outpipe, NULL, NULL);
+ g_strfreev (argv);
+ g_return_val_if_fail (success == TRUE, NULL);
+
+ loader = gdk_pixbuf_loader_new ();
+ g_signal_connect (loader, "size-prepared",
+ G_CALLBACK (render_pixbuf_size_prepared_cb), &rc->scale);
+
+ while (outpipe >= 0) {
+ gssize bytes = read (outpipe, buf, 4096);
+
+ if (bytes > 0) {
+ gdk_pixbuf_loader_write (loader, buf, bytes, NULL);
+ } else if (bytes <= 0) {
+ close (outpipe);
+ gdk_pixbuf_loader_close (loader, NULL);
+ outpipe = -1;
+ }
+ }
+
+ rotated_pixbuf = gdk_pixbuf_rotate_simple (gdk_pixbuf_loader_get_pixbuf (loader),
+ 360 - rc->rotation);
+ g_spawn_close_pid (child_pid);
+ g_object_unref (loader);
+ return rotated_pixbuf;
+}
+
+static void
+render_pixbuf_size_prepared_cb (GdkPixbufLoader *loader,
+ gint width,
+ gint height,
+ gpointer data)
+{
+ double *scale = data;
+ int w = width * (*scale);
+ int h = height * (*scale);
+
+ gdk_pixbuf_loader_set_size (loader, w, h);
+}
+
+static void
+comics_document_finalize (GObject *object)
+{
+ ComicsDocument *comics_document = COMICS_DOCUMENT (object);
+
+ if (comics_document->archive)
+ g_free (comics_document->archive);
+
+ if (comics_document->page_names) {
+ g_slist_foreach (comics_document->page_names,
+ (GFunc) g_free, NULL);
+ g_slist_free (comics_document->page_names);
+ }
+
+ if (comics_document->extract_command)
+ g_free (comics_document->extract_command);
+
+ G_OBJECT_CLASS (comics_document_parent_class)->finalize (object);
+}
+
+static void
+comics_document_class_init (ComicsDocumentClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = comics_document_finalize;
+}
+
+static gboolean
+comics_document_can_get_text (EvDocument *document)
+{
+ return FALSE;
+}
+
+static EvDocumentInfo *
+comics_document_get_info (EvDocument *document)
+{
+ EvDocumentInfo *info;
+ info = g_new0 (EvDocumentInfo, 1);
+ return info;
+}
+
+static void
+comics_document_document_iface_init (EvDocumentIface *iface)
+{
+ iface->load = comics_document_load;
+ iface->save = comics_document_save;
+ iface->can_get_text = comics_document_can_get_text;
+ iface->get_n_pages = comics_document_get_n_pages;
+ iface->get_page_size = comics_document_get_page_size;
+ iface->render_pixbuf = comics_document_render_pixbuf;
+ iface->get_info = comics_document_get_info;
+}
+
+static void
+comics_document_init (ComicsDocument *comics_document)
+{
+ comics_document->archive = NULL;
+ comics_document->page_names = NULL;
+ comics_document->extract_command = NULL;
+ comics_document->n_pages = 0;
+}
+
+/* Returns a list of file extensions supported by gdk-pixbuf */
+static GSList*
+get_supported_image_extensions()
+{
+ GSList *extensions = NULL;
+ GSList *formats = gdk_pixbuf_get_formats ();
+ GSList *l;
+
+ for (l = formats; l != NULL; l = l->next) {
+ int i;
+ gchar **ext = gdk_pixbuf_format_get_extensions (l->data);
+
+ for (i = 0; ext[i] != NULL; i++) {
+ extensions = g_slist_append (extensions,
+ g_strdup (ext[i]));
+ }
+
+ g_strfreev (ext);
+ }
+
+ g_slist_free (formats);
+ return extensions;
+}
+
+static void
+comics_document_thumbnails_get_geometry (EvDocumentThumbnails *document,
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height,
+ gdouble *scale_factor)
+{
+ gdouble orig_width, orig_height, scale;
+
+ comics_document_get_page_size (EV_DOCUMENT (document), page,
+ &orig_width, &orig_height);
+ scale = suggested_width / orig_width;
+
+ if (width)
+ *width = suggested_width;
+ if (height)
+ *height = orig_height * scale;
+ if (scale_factor)
+ *scale_factor = scale;
+}
+
+static GdkPixbuf *
+comics_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
+ gint page,
+ gint rotation,
+ gint size,
+ gboolean border)
+{
+ GdkPixbuf *thumbnail, *framed;
+ gint thumb_width, thumb_height;
+ gdouble scale;
+ EvRenderContext *rc;
+
+ comics_document_thumbnails_get_geometry (document, page, size,
+ &thumb_width, &thumb_height,
+ &scale);
+
+ rc = ev_render_context_new (rotation, page, scale);
+ thumbnail = comics_document_render_pixbuf (EV_DOCUMENT (document),
+ rc);
+ g_object_unref (G_OBJECT (rc));
+
+ if (border) {
+ GdkPixbuf *tmp_pixbuf = thumbnail;
+ thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
+ g_object_unref (tmp_pixbuf);
+ }
+
+ return thumbnail;
+}
+
+static void
+comics_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
+ gint page,
+ gint suggested_width,
+ gint *width,
+ gint *height)
+{
+ comics_document_thumbnails_get_geometry (document, page,
+ suggested_width,
+ width, height, NULL);
+}
+
+static void
+comics_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface)
+{
+ iface->get_thumbnail = comics_document_thumbnails_get_thumbnail;
+ iface->get_dimensions = comics_document_thumbnails_get_dimensions;
+}
+
+static char**
+extract_argv (EvDocument *document, gint page)
+{
+ ComicsDocument *comics_document = COMICS_DOCUMENT (document);
+ char **argv;
+ char *command_line, *quoted_archive, *quoted_filename;
+
+ quoted_archive = g_shell_quote (comics_document->archive);
+ quoted_filename = g_shell_quote (
+ g_slist_nth_data (comics_document->page_names, page));
+
+ command_line = g_strdup_printf ("%s -- %s %s",
+ comics_document->extract_command,
+ quoted_archive,
+ quoted_filename);
+ g_shell_parse_argv (command_line, NULL, &argv, NULL);
+
+ g_free (command_line);
+ g_free (quoted_archive);
+ g_free (quoted_filename);
+ return argv;
+}
diff --git a/comics/comics-document.h b/comics/comics-document.h
new file mode 100644
index 0000000..cd5b17b
--- /dev/null
+++ b/comics/comics-document.h
@@ -0,0 +1,38 @@
+/* comics-document.h: Implementation of EvDocument for comic book archives
+ * Copyright (C) 2005, Teemu Tervo <teemu.tervo@gmx.net>
+ *
+ * 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.
+ */
+
+#ifndef __COMICS_DOCUMENT_H__
+#define __COMICS_DOCUMENT_H__
+
+#include "ev-document.h"
+
+G_BEGIN_DECLS
+
+#define COMICS_TYPE_DOCUMENT (comics_document_get_type ())
+#define COMICS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COMICS_TYPE_DOCUMENT, ComicsDocument))
+#define COMICS_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COMICS_TYPE_DOCUMENT))
+
+typedef struct _ComicsDocument ComicsDocument;
+
+ComicsDocument *comics_document_new (void);
+
+GType comics_document_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __COMICS_DOCUMENT_H__ */
diff --git a/comics/ev-cbr-mime.xml b/comics/ev-cbr-mime.xml
new file mode 100644
index 0000000..8b1a54a
--- /dev/null
+++ b/comics/ev-cbr-mime.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/cbr">
+ <comment>CBR document</comment>
+ <magic priority="50">
+ <match value="Rar!" type="string" offset="0"/>
+ </magic>
+ <glob pattern="*.cbr"/>
+ </mime-type>
+ <mime-type type="application/cbz">
+ <comment>CBZ document</comment>
+ <magic priority="50">
+ <match value="PK\003\004" type="string" offset="0"/>
+ </magic>
+ <glob pattern="*.cbz"/>
+ </mime-type>
+</mime-info>
+
diff --git a/configure.ac b/configure.ac
index 375778f..e72c105 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,7 +47,7 @@ POPPLER_REQUIRED=0.4.1
DBUS_GLIB_REQUIRED=0.33
GTK_REQUIRED=2.6.0
LIBGNOMEUI_REQUIRED=2.6.0
-KEYRING_REQUIRED=0.4.2
+KEYRING_REQUIRED=0.4.0
PKG_CHECK_MODULES(LIB, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED)
PKG_CHECK_MODULES(BACKEND, gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0)
@@ -264,7 +264,18 @@ if test "x$enable_pixbuf" = "xyes"; then
fi
AM_CONDITIONAL(ENABLE_PIXBUF, test x$enable_pixbuf = xyes)
-dnl ================== End of dvi checks ===================================================
+dnl ================== End of pixbuf checks ===================================================
+
+dnl ================== comic book checks ===================================================
+
+AC_ARG_ENABLE(comics,
+ [AC_HELP_STRING([--enable-comics], [Compile with support for comic book archives])],enable_comics=yes,enable_comics=no)
+if test "x$enable_comics" = "xyes"; then
+ AC_DEFINE([ENABLE_COMICS], [1], [Enable support for comics.])
+fi
+AM_CONDITIONAL(ENABLE_COMICS, test x$enable_comics = xyes)
+
+dnl ================== End of comic book checks ============================================
dnl =================== Mime types list ====================================================
@@ -279,6 +290,9 @@ fi
if test "x$enable_tiff" = "xyes"; then
EVINCE_MIME_TYPES="$EVINCE_MIME_TYPES;image/tiff"
fi
+if test "x$enable_comics" = "xyes"; then
+ EVINCE_MIME_TYPES="$EVINCE_MIME_TYPES;application/cbr;application/cbz"
+fi
AC_SUBST(EVINCE_MIME_TYPES)
AC_CONFIG_FILES([
@@ -297,6 +311,7 @@ ps/Makefile
djvu/Makefile
dvi/Makefile
dvi/mdvi-lib/Makefile
+comics/Makefile
po/Makefile.in
backend/Makefile
properties/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0403b31..c236cb3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,7 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
+comics/comics-document.c
cut-n-paste/toolbar-editor/egg-editable-toolbar.c
cut-n-paste/toolbar-editor/egg-toolbar-editor.c
cut-n-paste/zoom-control/ephy-zoom.h
diff --git a/shell/ev-application.c b/shell/ev-application.c
index eed7be8..1b64c3d 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -91,6 +91,9 @@ ev_application_register_service (EvApplication *application)
dbus_g_object_type_install_info (EV_TYPE_APPLICATION,
&dbus_glib_ev_application_object_info);
#endif
+#ifdef ENABLE_COMICS
+ GtkFileFilter *comics_filter;
+#endif
dbus_g_connection_register_g_object (connection,
"/org/gnome/evince/Evince",
diff --git a/shell/ev-document-types.c b/shell/ev-document-types.c
index f1bf9c9..ea729bf 100644
--- a/shell/ev-document-types.c
+++ b/shell/ev-document-types.c
@@ -181,6 +181,16 @@ ev_document_types_add_filters (GtkWidget *chooser, EvDocument *document)
}
#endif
+#ifdef ENABLE_COMICS
+ if (document == NULL || backend == EV_BACKEND_COMICS) {
+ default_filter = filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Comics Books"));
+ mime_types = ev_document_factory_get_mime_types (EV_BACKEND_COMICS);
+ file_filter_add_mime_list_and_free (filter, mime_types);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
+ }
+#endif
+
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All Files"));
gtk_file_filter_add_pattern (filter, "*");
diff --git a/thumbnailer/Makefile.am b/thumbnailer/Makefile.am
index 3512aa7..6bacca5 100644
--- a/thumbnailer/Makefile.am
+++ b/thumbnailer/Makefile.am
@@ -22,6 +22,7 @@ evince_thumbnailer_LDADD= \
schema_files = \
evince-thumbnailer-dvi.schemas.in \
evince-thumbnailer-djvu.schemas.in \
+ evince-thumbnailer-comics.schemas.in \
evince-thumbnailer.schemas.in
schema_DATA = evince-thumbnailer.schemas
@@ -34,6 +35,10 @@ if ENABLE_DVI
schema_DATA += evince-thumbnailer-dvi.schemas
endif
+if ENABLE_COMICS
+schema_DATA += evince-thumbnailer-comics.schemas
+endif
+
schemadir = $(GCONF_SCHEMA_FILE_DIR)
install-data-local:
diff --git a/thumbnailer/evince-thumbnailer-comics.schemas.in b/thumbnailer/evince-thumbnailer-comics.schemas.in
new file mode 100644
index 0000000..f9a4e0d
--- /dev/null
+++ b/thumbnailer/evince-thumbnailer-comics.schemas.in
@@ -0,0 +1,55 @@
+<gconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/desktop/gnome/thumbnailers/application@cbz/enable</key>
+ <applyto>/desktop/gnome/thumbnailers/application@cbz/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/gnome/thumbnailers/application@cbz/command</key>
+ <applyto>/desktop/gnome/thumbnailers/application@cbz/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/desktop/gnome/thumbnailers/application@cbr/enable</key>
+ <applyto>/desktop/gnome/thumbnailers/application@cbz/enable</applyto>
+ <owner>evince</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/desktop/gnome/thumbnailers/application@cbr/command</key>
+ <applyto>/desktop/gnome/thumbnailers/application@cbz/command</applyto>
+ <owner>evince</owner>
+ <type>string</type>
+ <default>evince-thumbnailer -s %s %u %o</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</gconfschemafile>