X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-view.c;h=fa9fbd8dc65f9ab894e0bef07ee14268ce07bd98;hb=8fdc90f6d511cd854fdfdf4c5d7066a2bbe00c94;hp=0fd2834aeb6b03f89004eaf6d90259012be76709;hpb=1624d8ca4f26f53dcae3e2f122285d75fa003384;p=evince.git diff --git a/shell/ev-view.c b/shell/ev-view.c index 0fd2834a..fa9fbd8d 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -1575,7 +1575,8 @@ ev_view_handle_cursor_over_xy (EvView *view, gint x, gint y) } else { if (view->cursor == EV_VIEW_CURSOR_LINK || view->cursor == EV_VIEW_CURSOR_IBEAM || - view->cursor == EV_VIEW_CURSOR_DRAG) + view->cursor == EV_VIEW_CURSOR_DRAG || + view->cursor == EV_VIEW_CURSOR_AUTOSCROLL) ev_view_set_cursor (view, EV_VIEW_CURSOR_NORMAL); } } @@ -2385,15 +2386,16 @@ ev_view_scroll_event (GtkWidget *widget, GdkEventScroll *event) } view->jump_to_find_result = FALSE; + /* Shift+Wheel scrolls the in the perpendicular direction */ if (state & GDK_SHIFT_MASK) { if (event->direction == GDK_SCROLL_UP) event->direction = GDK_SCROLL_LEFT; - if (event->direction == GDK_SCROLL_LEFT) + else if (event->direction == GDK_SCROLL_LEFT) event->direction = GDK_SCROLL_UP; - if (event->direction == GDK_SCROLL_DOWN) + else if (event->direction == GDK_SCROLL_DOWN) event->direction = GDK_SCROLL_RIGHT; - if (event->direction == GDK_SCROLL_RIGHT) + else if (event->direction == GDK_SCROLL_RIGHT) event->direction = GDK_SCROLL_DOWN; event->state &= ~GDK_SHIFT_MASK; @@ -2686,15 +2688,12 @@ ev_view_button_press_event (GtkWidget *widget, view->pressed_button = event->button; view->selection_info.in_drag = FALSE; + + if (view->scroll_info.autoscrolling) + return TRUE; switch (event->button) { case 1: { - - if (view->scroll_info.autoscrolling == TRUE) { - view->scroll_info.autoscrolling = FALSE; - return TRUE; - } - EvImage *image; EvFormField *field; @@ -2733,10 +2732,6 @@ ev_view_button_press_event (GtkWidget *widget, case 2: /* use root coordinates as reference point because * scrolling changes window relative coordinates */ - if (view->scroll_info.autoscrolling == TRUE) { - view->scroll_info.autoscrolling = FALSE; - return TRUE; - } view->drag_info.start.x = event->x_root; view->drag_info.start.y = event->y_root; view->drag_info.hadj = gtk_adjustment_get_value (view->hadjustment); @@ -2746,8 +2741,7 @@ ev_view_button_press_event (GtkWidget *widget, return TRUE; case 3: - if (!view->scroll_info.autoscrolling) - view->scroll_info.start_y = event->y; + view->scroll_info.start_y = event->y; return ev_view_do_popup_menu (view, event->x, event->y); } @@ -2794,16 +2788,28 @@ ev_view_drag_data_get (GtkWidget *widget, if (view->image_dnd_info.image) { GdkPixbuf *pixbuf; - pixbuf = ev_image_get_pixbuf (view->image_dnd_info.image); + ev_document_doc_mutex_lock (); + pixbuf = ev_document_images_get_image (EV_DOCUMENT_IMAGES (view->document), + view->image_dnd_info.image); + ev_document_doc_mutex_unlock (); + gtk_selection_data_set_pixbuf (selection_data, pixbuf); + g_object_unref (pixbuf); } break; case TARGET_DND_URI: if (view->image_dnd_info.image) { + GdkPixbuf *pixbuf; const gchar *tmp_uri; gchar **uris; - tmp_uri = ev_image_save_tmp (view->image_dnd_info.image); + ev_document_doc_mutex_lock (); + pixbuf = ev_document_images_get_image (EV_DOCUMENT_IMAGES (view->document), + view->image_dnd_info.image); + ev_document_doc_mutex_unlock (); + + tmp_uri = ev_image_save_tmp (view->image_dnd_info.image, pixbuf); + g_object_unref (pixbuf); uris = g_new0 (gchar *, 2); uris[0] = (gchar *)tmp_uri; @@ -2992,6 +2998,7 @@ ev_view_motion_notify_event (GtkWidget *widget, if (view->scroll_info.autoscrolling) { view->scroll_info.last_y = y; + return TRUE; } if (view->selection_info.in_drag) { @@ -3125,19 +3132,30 @@ ev_view_button_release_event (GtkWidget *widget, EvView *view = EV_VIEW (widget); EvLink *link = NULL; - view->drag_info.in_drag = FALSE; view->image_dnd_info.in_drag = FALSE; - - view->drag_info.release_timeout_id = g_timeout_add (20, - (GSourceFunc)ev_view_scroll_drag_release, view); - if (view->pressed_button == 2) { - ev_view_handle_cursor_over_xy (view, event->x, event->y); + if (view->scroll_info.autoscrolling) { + ev_view_autoscroll_stop (view); + view->pressed_button = -1; + + return TRUE; + } + + if (view->drag_info.in_drag) { + view->drag_info.release_timeout_id = + g_timeout_add (20, + (GSourceFunc)ev_view_scroll_drag_release, view); } - if (view->document && view->pressed_button != 3) { + if (view->document && !view->drag_info.in_drag && view->pressed_button != 3) { link = ev_view_get_link_at_location (view, event->x, event->y); } + + view->drag_info.in_drag = FALSE; + + if (view->pressed_button == 2) { + ev_view_handle_cursor_over_xy (view, event->x, event->y); + } view->pressed_button = -1; @@ -4409,7 +4427,8 @@ ev_view_set_loading (EvView *view, gtk_widget_queue_draw (GTK_WIDGET (view)); } -static gboolean ev_view_autoscroll_cb (EvView *view) +static gboolean +ev_view_autoscroll_cb (EvView *view) { gdouble speed, value; @@ -4442,10 +4461,43 @@ static gboolean ev_view_autoscroll_cb (EvView *view) } -void ev_view_autoscroll(EvView *view) +void +ev_view_autoscroll_start (EvView *view) { + gint x, y; + + g_return_if_fail (EV_IS_VIEW (view)); + + if (view->scroll_info.autoscrolling) + return; + view->scroll_info.autoscrolling = TRUE; - view->scroll_info.timeout_id = g_timeout_add (20, (GSourceFunc)(ev_view_autoscroll_cb), view); + view->scroll_info.timeout_id = + g_timeout_add (20, (GSourceFunc)ev_view_autoscroll_cb, + view); + + gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y); + ev_view_handle_cursor_over_xy (view, x, y); +} + +void +ev_view_autoscroll_stop (EvView *view) +{ + gint x, y; + + g_return_if_fail (EV_IS_VIEW (view)); + + if (!view->scroll_info.autoscrolling) + return; + + view->scroll_info.autoscrolling = FALSE; + if (view->scroll_info.timeout_id) { + g_source_remove (view->scroll_info.timeout_id); + view->scroll_info.timeout_id = 0; + } + + gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y); + ev_view_handle_cursor_over_xy (view, x, y); } void