Commit 6b9aeb5d authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

Add image handling support. Fixes bugs #310008 and #325047. Images

2007-01-07  Carlos Garcia Campos  <carlosgc@gnome.org>
	* configure.ac:
	* data/evince-ui.xml:
	* pdf/ev-poppler.cc: (pdf_document_images_get_images),
	(pdf_document_document_images_iface_init):
	* backend/Makefile.am:
	* backend/ev-document-images.[ch]:
	* backend/ev-image.[ch]:
	* lib/ev-file-helpers.[ch]: (ev_tmp_filename):
	* shell/ev-jobs.[ch]: (ev_job_render_new), (ev_job_render_run),
	(ev_job_xfer_run):
	* shell/ev-pixbuf-cache.[ch]: (dispose_cache_job_info),
	(move_one_job), (copy_job_to_job_info), (add_job_if_needed),
	(ev_pixbuf_cache_get_image_mapping):
	* shell/ev-window.c: (view_menu_link_popup), (view_menu_image_popup),
	(view_menu_popup_cb), (ev_window_dispose),
	(image_save_dialog_response_cb), (ev_view_popup_cmd_save_image_as),
	(ev_view_popup_cmd_copy_image):
	* shell/ev-view-private.h:
	* shell/ev-view.c: (ev_view_get_image_at_location),
	(ev_view_do_popup_menu), (ev_view_popup_menu),
	(ev_view_button_press_event), (ev_view_drag_data_get),
	(ev_view_drag_motion), (ev_view_drag_data_received),
	(ev_view_motion_notify_event), (ev_view_button_release_event),
	(ev_view_finalize), (ev_view_class_init):
	Add image handling support. Fixes bugs #310008 and #325047. Images
	selection is not supported yet. 

