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=3d3c4a5a08f1b8b536542735110c1376fb3e30bf;hp=abd661e2732117d75aa1a792eacc4f6448e02b8e;hpb=8dbd7b00f71be8b78198b2c713ae071c2dd77d11;p=evince.git diff --git a/libview/ev-view.c b/libview/ev-view.c index abd661e2..61323631 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -1117,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, @@ -1124,24 +1159,13 @@ 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); @@ -1568,23 +1592,13 @@ 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); @@ -1602,23 +1616,13 @@ 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); @@ -1635,14 +1639,12 @@ ev_view_form_field_get_region (EvView *view, { GdkRectangle view_area; GList *forms_mapping; - EvMapping *mapping; forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page->index); - mapping = ev_mapping_list_find (forms_mapping, field); - doc_rect_to_view_rect (view, field->page->index, &mapping->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); } @@ -2051,7 +2053,6 @@ ev_view_handle_form_field (EvView *view, { GtkWidget *field_widget = NULL; GList *form_field_mapping; - EvMapping *mapping; GdkRectangle view_area; if (field->is_read_only) @@ -2076,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); - mapping = ev_mapping_list_find (form_field_mapping, field); - - doc_rect_to_view_rect (view, field->page->index, &mapping->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); @@ -2315,6 +2314,9 @@ show_annotation_windows (EvView *view, 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); @@ -2386,23 +2388,13 @@ 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); @@ -2616,7 +2608,6 @@ ev_view_size_allocate (GtkWidget *widget, EvFormField *field; GdkRectangle view_area; GList *form_field_mapping; - EvMapping *mapping; GtkAllocation child_allocation; GtkRequisition child_requisition; GtkWidget *child = (GtkWidget *)l->data; @@ -2627,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); - mapping = ev_mapping_list_find (form_field_mapping, field); - - doc_rect_to_view_rect (view, field->page->index, &mapping->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 || @@ -2948,10 +2937,9 @@ get_link_area (EvView *view, EvLink *link, GdkRectangle *area) { - GList *link_mapping; - EvMapping *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; @@ -2959,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); - mapping = ev_mapping_list_find (link_mapping, link); - - doc_rect_to_view_rect (view, page, &mapping->area, area); - area->y -= view->scroll_y; + ev_view_get_area_from_mapping (view, page, + link_mapping, + link, area); } static void @@ -2972,10 +2959,9 @@ get_annot_area (EvView *view, EvAnnotation *annot, GdkRectangle *area) { - GList *annots_mapping; - EvMapping *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; @@ -2983,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); - mapping = ev_mapping_list_find (annots_mapping, annot); - - doc_rect_to_view_rect (view, page, &mapping->area, area); - area->y -= view->scroll_y; + ev_view_get_area_from_mapping (view, page, + annots_mapping, + annot, area); } static gboolean @@ -3033,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 @@ -3535,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); @@ -4643,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",