X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libview%2Fev-view.c;h=613236319dc4aa4d4fefbd35b068434289686867;hb=7b5e14ea3df691578a091c563be0081ff850a367;hp=a3ac91ec3f51d57250212d817ef27d8b32d1a4af;hpb=b1e91476f3aa8b27086242c915a4f8b1c9ba1e7c;p=evince.git diff --git a/libview/ev-view.c b/libview/ev-view.c index a3ac91ec..61323631 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -28,6 +28,7 @@ #include #include +#include "ev-mapping.h" #include "ev-document-forms.h" #include "ev-document-images.h" #include "ev-document-links.h" @@ -520,14 +521,14 @@ view_update_range_and_current_page (EvView *view) for (i = end; i > view->end_page; i--) { hide_annotation_windows (view, i); } - - ev_pixbuf_cache_set_page_range (view->pixbuf_cache, - view->start_page, - view->end_page, - view->rotation, - view->scale, - view->selection_info.selections); } + + ev_pixbuf_cache_set_page_range (view->pixbuf_cache, + view->start_page, + view->end_page, + view->rotation, + view->scale, + view->selection_info.selections); } static void @@ -1116,6 +1117,41 @@ get_doc_point_from_offset (EvView *view, return TRUE; } +static gboolean +get_doc_point_from_location (EvView *view, + gdouble x, + gdouble y, + gint *page, + gint *x_new, + gint *y_new) +{ + gint x_offset = 0, y_offset = 0; + + x += view->scroll_x; + y += view->scroll_y; + find_page_at_location (view, x, y, page, &x_offset, &y_offset); + if (*page == -1) + return FALSE; + + return get_doc_point_from_offset (view, *page, x_offset, y_offset, x_new, y_new); +} + +static void +ev_view_get_area_from_mapping (EvView *view, + guint page, + GList *mapping_list, + gconstpointer data, + GdkRectangle *area) +{ + EvMapping *mapping; + + mapping = ev_mapping_list_find (mapping_list, data); + doc_rect_to_view_rect (view, page, &mapping->area, area); + area->x -= view->scroll_x; + area->y -= view->scroll_y; +} + + /*** Hyperref ***/ static EvLink * ev_view_get_link_at_location (EvView *view, @@ -1123,30 +1159,19 @@ ev_view_get_link_at_location (EvView *view, gdouble y) { gint page = -1; - gint x_offset = 0, y_offset = 0; gint x_new = 0, y_new = 0; GList *link_mapping; if (!EV_IS_DOCUMENT_LINKS (view->document)) return NULL; - - 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; - - - if (get_doc_point_from_offset (view, page, x_offset, - y_offset, &x_new, &y_new) == FALSE) + if (!get_doc_point_from_location (view, x, y, &page, &x_new, &y_new)) return NULL; link_mapping = ev_pixbuf_cache_get_link_mapping (view->pixbuf_cache, page); if (link_mapping) - return ev_link_mapping_find (link_mapping, x_new, y_new); + return ev_mapping_list_get_data (link_mapping, x_new, y_new); else return NULL; } @@ -1567,29 +1592,19 @@ ev_view_get_image_at_location (EvView *view, gdouble y) { gint page = -1; - gint x_offset = 0, y_offset = 0; gint x_new = 0, y_new = 0; GList *image_mapping; if (!EV_IS_DOCUMENT_IMAGES (view->document)) return NULL; - 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; - - if (get_doc_point_from_offset (view, page, x_offset, - y_offset, &x_new, &y_new) == FALSE) + if (!get_doc_point_from_location (view, x, y, &page, &x_new, &y_new)) return NULL; image_mapping = ev_pixbuf_cache_get_image_mapping (view->pixbuf_cache, page); if (image_mapping) - return ev_image_mapping_find (image_mapping, x_new, y_new); + return ev_mapping_list_get_data (image_mapping, x_new, y_new); else return NULL; } @@ -1601,29 +1616,19 @@ ev_view_get_form_field_at_location (EvView *view, gdouble y) { gint page = -1; - gint x_offset = 0, y_offset = 0; gint x_new = 0, y_new = 0; GList *forms_mapping; if (!EV_IS_DOCUMENT_FORMS (view->document)) return NULL; - 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; - - if (get_doc_point_from_offset (view, page, x_offset, - y_offset, &x_new, &y_new) == FALSE) + if (!get_doc_point_from_location (view, x, y, &page, &x_new, &y_new)) return NULL; forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, page); if (forms_mapping) - return ev_form_field_mapping_find (forms_mapping, x_new, y_new); + return ev_mapping_list_get_data (forms_mapping, x_new, y_new); else return NULL; } @@ -1632,16 +1637,14 @@ static GdkRegion * ev_view_form_field_get_region (EvView *view, EvFormField *field) { - EvRectangle field_area; GdkRectangle view_area; GList *forms_mapping; forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page->index); - ev_form_field_mapping_get_area (forms_mapping, field, &field_area); - doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area); - view_area.x -= view->scroll_x; - view_area.y -= view->scroll_y; + ev_view_get_area_from_mapping (view, field->page->index, + forms_mapping, + field, &view_area); return gdk_region_rectangle (&view_area); } @@ -1692,7 +1695,7 @@ ev_view_form_field_button_create_widget (EvView *view, forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page->index); for (l = forms_mapping; l; l = g_list_next (l)) { - EvFormField *button = ((EvFormFieldMapping *)(l->data))->field; + EvFormField *button = ((EvMapping *)(l->data))->data; GdkRegion *button_region; if (button->id == field->id) @@ -2050,7 +2053,6 @@ ev_view_handle_form_field (EvView *view, { GtkWidget *field_widget = NULL; GList *form_field_mapping; - EvRectangle field_area; GdkRectangle view_area; if (field->is_read_only) @@ -2075,11 +2077,9 @@ ev_view_handle_form_field (EvView *view, (GDestroyNotify)g_object_unref); form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page->index); - ev_form_field_mapping_get_area (form_field_mapping, field, &field_area); - - doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area); - view_area.x -= view->scroll_x; - view_area.y -= view->scroll_y; + ev_view_get_area_from_mapping (view, field->page->index, + form_field_mapping, + field, &view_area); gtk_layout_put (GTK_LAYOUT (view), field_widget, view_area.x, view_area.y); gtk_widget_show (field_widget); @@ -2303,19 +2303,20 @@ show_annotation_windows (EvView *view, annots = ev_pixbuf_cache_get_annots_mapping (view->pixbuf_cache, page); for (l = annots; l && l->data; l = g_list_next (l)) { - EvAnnotationMapping *annotation_mapping; - EvAnnotation *annot; - EvViewWindowChild *child; - GtkWidget *window; - EvRectangle *doc_rect; - GdkRectangle view_rect; + EvAnnotation *annot; + EvViewWindowChild *child; + GtkWidget *window; + EvRectangle *doc_rect; + GdkRectangle view_rect; - annotation_mapping = (EvAnnotationMapping *)l->data; - annot = annotation_mapping->annotation; + annot = ((EvMapping *)(l->data))->data; if (!EV_IS_ANNOTATION_MARKUP (annot)) continue; + if (!ev_annotation_markup_has_popup (EV_ANNOTATION_MARKUP (annot))) + continue; + window = g_object_get_data (G_OBJECT (annot), "popup"); if (window) { ev_view_window_child_move_with_parent (view, window); @@ -2367,12 +2368,10 @@ hide_annotation_windows (EvView *view, annots = ev_pixbuf_cache_get_annots_mapping (view->pixbuf_cache, page); for (l = annots; l && l->data; l = g_list_next (l)) { - EvAnnotationMapping *annotation_mapping; - EvAnnotation *annot; - GtkWidget *window; + EvAnnotation *annot; + GtkWidget *window; - annotation_mapping = (EvAnnotationMapping *)l->data; - annot = annotation_mapping->annotation; + annot = ((EvMapping *)(l->data))->data; if (!EV_IS_ANNOTATION_MARKUP (annot)) continue; @@ -2389,29 +2388,19 @@ ev_view_get_annotation_at_location (EvView *view, gdouble y) { gint page = -1; - gint x_offset = 0, y_offset = 0; gint x_new = 0, y_new = 0; GList *annotations_mapping; if (!EV_IS_DOCUMENT_ANNOTATIONS (view->document)) return NULL; - 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; - - if (get_doc_point_from_offset (view, page, x_offset, - y_offset, &x_new, &y_new) == FALSE) + if (!get_doc_point_from_location (view, x, y, &page, &x_new, &y_new)) return NULL; annotations_mapping = ev_pixbuf_cache_get_annots_mapping (view->pixbuf_cache, page); if (annotations_mapping) - return ev_annotation_mapping_find (annotations_mapping, x_new, y_new); + return ev_mapping_list_get_data (annotations_mapping, x_new, y_new); else return NULL; } @@ -2617,7 +2606,6 @@ ev_view_size_allocate (GtkWidget *widget, children = gtk_container_get_children (GTK_CONTAINER (widget)); for (l = children; l && l->data; l = g_list_next (l)) { EvFormField *field; - EvRectangle field_area; GdkRectangle view_area; GList *form_field_mapping; GtkAllocation child_allocation; @@ -2630,11 +2618,9 @@ ev_view_size_allocate (GtkWidget *widget, form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page->index); - ev_form_field_mapping_get_area (form_field_mapping, field, &field_area); - - doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area); - view_area.x -= view->scroll_x; - view_area.y -= view->scroll_y; + ev_view_get_area_from_mapping (view, field->page->index, + form_field_mapping, + field, &view_area); gtk_widget_size_request (child, &child_requisition); if (child_requisition.width != view_area.width || @@ -2951,10 +2937,9 @@ get_link_area (EvView *view, EvLink *link, GdkRectangle *area) { - EvRectangle ev_rect; - GList *link_mapping; - gint page; - gint x_offset = 0, y_offset = 0; + GList *link_mapping; + gint page; + gint x_offset = 0, y_offset = 0; x += view->scroll_x; y += view->scroll_y; @@ -2962,10 +2947,9 @@ get_link_area (EvView *view, find_page_at_location (view, x, y, &page, &x_offset, &y_offset); link_mapping = ev_pixbuf_cache_get_link_mapping (view->pixbuf_cache, page); - ev_link_mapping_get_area (link_mapping, link, &ev_rect); - - doc_rect_to_view_rect (view, page, &ev_rect, area); - area->y -= view->scroll_y; + ev_view_get_area_from_mapping (view, page, + link_mapping, + link, area); } static void @@ -2975,10 +2959,9 @@ get_annot_area (EvView *view, EvAnnotation *annot, GdkRectangle *area) { - EvRectangle ev_rect; - GList *annots_mapping; - gint page; - gint x_offset = 0, y_offset = 0; + GList *annots_mapping; + gint page; + gint x_offset = 0, y_offset = 0; x += view->scroll_x; y += view->scroll_y; @@ -2986,10 +2969,9 @@ get_annot_area (EvView *view, find_page_at_location (view, x, y, &page, &x_offset, &y_offset); annots_mapping = ev_pixbuf_cache_get_annots_mapping (view->pixbuf_cache, page); - ev_annotation_mapping_get_area (annots_mapping, annot, &ev_rect); - - doc_rect_to_view_rect (view, page, &ev_rect, area); - area->y -= view->scroll_y; + ev_view_get_area_from_mapping (view, page, + annots_mapping, + annot, area); } static gboolean @@ -3036,26 +3018,28 @@ static void start_selection_for_event (EvView *view, GdkEventButton *event) { - EvSelectionStyle style; - clear_selection (view); - + view->selection_info.start.x = event->x + view->scroll_x; view->selection_info.start.y = event->y + view->scroll_y; switch (event->type) { case GDK_2BUTTON_PRESS: - style = EV_SELECTION_STYLE_WORD; + view->selection_info.style = EV_SELECTION_STYLE_WORD; break; case GDK_3BUTTON_PRESS: - style = EV_SELECTION_STYLE_LINE; + view->selection_info.style = EV_SELECTION_STYLE_LINE; break; default: - style = EV_SELECTION_STYLE_GLYPH; - break; + view->selection_info.style = EV_SELECTION_STYLE_GLYPH; + return; } - view->selection_info.style = style; + /* In case of WORD or LINE, compute selections now */ + compute_selections (view, + view->selection_info.style, + &(view->selection_info.start), + &(view->selection_info.start)); } static gboolean @@ -3538,14 +3522,6 @@ ev_view_button_release_event (GtkWidget *widget, view->selection_update_id = 0; } - if (!view->selection_info.in_selection && - view->selection_info.style != EV_SELECTION_STYLE_GLYPH) { - compute_selections (view, - view->selection_info.style, - &(view->selection_info.start), - &(view->selection_info.start)); - } - if (view->selection_info.selections) { clear_link_selected (view); ev_view_update_primary_selection (view); @@ -4646,10 +4622,14 @@ ev_view_presentation_animation_start (EvView *view, if (!effect) return; - surface = ev_pixbuf_cache_get_surface (view->pixbuf_cache, view->current_page); view->animation = ev_transition_animation_new (effect); + + surface = ev_pixbuf_cache_get_surface (view->pixbuf_cache, view->current_page); ev_transition_animation_set_origin_surface (view->animation, surface); - + surface = ev_pixbuf_cache_get_surface (view->pixbuf_cache, new_page); + if (surface) + ev_transition_animation_set_dest_surface (view->animation, surface); + g_signal_connect (view->animation, "frame", G_CALLBACK (ev_view_transition_animation_frame), view); g_signal_connect (view->animation, "finished", @@ -4892,6 +4872,8 @@ ev_view_set_document (EvView *view, setup_caches (view); } + view_update_range_and_current_page (view); + gtk_widget_queue_resize (GTK_WIDGET (view)); } }