svn path=/trunk/; revision=2194
parent 560065af
2007-01-07 Carlos Garcia Campos <carlosgc@gnome.org>
* configure.ac:
* data/evince-ui.xml:
* pdf/ev-poppler.cc: (pdf_document_images_get_images),
(pdf_document_document_images_iface_init):
* backend/Makefile.am:
* backend/ev-document-images.[ch]:
* backend/ev-image.[ch]:
* lib/ev-file-helpers.[ch]: (ev_tmp_filename):
* shell/ev-jobs.[ch]: (ev_job_render_new), (ev_job_render_run),
(ev_job_xfer_run):
* shell/ev-pixbuf-cache.[ch]: (dispose_cache_job_info),
(move_one_job), (copy_job_to_job_info), (add_job_if_needed),
(ev_pixbuf_cache_get_image_mapping):
* shell/ev-window.c: (view_menu_link_popup), (view_menu_image_popup),
(view_menu_popup_cb), (ev_window_dispose),
(image_save_dialog_response_cb), (ev_view_popup_cmd_save_image_as),
(ev_view_popup_cmd_copy_image):
* shell/ev-view-private.h:
* shell/ev-view.c: (ev_view_get_image_at_location),
(ev_view_do_popup_menu), (ev_view_popup_menu),
(ev_view_button_press_event), (ev_view_drag_data_get),
(ev_view_drag_motion), (ev_view_drag_data_received),
(ev_view_motion_notify_event), (ev_view_button_release_event),
(ev_view_finalize), (ev_view_class_init):
Add image handling support. Fixes bugs #310008 and #325047. Images
selection is not supported yet.
2007-01-07 Carlos Garcia Campos <carlosgc@gnome.org>
* shell/ev-window.c: (drag_data_received_cb), (ev_window_init):
......
......@@ -28,6 +28,8 @@ libevbackend_la_SOURCES= \
ev-link-action.h \
ev-link-dest.c \
ev-link-dest.h \
ev-image.c \
ev-image.h \
ev-document.c \
ev-document.h \
ev-document-factory.c \
......@@ -38,6 +40,8 @@ libevbackend_la_SOURCES= \
ev-document-fonts.h \
ev-document-links.c \
ev-document-links.h \
ev-document-images.c \
ev-document-images.h \
ev-document-security.c \
ev-document-security.h \
ev-document-find.c \
......
/* ev-document-images.c
* this file is part of evince, a gnome document_links viewer
*
* Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
*
* Evince 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 of the License, or
* (at your option) any later version.
*
* Evince 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 "ev-document-images.h"
GType
ev_document_images_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0)) {
const GTypeInfo our_info = {
sizeof (EvDocumentImagesIface),
NULL,
NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE,
"EvDocumentImages",
&our_info, (GTypeFlags)0);
}
return type;
}
GList *
ev_document_images_get_images (EvDocumentImages *document_images,
gint page)
{
EvDocumentImagesIface *iface = EV_DOCUMENT_IMAGES_GET_IFACE (document_images);
GList *retval;
retval = iface->get_images (document_images, page);
return retval;
}
/* ev-document-images.h
* this file is part of evince, a gnome document viewer
*
* Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
*
* Evince 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 of the License, or
* (at your option) any later version.
*
* Evince 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 EV_DOCUMENT_IMAGES_H
#define EV_DOCUMENT_IMAGES_H
#include <glib-object.h>
#include <glib.h>
#include "ev-document.h"
G_BEGIN_DECLS
#define EV_TYPE_DOCUMENT_IMAGES (ev_document_images_get_type ())
#define EV_DOCUMENT_IMAGES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT_IMAGES, EvDocumentImages))
#define EV_DOCUMENT_IMAGES_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT_IMAGES, EvDocumentImagesIface))
#define EV_IS_DOCUMENT_IMAGES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT_IMAGES))
#define EV_IS_DOCUMENT_IMAGES_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT_IMAGES))
#define EV_DOCUMENT_IMAGES_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT_IMAGES, EvDocumentImagesIface))
typedef struct _EvDocumentImages EvDocumentImages;
typedef struct _EvDocumentImagesIface EvDocumentImagesIface;
struct _EvDocumentImagesIface {
GTypeInterface base_iface;
/* Methods */
GList *(* get_images) (EvDocumentImages *document_images,
gint page);
};
GType ev_document_images_get_type (void) G_GNUC_CONST;
GList *ev_document_images_get_images (EvDocumentImages *document_images,
gint page);
G_END_DECLS
#endif /* EV_DOCUMENT_IMAGES_H */
/* this file is part of evince, a gnome document viewer
*
* Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
*
* Evince 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 of the License, or
* (at your option) any later version.
*
* Evince 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 <glib/gstdio.h>
#include "ev-file-helpers.h"
#include "ev-image.h"
struct _EvImagePrivate {
GdkPixbuf *pixbuf;
gchar *tmp_uri;
};
#define EV_IMAGE_GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_IMAGE, EvImagePrivate))
G_DEFINE_TYPE (EvImage, ev_image, G_TYPE_OBJECT)
static void
ev_image_finalize (GObject *object)
{
EvImage *image = EV_IMAGE (object);
if (image->priv->pixbuf) {
g_object_unref (image->priv->pixbuf);
image->priv->pixbuf = NULL;
}
if (image->priv->tmp_uri) {
g_unlink (image->priv->tmp_uri);
g_free (image->priv->tmp_uri);
image->priv->tmp_uri = NULL;
}
(* G_OBJECT_CLASS (ev_image_parent_class)->finalize) (object);
}
static void
ev_image_class_init (EvImageClass *klass)
{
GObjectClass *g_object_class;
g_object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (g_object_class, sizeof (EvImagePrivate));
g_object_class->finalize = ev_image_finalize;
}
static void
ev_image_init (EvImage *image)
{
image->priv = EV_IMAGE_GET_PRIVATE (image);
}
EvImage *
ev_image_new_from_pixbuf (GdkPixbuf *pixbuf)
{
EvImage *image;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
image = EV_IMAGE (g_object_new (EV_TYPE_IMAGE, NULL));
image->priv->pixbuf = g_object_ref (pixbuf);
return image;
}
GdkPixbuf *
ev_image_get_pixbuf (EvImage *image)
{
g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
g_return_val_if_fail (GDK_IS_PIXBUF (image->priv->pixbuf), NULL);
return image->priv->pixbuf;
}
const gchar *
ev_image_save_tmp (EvImage *image)
{
GError *error = NULL;
g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
g_return_val_if_fail (GDK_IS_PIXBUF (image->priv->pixbuf), NULL);
if (image->priv->tmp_uri)
return image->priv->tmp_uri;
image->priv->tmp_uri = ev_tmp_filename ("image");
gdk_pixbuf_save (image->priv->pixbuf,
image->priv->tmp_uri, "png", &error,
"compression", "3", NULL);
if (!error)
return image->priv->tmp_uri;
/* Erro saving image */
g_warning (error->message);
g_error_free (error);
g_free (image->priv->tmp_uri);
image->priv->tmp_uri = NULL;
return NULL;
}
const gchar *
ev_image_get_tmp_uri (EvImage *image)
{
g_return_val_if_fail (EV_IS_IMAGE (image), NULL);
return image->priv->tmp_uri;
}
/* EvImageMapping */
static void
ev_image_mapping_free_foreach (EvImageMapping *mapping)
{
g_object_unref (mapping->image);
g_free (mapping);
}
void
ev_image_mapping_free (GList *image_mapping)
{
if (!image_mapping)
return;
g_list_foreach (image_mapping, (GFunc) ev_image_mapping_free_foreach, NULL);
g_list_free (image_mapping);
}
EvImage *
ev_image_mapping_find (GList *image_mapping,
gdouble x,
gdouble y)
{
GList *list;
for (list = image_mapping; list; list = list->next) {
EvImageMapping *mapping = list->data;
if ((x >= mapping->x1) &&
(y >= mapping->y1) &&
(x <= mapping->x2) &&
(y <= mapping->y2)) {
return mapping->image;
}
}
return NULL;
}
/* this file is part of evince, a gnome document viewer
*
* Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org>
*
* Evince 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 of the License, or
* (at your option) any later version.
*
* Evince 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 __EV_IMAGE_H__
#define __EV_IMAGE_H__
#include <glib-object.h>
#include <gdk/gdkpixbuf.h>
G_BEGIN_DECLS
typedef struct _EvImage EvImage;
typedef struct _EvImageClass EvImageClass;
typedef struct _EvImagePrivate EvImagePrivate;
#define EV_TYPE_IMAGE (ev_image_get_type())
#define EV_IMAGE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_IMAGE, EvImage))
#define EV_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_IMAGE, EvImageClass))
#define EV_IS_IMAGE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_IMAGE))
#define EV_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_IMAGE))
#define EV_IMAGE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_IMAGE, EvImageClass))
struct _EvImage {
GObject base_instance;
EvImagePrivate *priv;
};
struct _EvImageClass {
GObjectClass base_class;
};
GType ev_image_get_type (void) G_GNUC_CONST;
EvImage *ev_image_new_from_pixbuf (GdkPixbuf *pixbuf);
GdkPixbuf *ev_image_get_pixbuf (EvImage *image);
const gchar *ev_image_save_tmp (EvImage *image);
const gchar *ev_image_get_tmp_uri (EvImage *image);
/* Image Mapping stuff */
typedef struct _EvImageMapping EvImageMapping;
struct _EvImageMapping {
EvImage *image;
gdouble x1;
gdouble y1;
gdouble x2;
gdouble y2;
};
void ev_image_mapping_free (GList *image_mapping);
EvImage *ev_image_mapping_find (GList *image_mapping,
gdouble x,
gdouble y);
G_END_DECLS
#endif /* __EV_IMAGE_H__ */
......@@ -212,6 +212,7 @@ if test "x$enable_pdf" = "xyes"; then
LIBS="$LIBS $FRONTEND_LIBS"
AC_CHECK_FUNCS(poppler_page_render)
AC_CHECK_FUNCS(poppler_page_get_duration)
AC_CHECK_FUNCS(poppler_page_get_image_mapping)
LIBS=$evince_save_LIBS
PKG_CHECK_MODULES(CAIRO_PDF, cairo-pdf, enable_cairo_pdf=yes, enable_cairo_pdf=no)
......
......@@ -73,6 +73,9 @@
<separator/>
<menuitem name="EditCopy" action="EditCopy"/>
<menuitem name="EditSelectAllPopup" action="EditSelectAll"/>
<separator/>
<menuitem name="SaveImageAs" action="SaveImageAs"/>
<menuitem name="CopyImage" action="CopyImage"/>
</popup>
<popup name="AttachmentPopup" action="AttachmentPopupAction">
......
......@@ -113,7 +113,7 @@ ev_file_helpers_shutdown (void)
}
gchar *
ev_tmp_filename (void)
ev_tmp_filename (const gchar *prefix)
{
gchar *basename;
gchar *filename = NULL;
......@@ -122,7 +122,9 @@ ev_tmp_filename (void)
if (filename != NULL)
g_free (filename);
basename = g_strdup_printf ("document-%d", count ++);
basename = g_strdup_printf ("%s-%d",
prefix ? prefix : "document",
count ++);
filename = g_build_filename (ev_tmp_dir (),
basename, NULL);
......
......@@ -33,7 +33,7 @@ void ev_file_helpers_init (void);
void ev_file_helpers_shutdown (void);
gchar* ev_tmp_filename (void);
gchar* ev_tmp_filename (const char *prefix);
gboolean ev_xfer_uri_simple (const char *from,
const char *to,
......
......@@ -35,12 +35,14 @@
#include "ev-document-find.h"
#include "ev-document-misc.h"
#include "ev-document-links.h"
#include "ev-document-images.h"
#include "ev-document-fonts.h"
#include "ev-document-security.h"
#include "ev-document-thumbnails.h"
#include "ev-document-transition.h"
#include "ev-selection.h"
#include "ev-attachment.h"
#include "ev-image.h"
typedef struct {
PdfDocument *document;
......@@ -83,6 +85,7 @@ static void pdf_document_document_iface_init (EvDocumentIface
static void pdf_document_security_iface_init (EvDocumentSecurityIface *iface);
static void pdf_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
static void pdf_document_document_links_iface_init (EvDocumentLinksIface *iface);
static void pdf_document_document_images_iface_init (EvDocumentImagesIface *iface);
static void pdf_document_document_fonts_iface_init (EvDocumentFontsIface *iface);
static void pdf_document_find_iface_init (EvDocumentFindIface *iface);
static void pdf_document_file_exporter_iface_init (EvFileExporterIface *iface);
......@@ -113,6 +116,8 @@ G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT,
pdf_document_document_thumbnails_iface_init);
G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_LINKS,
pdf_document_document_links_iface_init);
G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_IMAGES,
pdf_document_document_images_iface_init);
G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FONTS,
pdf_document_document_fonts_iface_init);
G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FIND,
......@@ -1123,6 +1128,50 @@ pdf_document_document_links_iface_init (EvDocumentLinksIface *iface)
iface->find_link_dest = pdf_document_links_find_link_dest;
}
static GList *
pdf_document_images_get_images (EvDocumentImages *document_images,
gint page)
{
GList *retval = NULL;
#ifdef HAVE_POPPLER_PAGE_GET_IMAGE_MAPPING
PdfDocument *pdf_document;
PopplerPage *poppler_page;
GList *mapping_list;
GList *list;
pdf_document = PDF_DOCUMENT (document_images);
poppler_page = poppler_document_get_page (pdf_document->document, page);
mapping_list = poppler_page_get_image_mapping (poppler_page);
for (list = mapping_list; list; list = list->next) {
PopplerImageMapping *image_mapping;
EvImageMapping *ev_image_mapping;
image_mapping = (PopplerImageMapping *)list->data;
ev_image_mapping = g_new (EvImageMapping, 1);
ev_image_mapping->image = ev_image_new_from_pixbuf (image_mapping->image);
ev_image_mapping->x1 = image_mapping->area.x1;
ev_image_mapping->x2 = image_mapping->area.x2;
ev_image_mapping->y1 = image_mapping->area.y1;
ev_image_mapping->y2 = image_mapping->area.y2;
retval = g_list_prepend (retval, ev_image_mapping);
}
poppler_page_free_image_mapping (mapping_list);
g_object_unref (poppler_page);
#endif /* HAVE_POPPLER_PAGE_GET_IMAGE_MAPPING */
return retval;
}
static void
pdf_document_document_images_iface_init (EvDocumentImagesIface *iface)
{
iface->get_images = pdf_document_images_get_images;
}
static GdkPixbuf *
make_thumbnail_for_size (PdfDocument *pdf_document,
gint page,
......
......@@ -2,6 +2,7 @@
#include "ev-job-queue.h"
#include "ev-document-thumbnails.h"
#include "ev-document-links.h"
#include "ev-document-images.h"
#include "ev-document-factory.h"
#include "ev-file-helpers.h"
#include "ev-document-fonts.h"
......@@ -260,6 +261,7 @@ ev_job_render_new (EvDocument *document,
GdkColor *text,
GdkColor *base,
gboolean include_links,
gboolean include_images,
gboolean include_text,
gboolean include_selection)
{
......@@ -278,6 +280,7 @@ ev_job_render_new (EvDocument *document,
job->text = *text;
job->base = *base;
job->include_links = include_links;
job->include_images = include_images;
job->include_text = include_text;
job->include_selection = include_selection;
......@@ -323,6 +326,10 @@ ev_job_render_run (EvJobRender *job)
job->link_mapping =
ev_document_links_get_links (EV_DOCUMENT_LINKS (EV_JOB (job)->document),
job->rc->page);
if (job->include_images && EV_IS_DOCUMENT_IMAGES (EV_JOB (job)->document))
job->image_mapping =
ev_document_images_get_images (EV_DOCUMENT_IMAGES (EV_JOB (job)->document),
job->rc->page);
if (job->include_text && EV_IS_SELECTION (EV_JOB (job)->document))
job->text_mapping =
ev_selection_get_selection_map (EV_SELECTION (EV_JOB (job)->document),
......@@ -507,7 +514,7 @@ ev_job_xfer_run (EvJobXfer *job)
/* We'd like to keep extension of source uri since
* it helps to resolve some mime types, say cbz */
tmp_name = ev_tmp_filename ();
tmp_name = ev_tmp_filename (NULL);
base_name = gnome_vfs_uri_extract_short_name (source_uri);
job->local_uri = g_strconcat ("file:", tmp_name, "-", base_name, NULL);
g_free (base_name);
......
......@@ -125,6 +125,7 @@ struct _EvJobRender
GList *link_mapping;
GdkRegion *text_mapping;
GList *image_mapping;
GdkPixbuf *selection;
GdkRegion *selection_region;
......@@ -135,6 +136,7 @@ struct _EvJobRender
gint include_links : 1;
gint include_text : 1;
gint include_selection : 1;
gint include_images : 1;
};
struct _EvJobRenderClass
......@@ -224,6 +226,7 @@ EvJob *ev_job_render_new (EvDocument *document,
GdkColor *text,
GdkColor *base,
gboolean include_links,
gboolean include_images,
gboolean include_text,
gboolean include_selection);
void ev_job_render_run (EvJobRender *thumbnail);
......
......@@ -2,6 +2,8 @@
#include "ev-job-queue.h"
#include "ev-page-cache.h"
#include "ev-selection.h"
#include "ev-document-images.h"
#include "ev-image.h"
typedef struct _CacheJobInfo
{
......@@ -11,6 +13,7 @@ typedef struct _CacheJobInfo
/* Data we get from rendering */
GdkPixbuf *pixbuf;
GList *link_mapping;
GList *image_mapping;
GdkRegion *text_mapping;
/* Selection data.
......@@ -152,6 +155,10 @@ dispose_cache_job_info (CacheJobInfo *job_info,
ev_link_mapping_free (job_info->link_mapping);
job_info->link_mapping = NULL;
}
if (job_info->image_mapping) {
ev_image_mapping_free (job_info->image_mapping);
job_info->image_mapping = NULL;
}
if (job_info->text_mapping) {
gdk_region_destroy (job_info->text_mapping);
job_info->text_mapping = NULL;
......@@ -312,6 +319,7 @@ move_one_job (CacheJobInfo *job_info,
job_info->job = NULL;
job_info->pixbuf = NULL;
job_info->link_mapping = NULL;
job_info->image_mapping = NULL;
if (new_priority != priority && target_page->job) {
ev_job_queue_update_job (target_page->job, new_priority);
......@@ -415,15 +423,19 @@ copy_job_to_job_info (EvJobRender *job_render,
job_info->link_mapping = job_render->link_mapping;
}
if (job_render->include_images) {
if (job_info->image_mapping)
ev_image_mapping_free (job_info->image_mapping);
job_info->image_mapping = job_render->image_mapping;
}
if (job_render->include_text) {
if (job_info->text_mapping)
gdk_region_destroy (job_info->text_mapping);
job_info->text_mapping = job_render->text_mapping;
}
if (job_render->include_selection) {
if (job_info->selection) {
g_object_unref (G_OBJECT (job_info->selection));
job_info->selection = NULL;
......@@ -447,10 +459,9 @@ copy_job_to_job_info (EvJobRender *job_render,
g_object_unref (G_OBJECT (job_info->job));
job_info->job = NULL;
}
}
static CacheJobInfo*
static CacheJobInfo *
find_job_cache (EvPixbufCache *pixbuf_cache,
int page)
{
......@@ -528,6 +539,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache,
gboolean include_links = FALSE;
gboolean include_text = FALSE;
gboolean include_selection = FALSE;
gboolean include_images = FALSE;
int width, height;
GdkColor *text, *base;
......@@ -554,6 +566,8 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache,
/* Figure out what else we need for this job */
if (job_info->link_mapping == NULL)
include_links = TRUE;
if (job_info->image_mapping == NULL)
include_images = TRUE;
if (job_info->text_mapping == NULL)
include_text = TRUE;
if (new_selection_pixbuf_needed (pixbuf_cache, job_info, page, scale)) {
......@@ -570,6 +584,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache,
&(job_info->target_points),
text, base,
include_links,
include_images,
include_text,
include_selection);
ev_job_queue_add_job (job_info->job, priority);
......@@ -690,6 +705,28 @@ ev_pixbuf_cache_get_link_mapping (EvPixbufCache *pixbuf_cache,
return job_info->link_mapping;
}
GList *
ev_pixbuf_cache_get_image_mapping (EvPixbufCache *pixbuf_cache,
gint page)
{
CacheJobInfo *job_info;
if (!EV_IS_DOCUMENT_IMAGES (pixbuf_cache->document))
return NULL;
job_info = find_job_cache (pixbuf_cache, page);
if (job_info == NULL)
return NULL;
/* We don't need to wait for the idle to handle the callback */
if (job_info->job &&
EV_JOB (job_info->job)->finished) {
copy_job_to_job_info (EV_JOB_RENDER (job_info->job), job_info, pixbuf_cache);
}
return job_info->image_mapping;
}
static gboolean
new_selection_pixbuf_needed (EvPixbufCache *pixbuf_cache,
CacheJobInfo *job_info,
......@@ -729,8 +766,8 @@ clear_selection_if_needed (EvPixbufCache *pixbuf_cache,
}
GdkRegion *
ev_pixbuf_cache_get_text_mapping (EvPixbufCache *pixbuf_cache,
gint page)
ev_pixbuf_cache_get_text_mapping (EvPixbufCache *pixbuf_cache,
gint page)
{
CacheJobInfo *job_info;
......
......@@ -48,7 +48,7 @@ typedef struct {
typedef struct _EvPixbufCache EvPixbufCache;
typedef struct _EvPixbufCacheClass EvPixbufCacheClass;
GType ev_pixbuf_cache_get_type (void) G_GNUC_CONST;
GType ev_pixbuf_cache_get_type (void) G_GNUC_CONST;
EvPixbufCache *ev_pixbuf_cache_new (GtkWidget *view,
EvDocument *document);
void ev_pixbuf_cache_set_page_range (EvPixbufCache *pixbuf_cache,
......@@ -61,6 +61,8 @@ GdkPixbuf *ev_pixbuf_cache_get_pixbuf (EvPixbufCache *pixbuf_cache
gint page);
GList *ev_pixbuf_cache_get_link_mapping (EvPixbufCache *pixbuf_cache,
gint page);
GList *ev_pixbuf_cache_get_image_mapping (EvPixbufCache *pixbuf_cache,
gint page);