Index: backend/pdf/ev-poppler.cc =================================================================== --- backend/pdf/ev-poppler.cc (revision 2369) +++ backend/pdf/ev-poppler.cc (working copy) @@ -111,6 +111,10 @@ static GList *pdf_document_get_form_field_mapping (EvDocument *document, int page); +static void pdf_document_get_form_field_rect (EvDocument *document, + unsigned field_id, + double *xMin, double *yMin, + double *xMax, double *yMax); static gchar* pdf_document_get_text_field_content (EvDocument *document, unsigned field_id, int *length); @@ -147,6 +151,14 @@ static gchar * pdf_document_get_form_field_choice_edit (EvDocument *document, unsigned field_id, int *length); +static void pdf_document_render_form_field (EvDocument *document, + unsigned field_id, + cairo_t *cairo); +static cairo_font_face_t* pdf_document_get_form_field_font_face (EvDocument *document, + unsigned field_id); +static unsigned long pdf_document_get_form_field_glyph (EvDocument *document, + unsigned field_id, + unsigned int char_code); @@ -733,6 +745,10 @@ iface->choice_field_deselect_all = pdf_document_form_field_choice_deselect_all; iface->set_choice_field_edit = pdf_document_set_form_field_choice_edit; iface->get_choice_field_edit = pdf_document_get_form_field_choice_edit; + iface->render_form_field = pdf_document_render_form_field; + iface->get_form_field_rect = pdf_document_get_form_field_rect; + iface->get_form_field_font_face = pdf_document_get_form_field_font_face; + iface->get_form_field_glyph = pdf_document_get_form_field_glyph; }; static void @@ -1816,7 +1832,9 @@ dest->text.comb = source->text.comb; dest->text.rich_text = source->text.rich_text; } else if (dest->type == EV_FORM_FIELD_TYPE_BUTTON) { - + dest->button.check = source->button.check; + dest->button.push = source->button.push; + dest->button.radio = source->button.radio; } else if (dest->type == EV_FORM_FIELD_TYPE_CHOICE) { dest->choice.combo = source->choice.combo; dest->choice.edit = source->choice.edit; @@ -1864,6 +1882,15 @@ return g_list_reverse(retval); } +static void pdf_document_get_form_field_rect (EvDocument *document, + unsigned field_id, + double *xMin, double *yMin, + double *xMax, double *yMax) +{ + PdfDocument *pdf_document = PDF_DOCUMENT(document); + return poppler_document_get_form_field_rect(pdf_document->document, field_id, xMin, yMin, xMax, yMax); + +} static gchar* pdf_document_get_text_field_content (EvDocument *document, unsigned field_id, @@ -1960,4 +1987,26 @@ PdfDocument *pdf_document = PDF_DOCUMENT(document); return poppler_document_get_form_field_choice_edit(pdf_document->document, field_id, length); } +static void pdf_document_render_form_field (EvDocument *document, + unsigned field_id, + cairo_t *cairo) +{ + PdfDocument *pdf_document = PDF_DOCUMENT(document); + return poppler_document_render_form_field(pdf_document->document, field_id, cairo); +} +static cairo_font_face_t* pdf_document_get_form_field_font_face (EvDocument *document, + unsigned field_id) +{ + PdfDocument *pdf_document = PDF_DOCUMENT(document); + return poppler_document_get_form_field_font_face(pdf_document->document, field_id); +} + +static unsigned long pdf_document_get_form_field_glyph (EvDocument *document, + unsigned field_id, + unsigned int char_code) +{ + PdfDocument *pdf_document = PDF_DOCUMENT(document); + return poppler_document_get_form_field_glyph(pdf_document->document, field_id, char_code); +} + Index: libdocument/ev-form-field.h =================================================================== --- libdocument/ev-form-field.h (revision 2369) +++ libdocument/ev-form-field.h (working copy) @@ -51,6 +51,9 @@ struct _EvFormButtonField { + char check:1; + char push:1; + char radio:1; }; struct _EvFormChoiceField Index: libdocument/ev-document.c =================================================================== --- libdocument/ev-document.c (revision 2369) +++ libdocument/ev-document.c (working copy) @@ -289,7 +289,7 @@ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); GList *retval; - LOG ("ev_document_get_form_fields"); + LOG ("ev_document_get_form_field_mapping"); if (iface->get_form_field_mapping == NULL) return NULL; @@ -297,6 +297,20 @@ return retval; } +void +ev_document_get_form_field_rect (EvDocument *document, + unsigned field_id, + double *xMin, double *yMin, + double *xMax, double *yMax) +{ + EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); + LOG("ev_document_get_form_field_rect"); + if (iface->get_form_field_rect == NULL) + return; + + return iface->get_form_field_rect (document, field_id, xMin, yMin, xMax, yMax); +} + gboolean ev_document_get_crop_box (EvDocument *document, int page, @@ -435,5 +449,38 @@ return; return iface->get_choice_field_edit(document, field_id, length); } +void +ev_document_render_form_field (EvDocument *document, + unsigned field_id, + cairo_t *cairo) +{ + EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE(document); + LOG("ev_document_render_form_field"); + if (iface->render_form_field == NULL) + return; + iface->render_form_field(document, field_id, cairo); +} +cairo_font_face_t* +ev_document_get_form_field_font_face (EvDocument *document, + unsigned field_id) +{ + EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE(document); + LOG("ev_document_get_form_field_font_face"); + if (iface->get_form_field_font_face == NULL) + return NULL; + return iface->get_form_field_font_face(document, field_id); +} +unsigned long +ev_document_get_form_field_glyph (EvDocument *document, + unsigned field_id, + unsigned int char_code) +{ + EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE(document); + LOG("ev_document_get_form_field_glyph"); + if (iface->get_form_field_glyph == NULL) + return NULL; + return iface->get_form_field_glyph(document, field_id, char_code); +} + Index: libdocument/ev-document.h =================================================================== --- libdocument/ev-document.h (revision 2369) +++ libdocument/ev-document.h (working copy) @@ -25,6 +25,7 @@ #include #include #include +#include #include "ev-link.h" #include "ev-form-field.h" @@ -100,6 +101,10 @@ EvRectangle *rect); GList * (* get_form_field_mapping) (EvDocument *document, int page); + void (* get_form_field_rect) (EvDocument *document, + unsigned field_id, + double *xMin, double *yMin, + double *xMax, double *yMax); gchar * (* get_text_field_content) (EvDocument *document, unsigned field_id, int *length); @@ -136,6 +141,14 @@ gchar * (* get_choice_field_edit) (EvDocument *document, unsigned field_id, int *length); + void (* render_form_field) (EvDocument *document, + unsigned field_id, + cairo_t *cairo); + cairo_font_face_t * (* get_form_field_font_face) (EvDocument *document, + unsigned field_id); + unsigned long (* get_form_field_glyph) (EvDocument *document, + unsigned field_id, + unsigned int char_code); }; GType ev_document_get_type (void); @@ -179,6 +192,10 @@ /* Forms */ GList *ev_document_get_form_field_mapping (EvDocument *document, int page); +void ev_document_get_form_field_rect (EvDocument *document, + unsigned field_id, + double *xMin, double *yMin, + double *xMax, double *yMax); gchar *ev_document_get_form_field_text_content (EvDocument *document, int field_id, @@ -222,7 +239,16 @@ gchar * ev_document_get_form_field_choice_edit (EvDocument *document, unsigned field_id, int *length); +void ev_document_render_form_field (EvDocument *document, + unsigned field_id, + cairo_t *cairo); +cairo_font_face_t* ev_document_get_form_field_font_face (EvDocument *document, + unsigned field_id); +unsigned long ev_document_get_form_field_glyph (EvDocument *document, + unsigned field_id, + unsigned int char_code); + G_END_DECLS #endif Index: shell/ev-entry.c =================================================================== --- shell/ev-entry.c (revision 0) +++ shell/ev-entry.c (revision 0) @@ -0,0 +1,221 @@ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2007 Julien Rebetez + * + * 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-entry.h" + +G_DEFINE_TYPE (EvEntry, ev_entry, GTK_TYPE_ENTRY); +//G_DEFINE_TYPE (EvEntry, ev_entry, GTK_TYPE_DRAWING_AREA); + +static gint ev_entry_expose (GtkWidget *widget, + GdkEventExpose *event); + +typedef enum { + CURSOR_STANDARD, + CURSOR_DND +} CursorType; + +static void +ev_entry_class_init (EvEntryClass *class) +{ + GtkWidgetClass *widget_class; + widget_class = GTK_WIDGET_CLASS(class); + + //widget_class->expose_event = ev_entry_expose; + +} + +static void +ev_entry_init (EvEntry *entry) +{ + +} + +EvEntry* +ev_entry_new (unsigned id, EvDocument *document) +{ + EvEntry* entry = g_object_new (EV_TYPE_ENTRY, NULL); + entry->id = id; + entry->document = document; + return entry; +} + + + +static void +ev_entry_draw_text (EvEntry *entry) +{ + EvEntry *ev_entry; + GtkWidget *widget; + cairo_t *cairo; + double xMin,yMin, xMax, yMax; + double radius; + GList *field_mapping; + EvFormField *field; + cairo_font_face_t* font_face; + const int len = 10; + double x, y; + cairo_text_extents_t extents; + int i; + const char *utf8 = "cairo"; + g_return_if_fail(EV_IS_ENTRY(entry)); + + //TODO: Use CairoFont.cc to get a cairo font face and simply render text + // using this font size + printf("entry_draw_text\n"); + ev_entry = EV_ENTRY(entry); + widget = GTK_WIDGET(entry); + +#if 0 + font_face = ev_document_get_form_field_font_face(ev_entry->document, ev_entry->id); + + if (!font_face) { + printf("ev_entry_draw_text : no font face \n"); + return; + } + + cairo = gdk_cairo_create(GTK_WIDGET(entry)->window); + cairo_set_font_face(cairo, font_face); + //cairo_select_font_face(cairo, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size(cairo, 20); + + cairo_text_extents(cairo, utf8, &extents); + x = -extents.x_bearing; + y = -extents.y_bearing; + cairo_move_to(cairo, x, y); + cairo_show_text(cairo, utf8); + + cairo_set_source_rgba(cairo, 1.0, 0.2, 0.2, 0.6); + cairo_arc(cairo, x, y, 0.05, 0., 2*3.1415); + cairo_fill(cairo); + + cairo_destroy(cairo); +#endif + + /*cairo_set_source_rgb(cairo, 0, 0, 0); + cairo_rectangle(cairo, 0,0, + widget->allocation.width, widget->allocation.height); + cairo_fill(cairo);*/ + +#if 1 + ev_document_get_form_field_rect(ev_entry->document, ev_entry->id, &xMin, &yMin, &xMax, &yMax); + printf("xMin : %f, yMin : %f\n", xMin, yMin); + + ev_document_doc_mutex_lock (); + ev_document_fc_mutex_lock (); + + cairo = gdk_cairo_create(GTK_WIDGET(entry)->window); + //cairo_translate(cairo, xMin, yMin); + + ev_document_render_form_field(ev_entry->document, ev_entry->id, cairo); + +/* x = widget->allocation.x + widget->allocation.width/2; + y = widget->allocation.y + widget->allocation.height/2; + radius = widget->allocation.width/2 -5; + cairo_arc(cairo, x, y, radius, 0, 6.28);*/ + + ev_document_fc_mutex_unlock (); + ev_document_doc_mutex_unlock (); + + +/* cairo_set_source_rgb(cairo, 0, 0, 0); + cairo_rectangle(cairo, 0,0, + widget->allocation.width, widget->allocation.height); + cairo_stroke(cairo); + cairo_destroy(cairo);*/ + + #if 0 + GtkWidget *widget; + + if (!entry->visible && entry->invisible_char == 0) + return; + + if (GTK_WIDGET_DRAWABLE(entry)) { + //just call poppler_document_render_form_field with the cairo context and associated field id + int len = entry->n_bytes; + int glyphCount = 0; + int i; + cairo_glyph_t *glyphs; + //create cairo ? + cairo_t* cairo; + //get pattern ! + cairo_pattern_t* fill_pattern; + glyphs = (cairo_glyph_t *) gmalloc (len * sizeof(cairo_glyph_t)); + + //for an utf8 string, len must be even + if (len%2) { + printf("!!! error, uneven length\n"); + return ; + } + for(i=0; itext[i]); + GtkBorder inner_border; + gint area_width, area_height; + gint x, y; + get_text_area_size (entry, NULL, NULL, &area_width, &area_height); + _gtk_entry_effective_inner_border (entry, &inner_border); + x = inner_border.left - entry->scroll_offset; + y = inner_border.top; + + glyphs[glyphCount].index = //getGlyph + glyphs[glyphCount].x = x; + glyphs[glyphCount].y = y; + glyphCount++; + } + //actually draw the text + cairo_set_source (cairo, fill_pattern); + cairo_show_glyphs (cairo, glyphs, glyphCount); + } + #endif +#endif +} + +static gint +ev_entry_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + ev_entry_draw_text(EV_ENTRY(widget)); + return FALSE; + #if 0 + GtkEntry *entry = GTK_ENTRY(widget); + if (widget->window == event->window) + gtk_entry_draw_frame (widget, &event->area); + else if (entry->text_area == event->window) { + gint area_width, area_height; + get_text_area_size (entry, NULL, NULL, &area_width, &area_height); + + gtk_paint_flat_box (widget->style, entry->text_area, + GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, + &event->area, widget, "entry_bg", + 0, 0, area_width, area_height); + + /*if ((entry->visible || entry->invisible_chare != 0) && + GTK_WIDGET_HAS_FOCUS (widget) && + entry->selection_bound == entry->current_pos && entry->cursor_visible) + gtk_entry_draw_cursor (GTK_ENTRY(widget), CURSOR_STANDARD); + + if (entry->dnd_position != 1) + gtk_entry_draw_cursor (GTK_ENTRY(widget), CURSOR_DND);*/ + + ev_entry_draw_text (GTK_ENTRY(widget)); + } + + return FALSE; + #endif +} + Index: shell/ev-entry.h =================================================================== --- shell/ev-entry.h (revision 0) +++ shell/ev-entry.h (revision 0) @@ -0,0 +1,65 @@ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2007 Julien Rebetez + * + * 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_ENTRY_H +#define __EV_ENTRY_H + +#include +#include +#include + +#include "ev-document.h" + +G_BEGIN_DECLS + +#define EV_TYPE_ENTRY (ev_entry_get_type()) +#define EV_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_ENTRY, EvEntry)) +#define EV_ENTRY_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj, EV_ENTRY, EvEntryClass)) +#define EV_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EV_TYPE_ENTRY)) +#define EV_IS_ENTRY_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), EV_TYPE_ENTRY)) +#define EV_ENTRY_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), EV_TYPE_ENTRY, EvEntryClass)) + + +typedef struct _EvEntry EvEntry; +typedef struct _EvEntryClass EvEntryClass; + +struct _EvEntry +{ + GtkEntry parent; + //GtkDrawingArea parent; + + /* private */ + unsigned id; + EvDocument *document; +}; + +struct _EvEntryClass +{ + GtkEntryClass parent_class; + //GtkDrawingAreaClass parent_class; +}; + +GType ev_entry_get_type (void) G_GNUC_CONST; + +EvEntry* ev_entry_new (unsigned id, EvDocument *document); + +G_END_DECLS + +#endif + Index: shell/ev-view-private.h =================================================================== --- shell/ev-view-private.h (revision 2369) +++ shell/ev-view-private.h (working copy) @@ -197,6 +197,9 @@ gint current_width; gint current_height; GList *childs; + + /* Form */ + gboolean highlight; }; struct _EvViewClass { Index: shell/ev-window.c =================================================================== --- shell/ev-window.c (revision 2369) +++ shell/ev-window.c (working copy) @@ -51,6 +51,7 @@ #include "ev-jobs.h" #include "ev-sidebar-page.h" #include "eggfindbar.h" +#include "ev-message-area.h" #ifndef HAVE_GTK_RECENT #include "egg-recent-view-uimanager.h" @@ -128,6 +129,7 @@ GtkWidget *sidebar_links; GtkWidget *sidebar_attachments; GtkWidget *preview_toolbar; + GtkWidget *message_area; /* Dialogs */ GtkWidget *properties; @@ -4768,6 +4770,17 @@ } static void +highlight_fields_message_area_response (EvMessageArea *message_area, + gint response_id, + EvWindow *window) +{ + g_return_if_fail (EV_IS_VIEW (window->priv->view)); + EvView *view = EV_VIEW(window->priv->view); + printf("highlight !\n"); + ev_view_toggle_highlight_fields(view); +} + +static void ev_window_init (EvWindow *ev_window) { GtkActionGroup *action_group; @@ -4883,6 +4896,22 @@ gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), ev_window->priv->preview_toolbar, FALSE, FALSE, 0); + /* Message area */ + ev_window->priv->message_area = ev_message_area_form_new(); + + gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box), + ev_window->priv->message_area, + FALSE, TRUE, 0); + + ev_message_area_set_default_response (EV_MESSAGE_AREA(ev_window->priv->message_area), + GTK_RESPONSE_OK); + + g_signal_connect (ev_window->priv->message_area, "response", + G_CALLBACK(highlight_fields_message_area_response), ev_window); + + + gtk_widget_show (ev_window->priv->message_area); + /* Add the main area */ ev_window->priv->hpaned = gtk_hpaned_new (); g_signal_connect (ev_window->priv->hpaned, Index: shell/ev-view.c =================================================================== --- shell/ev-view.c (revision 2369) +++ shell/ev-view.c (working copy) @@ -43,6 +43,7 @@ #include "ev-pixbuf-cache.h" #include "ev-tooltip.h" #include "ev-application.h" +#include "ev-entry.h" #define EV_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_VIEW, EvViewClass)) #define EV_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EV_TYPE_VIEW)) @@ -342,7 +343,7 @@ static void handle_click_at_location (EvView *view, gdouble x, gdouble y); -static void render_form_field_content_for_page (EvView *view, gint page); +static void highlight_form_fields_for_page (EvView *view, gint page); /*** Container ***/ static void ev_view_map (GtkWidget *widget); @@ -361,7 +362,8 @@ double x2, double y2, gint page, - gint id); + gint id, + gboolean committed); static void ev_view_forall (GtkContainer *cont, gboolean include_internals, GtkCallback callback, @@ -3071,6 +3073,7 @@ g_object_unref (scaled_selection); } } + highlight_form_fields_for_page (view, page); } /*** GObject functions ***/ @@ -3486,6 +3489,7 @@ view->current_width = 0; view->current_height = 0; view->childs = NULL; + view->highlight = FALSE; gtk_drag_dest_set (GTK_WIDGET (view), GTK_DEST_DEFAULT_ALL, @@ -5238,6 +5242,31 @@ ev_pixbuf_cache_reload_page(view->pixbuf_cache, page, view->rotation, view->scale); } +static void entry_draw_content (GtkWidget *widget, + GdkEventExpose *expose, + gpointer user_data) +{ + cairo_t *cairo; + double xMin,yMin,xMax,yMax; + EvEntry *ev_entry; + g_return_if_fail(EV_IS_ENTRY(widget)); + ev_entry = EV_ENTRY(widget); + + printf("entry_draw_content"); + ev_document_get_form_field_rect(ev_entry->document, ev_entry->id, &xMin, &yMin, &xMax, &yMax); + printf("xMin : %f, yMin : %f\n", xMin, yMin); + + ev_document_doc_mutex_lock (); + ev_document_fc_mutex_lock (); + + cairo = gdk_cairo_create(widget->window); + + ev_document_render_form_field(ev_entry->document, ev_entry->id, cairo); + + ev_document_fc_mutex_unlock (); + ev_document_doc_mutex_unlock (); +} + static void handle_click_at_location (EvView *view, gdouble x, @@ -5254,6 +5283,7 @@ gint v[4]; gchar *content; gboolean current_state; + gboolean committed = FALSE; x += view->scroll_x; @@ -5292,19 +5322,27 @@ v[2] = d[1].x - view->scroll_x; v[3] = d[1].y - view->scroll_y; //TODO: delete old field + switch (new_field->type) { case EV_FORM_FIELD_TYPE_BUTTON: - /*wid = gtk_button_new_with_label("Button");*/ printf("button clicked\n"); - current_state = ev_document_get_form_field_button_state(view->document, new_field->id); - printf("old state: %i, new state: %i\n", current_state, !current_state); + current_state = ev_document_get_form_field_button_state(view->document, new_field->id); + printf("old state: %i, new state: %i\n", current_state, !current_state); ev_document_set_form_field_button_state(view->document, new_field->id, !current_state); - //g_array_append_val(view->pendingFormFields,new_field->id); - //ev_pixbuf_cache_reload_page(view->pixbuf_cache, page, view->rotation, view->scale); - gtk_widget_queue_draw(GTK_WIDGET(view)); - return; - //break; + ev_pixbuf_cache_reload_page(view->pixbuf_cache, page, view->rotation, view->scale); + if (new_field->button.check || new_field->button.radio) { + printf("creating label\n"); + //FIXME: we should add these label with the commited flag on + //display a label with an 'heavy check mark' (U+2714) + if (ev_document_get_form_field_button_state(view->document, new_field->id)) + wid = gtk_label_new ("\342\234\224"); + //else TODO: display some sort of feedback when deselecting ? + committed = TRUE; + break; + } else { + return; + } case EV_FORM_FIELD_TYPE_TEXT: { int txt_length; @@ -5329,12 +5367,16 @@ gtk_text_buffer_set_text(buffer, content, -1); } else { - wid = gtk_entry_new(); + //wid = gtk_entry_new(); + wid = ev_entry_new(new_field->id, view->document); + g_signal_connect_after(GTK_OBJECT(wid),"expose-event",G_CALLBACK(entry_draw_content), NULL); if (content) gtk_entry_set_text(GTK_ENTRY(wid), content); gtk_entry_set_has_frame(GTK_ENTRY(wid), FALSE); + // wid = ev_entry_new (new_field->id, view->document); + //if (content) + gtk_entry_set_text(GTK_ENTRY(wid), content); } - break; } case EV_FORM_FIELD_TYPE_CHOICE: @@ -5469,11 +5511,59 @@ break; } gtk_widget_set_size_request(wid, v[2]-v[0], v[3]-v[1]); - ev_view_put(view, wid, info, v[0],v[1],p[0].x,p[0].y,p[1].x,p[1].y,page, new_field->id); + ev_view_put(view, wid, info, v[0],v[1],p[0].x,p[0].y,p[1].x,p[1].y,page, new_field->id, committed); gtk_widget_show_all(wid); gtk_widget_grab_focus(wid); } +void +ev_view_toggle_highlight_fields (EvView *view) +{ + view->highlight = !view->highlight; + //TODO: we need to remove highlighting (re-render page ?) + gtk_widget_queue_draw_area(GTK_WIDGET(view), 0, 0, view->current_width, view->current_height); +} + +void +highlight_form_fields_for_page (EvView *view, gint page) +{ + GList *form_field_mapping = NULL; + GList *item = NULL; + + if (!view->highlight) + return; + + form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, page); + if (!form_field_mapping) + return; + + for (item = form_field_mapping; item != NULL; item = g_list_next(item)) { + EvFormField *field = item->data; + EvPoint p[2]; + GdkPoint d[2]; + gint v[4]; + + p[0].x = field->x1; + p[0].y = field->y1; + p[1].x = field->x2; + p[1].y = field->y2; + + doc_point_to_view_point (view, page, &p[0], &d[0]); + doc_point_to_view_point (view, page, &p[1], &d[1]); + v[0] = d[0].x - view->scroll_x; v[1] = d[0].y - view->scroll_y; + v[2] = d[1].x - view->scroll_x; v[3] = d[1].y - view->scroll_y; + + gdk_draw_rectangle (GTK_WIDGET(view)->window, + GTK_WIDGET(view)->style->black_gc, + TRUE, + v[0], + v[1], + v[2]-v[0], + v[3]-v[1]); + } + +} + static void handle_form_field_over_xy (EvView *view, gint x, gint y) { @@ -5569,7 +5659,7 @@ } static void -ev_view_put (EvView *view, GtkWidget *widget, EvViewChildInfo *info, gint x, gint y, double x1, double y1, double x2, double y2, gint page, int id) +ev_view_put (EvView *view, GtkWidget *widget, EvViewChildInfo *info, gint x, gint y, double x1, double y1, double x2, double y2, gint page, int id, gboolean committed) { EvViewChild *child; @@ -5586,7 +5676,7 @@ child->p[1].y = y2; child->page = page; child->field_id = id; - child->committed = FALSE; + child->committed = committed; view->childs = g_list_append(view->childs, child); Index: shell/ev-view.h =================================================================== --- shell/ev-view.h (revision 2369) +++ shell/ev-view.h (working copy) @@ -146,6 +146,9 @@ gboolean ev_view_previous_page (EvView *view); gchar* ev_view_page_label_from_dest (EvView *view, EvLinkDest *dest); +/* Form */ +void ev_view_toggle_highlight_fields (EvView *view); + G_END_DECLS #endif /* __EV_VIEW_H__ */ Index: shell/Makefile.am =================================================================== --- shell/Makefile.am (revision 2369) +++ shell/Makefile.am (working copy) @@ -27,6 +27,8 @@ eggfindbar.h \ ev-application.c \ ev-application.h \ + ev-entry.c \ + ev-entry.h \ ev-job-queue.h \ ev-job-queue.c \ ev-jobs.h \ @@ -35,6 +37,8 @@ ev-history.h \ ev-marshal.c \ ev-marshal.h \ + ev-message-area.h \ + ev-message-area.c \ ev-metadata-manager.c \ ev-metadata-manager.h \ ev-navigation-action.c \