Index: backend/Makefile.am =================================================================== RCS file: /cvs/gnome/evince/backend/Makefile.am,v retrieving revision 1.26 diff -u -8 -p -r1.26 Makefile.am --- backend/Makefile.am 3 Apr 2006 00:30:57 -0000 1.26 +++ backend/Makefile.am 30 Apr 2006 16:23:19 -0000 @@ -32,16 +32,18 @@ libevbackend_la_SOURCES= \ ev-document-fonts.h \ ev-document-links.c \ ev-document-links.h \ ev-document-security.c \ ev-document-security.h \ ev-document-find.c \ ev-document-find.h \ ev-document-info.h \ + ev-form.h \ + ev-form.c \ ev-ps-exporter.c \ ev-ps-exporter.h \ ev-render-context.h \ ev-render-context.c \ ev-selection.h \ ev-selection.c \ ev-document-misc.h \ ev-document-misc.c Index: backend/ev-document.c =================================================================== RCS file: /cvs/gnome/evince/backend/ev-document.c,v retrieving revision 1.34 diff -u -8 -p -r1.34 ev-document.c --- backend/ev-document.c 3 Apr 2006 00:30:57 -0000 1.34 +++ backend/ev-document.c 30 Apr 2006 16:23:19 -0000 @@ -195,16 +195,31 @@ ev_document_get_links (EvDocument *docum LOG ("ev_document_get_link"); if (iface->get_links == NULL) return NULL; retval = iface->get_links (document, page); return retval; } +GList * +ev_document_get_form_fields (EvDocument *document, + int page) +{ + EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); + GList *retval; + + LOG("ev_document_get_form_fields"); + if (iface->get_form_fields == NULL) + return NULL; + retval = iface->get_form_fields (document, page); + return retval; +} + + gboolean ev_document_has_attachments (EvDocument *document) { EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); if (iface->has_attachments == NULL) return FALSE; Index: backend/ev-document.h =================================================================== RCS file: /cvs/gnome/evince/backend/ev-document.h,v retrieving revision 1.33 diff -u -8 -p -r1.33 ev-document.h --- backend/ev-document.h 3 Apr 2006 00:30:57 -0000 1.33 +++ backend/ev-document.h 30 Apr 2006 16:23:19 -0000 @@ -22,16 +22,17 @@ #ifndef EV_DOCUMENT_H #define EV_DOCUMENT_H #include #include #include #include "ev-link.h" +#include "ev-form.h" #include "ev-document-info.h" #include "ev-render-context.h" G_BEGIN_DECLS #define EV_TYPE_DOCUMENT (ev_document_get_type ()) #define EV_DOCUMENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT, EvDocument)) #define EV_DOCUMENT_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT, EvDocumentIface)) @@ -92,16 +93,18 @@ struct _EvDocumentIface EvRectangle *rect); GList * (* get_links) (EvDocument *document, int page); gboolean (* has_attachments) (EvDocument *document); GList * (* get_attachments) (EvDocument *document); GdkPixbuf * (* render_pixbuf) (EvDocument *document, EvRenderContext *rc); EvDocumentInfo * (* get_info) (EvDocument *document); + GList * (* get_form_fields) (EvDocument *document, + int page); }; GType ev_document_get_type (void); GQuark ev_document_error_quark (void); GMutex *ev_document_get_doc_mutex (void); void ev_document_doc_mutex_lock (void); void ev_document_doc_mutex_unlock (void); @@ -127,13 +130,16 @@ GList *ev_document_get_links int page); gboolean ev_document_has_attachments (EvDocument *document); GList *ev_document_get_attachments (EvDocument *document); GdkPixbuf *ev_document_render_pixbuf (EvDocument *document, EvRenderContext *rc); gint ev_rect_cmp (EvRectangle *a, EvRectangle *b); + +GList *ev_document_get_form_fields (EvDocument *document, + int page); G_END_DECLS #endif Index: pdf/ev-poppler.cc =================================================================== RCS file: /cvs/gnome/evince/pdf/ev-poppler.cc,v retrieving revision 1.66 diff -u -8 -p -r1.66 ev-poppler.cc --- pdf/ev-poppler.cc 3 Apr 2006 00:30:58 -0000 1.66 +++ pdf/ev-poppler.cc 30 Apr 2006 16:23:22 -0000 @@ -310,16 +310,55 @@ pdf_document_get_links (EvDocument *docu } poppler_page_free_link_mapping (mapping_list); g_object_unref (poppler_page); return g_list_reverse (retval); } +static GList * +pdf_document_get_form_fields (EvDocument *document, + int page) +{ + PdfDocument *pdf_document; + PopplerPage *poppler_page; + GList *retval = NULL; + GList *fields; + GList *list; + double height; + printf("pdf_document_get_form_fields\n"); + + pdf_document = PDF_DOCUMENT (document); + poppler_page = poppler_document_get_page (pdf_document->document, + page); + fields = poppler_page_get_form_fields (poppler_page); + poppler_page_get_size (poppler_page, NULL, &height); + + for (list = fields; list; list = list->next) { + PopplerFormField *field; + EvFormFieldMapping *ev_form_field; + + field = (PopplerFormField *)list->data; + ev_form_field = g_new (EvFormFieldMapping, 1); + ev_form_field->field = ev_form_field_new_button("test"); + ev_form_field->x1 = field->area.x1; + ev_form_field->x2 = field->area.x2; + /* Invert this for X-style coordinates */ + ev_form_field->y1 = height - field->area.y2; + ev_form_field->y2 = height - field->area.y1; + + retval = g_list_prepend(retval, ev_form_field); + } + poppler_page_free_form_fields(fields); + g_object_unref (poppler_page); + + return g_list_reverse(retval); +} + static gboolean pdf_document_has_attachments (EvDocument *document) { PdfDocument *pdf_document; pdf_document = PDF_DOCUMENT (document); return poppler_document_has_attachments (pdf_document->document); @@ -653,25 +692,27 @@ pdf_document_get_text (EvDocument *docum text = poppler_page_get_text (poppler_page, &r); g_object_unref (poppler_page); return text; } + static void pdf_document_document_iface_init (EvDocumentIface *iface) { iface->save = pdf_document_save; iface->load = pdf_document_load; iface->get_n_pages = pdf_document_get_n_pages; iface->get_page_size = pdf_document_get_page_size; iface->get_page_label = pdf_document_get_page_label; iface->get_links = pdf_document_get_links; + iface->get_form_fields = pdf_document_get_form_fields; iface->has_attachments = pdf_document_has_attachments; iface->get_attachments = pdf_document_get_attachments; iface->render_pixbuf = pdf_document_render_pixbuf; iface->get_text = pdf_document_get_text; iface->can_get_text = pdf_document_can_get_text; iface->get_info = pdf_document_get_info; }; Index: shell/ev-jobs.c =================================================================== RCS file: /cvs/gnome/evince/shell/ev-jobs.c,v retrieving revision 1.12 diff -u -8 -p -r1.12 ev-jobs.c --- shell/ev-jobs.c 2 Apr 2006 23:24:26 -0000 1.12 +++ shell/ev-jobs.c 30 Apr 2006 16:23:23 -0000 @@ -208,16 +208,17 @@ ev_job_links_run (EvJobLinks *job) EvJob * ev_job_render_new (EvDocument *document, EvRenderContext *rc, gint width, gint height, EvRectangle *selection_points, GdkColor *text, GdkColor *base, + gboolean include_form, gboolean include_links, gboolean include_text, gboolean include_selection) { EvJobRender *job; g_return_val_if_fail (EV_IS_RENDER_CONTEXT (rc), NULL); if (include_selection) @@ -226,16 +227,17 @@ ev_job_render_new (EvDocument *docu job = g_object_new (EV_TYPE_JOB_RENDER, NULL); EV_JOB (job)->document = g_object_ref (document); job->rc = g_object_ref (rc); job->target_width = width; job->target_height = height; job->text = *text; job->base = *base; + job->include_form = include_form; job->include_links = include_links; job->include_text = include_text; job->include_selection = include_selection; if (include_selection) job->selection_points = *selection_points; if (EV_IS_ASYNC_RENDERER (document)) { @@ -266,16 +268,18 @@ ev_job_render_run (EvJobRender *job) if (EV_JOB (job)->async) { EvAsyncRenderer *renderer = EV_ASYNC_RENDERER (EV_JOB (job)->document); ev_async_renderer_render_pixbuf (renderer, job->rc->page, job->rc->scale, job->rc->rotation); g_signal_connect (EV_JOB (job)->document, "render_finished", G_CALLBACK (render_finished_cb), job); } else { job->pixbuf = ev_document_render_pixbuf (EV_JOB (job)->document, job->rc); + if (job->include_form) + job->form_field_mapping = ev_document_get_form_fields (EV_JOB (job)->document, job->rc->page); if (job->include_links) job->link_mapping = ev_document_get_links (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), job->rc); if (job->include_selection && EV_IS_SELECTION (EV_JOB (job)->document)) { ev_selection_render_selection (EV_SELECTION (EV_JOB (job)->document), job->rc, &(job->selection), Index: shell/ev-jobs.h =================================================================== RCS file: /cvs/gnome/evince/shell/ev-jobs.h,v retrieving revision 1.11 diff -u -8 -p -r1.11 ev-jobs.h --- shell/ev-jobs.h 2 Apr 2006 23:24:26 -0000 1.11 +++ shell/ev-jobs.h 30 Apr 2006 16:23:23 -0000 @@ -111,23 +111,25 @@ struct _EvJobRender EvRenderContext *rc; gint target_width; gint target_height; GdkPixbuf *pixbuf; GList *link_mapping; GdkRegion *text_mapping; + GList *form_field_mapping; GdkPixbuf *selection; GdkRegion *selection_region; EvRectangle selection_points; GdkColor base; GdkColor text; - + + gint include_form : 1; gint include_links : 1; gint include_text : 1; gint include_selection : 1; }; struct _EvJobRenderClass { EvJobClass parent_class; @@ -185,16 +187,17 @@ void ev_job_links_run GType ev_job_render_get_type (void); EvJob *ev_job_render_new (EvDocument *document, EvRenderContext *rc, gint width, gint height, EvRectangle *selection_points, GdkColor *text, GdkColor *base, + gboolean include_form, gboolean include_links, gboolean include_text, gboolean include_selection); void ev_job_render_run (EvJobRender *thumbnail); /* EvJobThumbnail */ GType ev_job_thumbnail_get_type (void); EvJob *ev_job_thumbnail_new (EvDocument *document, Index: shell/ev-pixbuf-cache.c =================================================================== RCS file: /cvs/gnome/evince/shell/ev-pixbuf-cache.c,v retrieving revision 1.22 diff -u -8 -p -r1.22 ev-pixbuf-cache.c --- shell/ev-pixbuf-cache.c 7 Jan 2006 13:18:28 -0000 1.22 +++ shell/ev-pixbuf-cache.c 30 Apr 2006 16:23:25 -0000 @@ -7,16 +7,17 @@ typedef struct _CacheJobInfo { EvJob *job; EvRenderContext *rc; /* Data we get from rendering */ GdkPixbuf *pixbuf; GList *link_mapping; GdkRegion *text_mapping; + GList *form_field_mapping; /* Selection data. * Selection_points are the coordinates encapsulated in selection. * target_points is the target selection size. */ EvRectangle selection_points; EvRectangle target_points; gboolean points_set; @@ -143,16 +144,20 @@ dispose_cache_job_info (CacheJobInfo *jo ev_job_queue_remove_job (job_info->job); g_object_unref (G_OBJECT (job_info->job)); job_info->job = NULL; } if (job_info->pixbuf) { g_object_unref (G_OBJECT (job_info->pixbuf)); job_info->pixbuf = NULL; } + if (job_info->form_field_mapping) { + ev_form_field_mapping_free (job_info->form_field_mapping); + job_info->form_field_mapping = NULL; + } if (job_info->link_mapping) { ev_link_mapping_free (job_info->link_mapping); job_info->link_mapping = NULL; } if (job_info->text_mapping) { gdk_region_destroy (job_info->text_mapping); job_info->text_mapping = NULL; } @@ -307,16 +312,17 @@ move_one_job (CacheJobInfo *job_info, new_priority = EV_JOB_PRIORITY_HIGH; target_page = new_job_list + page_offset; } *target_page = *job_info; job_info->job = NULL; job_info->pixbuf = NULL; job_info->link_mapping = NULL; + job_info->form_field_mapping = NULL; if (new_priority != priority && target_page->job) { ev_job_queue_update_job (target_page->job, new_priority); } } @@ -405,17 +411,19 @@ copy_job_to_job_info (EvJobRender *job dispose_cache_job_info (job_info, pixbuf_cache); job_info->pixbuf = pixbuf; job_info->rc = rc; if (job_render->link_mapping) job_info->link_mapping = job_render->link_mapping; if (job_render->text_mapping) - job_info->text_mapping = job_render->text_mapping; + job_info->text_mapping = job_render->text_mapping; + if (job_render->form_field_mapping) + job_info->form_field_mapping = job_render->form_field_mapping; if (job_render->include_selection) { pixbuf = g_object_ref (job_render->selection); job_info->selection_points = job_render->selection_points; job_info->selection_region = gdk_region_copy (job_render->selection_region); job_info->selection = pixbuf; g_assert (job_info->selection_points.x1 >= 0); } @@ -492,16 +500,17 @@ static void add_job_if_needed (EvPixbufCache *pixbuf_cache, CacheJobInfo *job_info, EvPageCache *page_cache, gint page, gint rotation, gfloat scale, EvJobPriority priority) { + gboolean include_form = FALSE; gboolean include_links = FALSE; gboolean include_text = FALSE; gboolean include_selection = FALSE; int width, height; GdkColor *text, *base; if (job_info->job) return; @@ -519,16 +528,18 @@ add_job_if_needed (EvPixbufCache *pixbuf job_info->rc = ev_render_context_new (rotation, page, scale); } else { ev_render_context_set_rotation (job_info->rc, rotation); ev_render_context_set_page (job_info->rc, page); ev_render_context_set_scale (job_info->rc, scale); } /* Figure out what else we need for this job */ + if (job_info->form_field_mapping == NULL) + include_form = TRUE; if (job_info->link_mapping == NULL) include_links = TRUE; if (job_info->text_mapping == NULL) include_text = TRUE; if (new_selection_pixbuf_needed (pixbuf_cache, job_info, page, scale)) { include_selection = TRUE; } @@ -536,16 +547,17 @@ add_job_if_needed (EvPixbufCache *pixbuf get_selection_colors (pixbuf_cache->view, &text, &base); job_info->job = ev_job_render_new (pixbuf_cache->document, job_info->rc, width, height, &(job_info->target_points), text, base, + include_form, include_links, include_text, include_selection); ev_job_queue_add_job (job_info->job, priority); g_signal_connect (job_info->job, "finished", G_CALLBACK (job_finished_cb), pixbuf_cache); } @@ -656,16 +668,34 @@ ev_pixbuf_cache_get_link_mapping (EvPixb /* 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->link_mapping; } + +GList * +ev_pixbuf_cache_get_form_field_mapping (EvPixbufCache *pixbuf_cache, + gint page) +{ + CacheJobInfo *job_info; + + job_info = find_job_cache (pixbuf_cache, page); + if(job_info == NULL) + return NULL; + + 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->form_field_mapping; +} + static gboolean new_selection_pixbuf_needed (EvPixbufCache *pixbuf_cache, CacheJobInfo *job_info, gint page, gfloat scale) { EvPageCache *page_cache; Index: shell/ev-pixbuf-cache.h =================================================================== RCS file: /cvs/gnome/evince/shell/ev-pixbuf-cache.h,v retrieving revision 1.9 diff -u -8 -p -r1.9 ev-pixbuf-cache.h --- shell/ev-pixbuf-cache.h 6 Aug 2005 05:13:20 -0000 1.9 +++ shell/ev-pixbuf-cache.h 30 Apr 2006 16:23:26 -0000 @@ -58,16 +58,18 @@ void ev_pixbuf_cache_set_page_ gfloat scale, GList *selection_list); GdkPixbuf *ev_pixbuf_cache_get_pixbuf (EvPixbufCache *pixbuf_cache, gint page); GList *ev_pixbuf_cache_get_link_mapping (EvPixbufCache *pixbuf_cache, gint page); GdkRegion *ev_pixbuf_cache_get_text_mapping (EvPixbufCache *pixbuf_cache, gint page); +GList *ev_pixbuf_cache_get_form_field_mapping (EvPixbufCache *pixbuf_cache, + gint page); void ev_pixbuf_cache_clear (EvPixbufCache *pixbuf_cache); void ev_pixbuf_cache_style_changed (EvPixbufCache *pixbuf_cache); /* Selection */ GdkPixbuf *ev_pixbuf_cache_get_selection_pixbuf (EvPixbufCache *pixbuf_cache, gint page, gfloat scale, GdkRegion **region); Index: shell/ev-view.c =================================================================== RCS file: /cvs/gnome/evince/shell/ev-view.c,v retrieving revision 1.198 diff -u -8 -p -r1.198 ev-view.c --- shell/ev-view.c 29 Apr 2006 12:20:26 -0000 1.198 +++ shell/ev-view.c 30 Apr 2006 16:23:35 -0000 @@ -154,16 +154,24 @@ static gboolean doc_point_to_view_point static EvLink * ev_view_get_link_at_location (EvView *view, gdouble x, gdouble y); static char* tip_from_link (EvView *view, EvLink *link); static void handle_link_over_xy (EvView *view, gint x, gint y); + +/*** Forms ***/ +static EvFormField * ev_view_get_form_field_at_location (EvView *view, + gdouble x, + gdouble y); +static void handle_form_field_over_xy (EvView* view, + gint x, + gint y); /*** GtkWidget implementation ***/ static void ev_view_size_request_continuous_dual_page (EvView *view, GtkRequisition *requisition); static void ev_view_size_request_continuous (EvView *view, GtkRequisition *requisition); static void ev_view_size_request_dual_page (EvView *view, GtkRequisition *requisition); static void ev_view_size_request_single_page (EvView *view, @@ -1304,16 +1312,57 @@ handle_link_over_xy (EvView *view, gint ev_view_set_status (view, NULL); if (view->cursor == EV_VIEW_CURSOR_LINK || view->cursor == EV_VIEW_CURSOR_IBEAM) ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL); } return; } +/*** Form ***/ +static EvFormField * +ev_view_get_form_field_at_location (EvView *view, + gdouble x, + gdouble y) +{ + gint page = -1; + gint x_offset = 0, y_offset = 0; + GList *form_field_mapping; + + x += view->scroll_x; + y += view->scroll_y; + + find_page_at_location (view, x, y, &page, &x_offset, &y_offset); + + if (page == -1) + return NULL; + + form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, page); + + if (form_field_mapping) + return ev_form_field_mapping_find (form_field_mapping, x_offset / view->scale, y_offset / view->scale); + else + return NULL; +} + + +static void +handle_form_field_over_xy (EvView *view, gint x, gint y) +{ + EvFormField *field; + + field = ev_view_get_form_field_at_location (view, x, y); + if(field) { + ev_view_set_cursor (view, EV_VIEW_CURSOR_LINK); + //printf("field\n"); + } else { + ev_view_set_cursor(view, EV_VIEW_CURSOR_NORMAL); + } +} + /*** GtkWidget implementation ***/ static void ev_view_size_request_continuous_dual_page (EvView *view, GtkRequisition *requisition) { int max_width; gint n_pages; @@ -1875,17 +1924,18 @@ ev_view_motion_notify_event (GtkWidget return TRUE; } /* For the Evince 0.4.x release, we limit links to un-rotated documents * only. */ } else if (view->pressed_button <= 0 && view->rotation == 0) { - handle_link_over_xy (view, x, y); + //handle_link_over_xy (view, x, y); + handle_form_field_over_xy (view, x, y); return TRUE; } return FALSE; } static gboolean ev_view_button_release_event (GtkWidget *widget,