From 6b9aeb5d0b86d0002db107ad79af550a4e39f07a Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sun, 07 Jan 2007 16:28:00 +0000 Subject: Add image handling support. Fixes bugs #310008 and #325047. Images 2007-01-07 Carlos Garcia Campos * 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 --- (limited to 'shell/ev-pixbuf-cache.c') diff --git a/shell/ev-pixbuf-cache.c b/shell/ev-pixbuf-cache.c index 630bdde..885c11a 100644 --- a/shell/ev-pixbuf-cache.c +++ b/shell/ev-pixbuf-cache.c @@ -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; -- cgit v0.9.1