[evince/wip/highlight: 12/16] libview: Track page of the annot being added



commit b136ec8cb283a078e5bd4e8636d4d2e5db908d64
Author: José Aliste <jaliste src gnome org>
Date:   Tue Sep 9 21:16:39 2014 -0300

    libview: Track page of the annot being added
    
    Currently we assume that the annot is added to the current_page.
    This is not necessarilly true with dual or continuous modes.
    Thus, we track the page in the ActiveAnnotInfo struct.

 libview/ev-view-private.h |    1 +
 libview/ev-view.c         |   21 +++++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index c193d67..fee0fd6 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -126,6 +126,7 @@ typedef struct {
        AnnotationModeType mode;
        EvAnnotationType   type;
        EvAnnotation      *annot;
+       gint               page;
 } ActiveAnnotInfo;
 
 struct _EvView {
diff --git a/libview/ev-view.c b/libview/ev-view.c
index dc87f0d..df437ba 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -138,6 +138,13 @@ static EvFormField *ev_view_get_form_field_at_location       (EvView
                                                               gdouble            x,
                                                               gdouble            y);
 
+static gboolean
+get_selection_page_range (EvView          *view,
+                          GdkPoint        *start,
+                          GdkPoint        *stop,
+                          gint            *first_page,
+                          gint            *last_page);
+
 /*** Annotations ***/
 static EvAnnotation *ev_view_get_annotation_at_location      (EvView             *view,
                                                              gdouble             x,
@@ -3188,14 +3195,14 @@ ev_view_create_annotation (EvView          *view,
 
        g_assert (view->annot_info.mode == MODE_ADD);
 
-       ev_view_get_page_extents (view, view->current_page, &page_area, &border);
+       ev_view_get_page_extents (view, view->annot_info.page, &page_area, &border);
        _ev_view_transform_view_point_to_doc_point (view, &view->annot_info.start, &page_area, &border,
                                                    &begin.x, &begin.y);
        _ev_view_transform_view_point_to_doc_point (view, &view->annot_info.stop, &page_area, &border,
                                                    &end.x, &end.y);
 
        ev_document_doc_mutex_lock ();
-       page = ev_document_get_page (view->document, view->current_page);
+       page = ev_document_get_page (view->document, view->annot_info.page);
        switch (annot_type) {
        case EV_ANNOTATION_TYPE_TEXT: {
                doc_rect.x1 = begin.x;
@@ -4869,9 +4876,13 @@ ev_view_button_press_event (GtkWidget      *widget,
                                view->image_dnd_info.start.x = event->x + view->scroll_x;
                                view->image_dnd_info.start.y = event->y + view->scroll_y;
                        } else if (view->annot_info.mode == MODE_ADD) {
+                               gint last;
                                view->annot_info.start.x = event->x + view->scroll_x;
                                view->annot_info.start.y = event->y + view->scroll_y;
                                view->annot_info.stop = view->annot_info.start;
+                               get_selection_page_range (view, &view->annot_info.start,
+                                                         &view->annot_info.start, 
+                                                         &view->annot_info.page, &last);
                                ev_view_create_annotation (view, view->annot_info.type);
 
                                switch (view->annot_info.type) {
@@ -5220,7 +5231,7 @@ ev_view_motion_notify_event (GtkWidget      *widget,
                        view->annot_info.stop.x = event->x + view->scroll_x;
                        view->annot_info.stop.y = event->y + view->scroll_y;
 
-                       ev_view_get_page_extents (view, view->current_page, &page_area, &border);
+                       ev_view_get_page_extents (view, view->annot_info.page, &page_area, &border);
                        _ev_view_transform_view_point_to_doc_point (view, &view->annot_info.start, 
&page_area, &border,
                                                                    &begin.x, &begin.y);
                        _ev_view_transform_view_point_to_doc_point (view, &view->annot_info.stop, &page_area, 
&border,
@@ -5362,7 +5373,6 @@ ev_view_button_release_event (GtkWidget      *widget,
                view->annot_info.mode = MODE_NORMAL;
                ev_view_handle_cursor_over_xy (view, event->x, event->y);
                view->pressed_button = -1;
-
                return FALSE;
        }
 
@@ -8443,7 +8453,6 @@ gdk_point_equal (GdkPoint *a,
 
 static gboolean
 get_selection_page_range (EvView          *view,
-                         EvSelectionStyle style,
                          GdkPoint        *start,
                          GdkPoint        *stop,
                          gint            *first_page,
@@ -8508,7 +8517,7 @@ compute_new_selection (EvView          *view,
        GList *list = NULL;
 
        /* First figure out the range of pages the selection affects. */
-       if (!get_selection_page_range (view, style, start, stop, &first, &last))
+       if (!get_selection_page_range (view,  start, stop, &first, &last))
                return list;
 
        /* Now create a list of EvViewSelection's for the affected


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]