[evince] libview: Fix shift+click text selection



commit 7cf4c80ca4cc81f1f9b2984309c2f20d2087d2f8
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Apr 14 11:12:14 2014 -0400

    libview: Fix shift+click text selection
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728189

 libview/ev-view.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index acd9890..1bd2af7 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -269,6 +269,9 @@ static void       compute_selections                         (EvView
                                                              EvSelectionStyle    style,
                                                              GdkPoint           *start,
                                                              GdkPoint           *stop);
+static void       extend_selection                           (EvView             *view,
+                                                             GdkPoint           *start,
+                                                             GdkPoint           *stop);
 static void       clear_selection                            (EvView             *view);
 static void       clear_link_selected                        (EvView             *view);
 static void       selection_free                             (EvViewSelection    *selection);
@@ -4662,6 +4665,12 @@ ev_view_button_press_event (GtkWidget      *widget,
                        if (EV_IS_SELECTION (view->document) && view->selection_info.selections) {
                                if (event->type == GDK_3BUTTON_PRESS) {
                                        start_selection_for_event (view, event);
+                               } else if (event->state & GDK_SHIFT_MASK) {
+                                       GdkPoint end_point;
+
+                                       end_point.x = event->x + view->scroll_x;
+                                       end_point.y = event->y + view->scroll_y;
+                                       extend_selection (view, &view->selection_info.start, &end_point);
                                } else if (location_in_selected_text (view,
                                                               event->x + view->scroll_x,
                                                               event->y + view->scroll_y)) {
@@ -5503,9 +5512,9 @@ cursor_forward_line (EvView *view)
 }
 
 static void
-extend_selection_from_cursor (EvView *view,
-                             GdkPoint *start_point,
-                             GdkPoint *end_point)
+extend_selection (EvView *view,
+                 GdkPoint *start_point,
+                 GdkPoint *end_point)
 {
        if (!view->selection_info.selections) {
                view->selection_info.start.x = start_point->x;
@@ -5555,7 +5564,7 @@ static gboolean
 ev_view_move_cursor (EvView         *view,
                     GtkMovementStep step,
                     gint            count,
-                    gboolean        extend_selection)
+                    gboolean        extend_selections)
 {
        GdkRectangle    rect;
        GdkRectangle    prev_rect;
@@ -5573,7 +5582,7 @@ ev_view_move_cursor (EvView         *view,
        prev_offset = view->cursor_offset;
        prev_page = view->cursor_page;
 
-       clear_selections = !extend_selection && view->selection_info.selections != NULL;
+       clear_selections = !extend_selections && view->selection_info.selections != NULL;
 
        switch (step) {
        case GTK_MOVEMENT_VISUAL_POSITIONS:
@@ -5664,7 +5673,7 @@ ev_view_move_cursor (EvView         *view,
        cairo_region_destroy (damage_region);
 
        /* Select text */
-       if (extend_selection && EV_IS_SELECTION (view->document)) {
+       if (extend_selections && EV_IS_SELECTION (view->document)) {
                GdkPoint start_point, end_point;
 
                start_point.x = prev_rect.x + view->scroll_x;
@@ -5673,7 +5682,7 @@ ev_view_move_cursor (EvView         *view,
                end_point.x = rect.x;
                end_point.y = rect.y + rect.height / 2;
 
-               extend_selection_from_cursor (view, &start_point, &end_point);
+               extend_selection (view, &start_point, &end_point);
        } else if (clear_selections)
                clear_selection (view);
 


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