+2007-12-23 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * data/evince-toolbar.xml:
+ * data/evince-ui.xml:
+ * shell/ev-view-private.h:
+ * shell/ev-view.c: (ev_view_handle_cursor_over_xy),
+ (ev_view_button_press_event), (ev_view_motion_notify_event),
+ (ev_view_button_release_event), (ev_view_init),
+ (ev_view_autoscroll_cb), (ev_view_autoscroll),
+ (ev_view_set_cursor):
+ * shell/ev-view.h:
+ * shell/ev-window.c: (ev_window_setup_action_sensitivity),
+ (ev_window_cmd_view_autoscroll):
+
+ Autoscroll feature with the context menu. Fixes bug
+ #323670. Thanks to David Turner <cillian64@googlemail.com>.
+
2007-12-23 Carlos Garcia Campos <carlosgc@gnome.org>
* shell/ev-pixbuf-cache.c: (check_job_size_and_unref):
Disconnect also page-ready signal when removing a job because the
page size has changed. Thanks to kripken
<kripkensteiner@gmail.com>.
-
+
2007-12-21 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
* shell/ev-page-action.c: (page_scroll_cb), (create_tool_item):
ev_view_set_cursor (view, EV_VIEW_CURSOR_DRAG);
return;
}
+
+ if (view->scroll_info.autoscrolling) {
+ if (view->cursor != EV_VIEW_CURSOR_AUTOSCROLL)
+ ev_view_set_cursor (view, EV_VIEW_CURSOR_AUTOSCROLL);
+ return;
+ }
link = ev_view_get_link_at_location (view, x, y);
switch (event->button) {
case 1: {
+
+ if (view->scroll_info.autoscrolling == TRUE) {
+ view->scroll_info.autoscrolling = FALSE;
+ return TRUE;
+ }
+
EvImage *image;
EvFormField *field;
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);
return TRUE;
case 3:
+ if (!view->scroll_info.autoscrolling)
+ view->scroll_info.start_y = event->y;
return ev_view_do_popup_menu (view, event->x, event->y);
}
if (!view->document)
return FALSE;
+
if (event->is_hint || event->window != view->layout.bin_window) {
gtk_widget_get_pointer (widget, &x, &y);
y = event->y;
}
+ if (view->scroll_info.autoscrolling) {
+ view->scroll_info.last_y = y;
+ }
+
if (view->selection_info.in_drag) {
if (gtk_drag_check_threshold (widget,
view->selection_info.start.x,
g_source_remove (view->selection_scroll_id);
view->selection_scroll_id = 0;
}
+ if (view->scroll_info.timeout_id) {
+ g_source_remove (view->scroll_info.timeout_id);
+ view->scroll_info.timeout_id = 0;
+ }
if (view->selection_update_id) {
g_source_remove (view->selection_update_id);
view->selection_update_id = 0;
view->pressed_button = -1;
view->cursor = EV_VIEW_CURSOR_NORMAL;
view->drag_info.in_drag = FALSE;
+ view->scroll_info.autoscrolling = FALSE;
view->selection_info.selections = NULL;
view->selection_info.in_selection = FALSE;
view->selection_info.in_drag = FALSE;
gtk_widget_queue_draw (GTK_WIDGET (view));
}
+static gboolean ev_view_autoscroll_cb (EvView *view)
+{
+ gdouble speed, value;
+
+ /* If the user stops autoscrolling, autoscrolling will be
+ * set to false but the timeout will continue; stop the timeout: */
+ if (!view->scroll_info.autoscrolling) {
+ view->scroll_info.timeout_id = 0;
+ return FALSE;
+ }
+
+ if (view->scroll_info.last_y > view->scroll_info.start_y &&
+ (view->scroll_info.last_y < view->scroll_info.start_y))
+ return TRUE;
+
+ /* Replace 100 with your speed of choice: The lower the faster.
+ * Replace 3 with another speed of choice: The higher, the faster it accelerated
+ * based on the distance of the starting point from the mouse
+ * (All also effected by the timeout interval of this callback) */
+
+ if (view->scroll_info.start_y > view->scroll_info.last_y)
+ speed = -pow ((((gdouble)view->scroll_info.start_y - view->scroll_info.last_y) / 100), 3);
+ else
+ speed = pow ((((gdouble)view->scroll_info.last_y - view->scroll_info.start_y) / 100), 3);
+
+ value = gtk_adjustment_get_value (view->vadjustment);
+ value = CLAMP (value + speed, 0, view->vadjustment->upper - view->vadjustment->page_size);
+ gtk_adjustment_set_value (view->vadjustment, value);
+
+ return TRUE;
+
+}
+
+void ev_view_autoscroll(EvView *view)
+{
+ view->scroll_info.autoscrolling = TRUE;
+ view->scroll_info.timeout_id = g_timeout_add (20, (GSourceFunc)(ev_view_autoscroll_cb), view);
+}
+
void
ev_view_set_document (EvView *view,
EvDocument *document)
case EV_VIEW_CURSOR_DRAG:
cursor = gdk_cursor_new_for_display (display, GDK_FLEUR);
break;
+ case EV_VIEW_CURSOR_AUTOSCROLL:
+ cursor = gdk_cursor_new_for_display (display, GDK_DOUBLE_ARROW);
+ break;
}
if (cursor) {
ev_window_set_action_sensitive (ev_window, "ViewBestFit", has_pages);
ev_window_set_action_sensitive (ev_window, "ViewPageWidth", has_pages);
ev_window_set_action_sensitive (ev_window, "ViewReload", has_pages);
+ ev_window_set_action_sensitive (ev_window, "ViewAutoscroll", has_pages);
/* Toolbar-specific actions: */
ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
g_free (uri);
}
+static void
+ev_window_cmd_view_autoscroll (GtkAction *action, EvWindow *ev_window)
+{
+ ev_view_autoscroll (EV_VIEW (ev_window->priv->view));
+}
+
static void
ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
{
N_("Reload the document"),
G_CALLBACK (ev_window_cmd_view_reload) },
+ { "ViewAutoscroll", GTK_STOCK_MEDIA_PLAY, N_("Auto_scroll"), NULL, NULL,
+ G_CALLBACK (ev_window_cmd_view_autoscroll) },
+
/* Go menu */
{ "GoPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "<control>Page_Up",
N_("Go to the previous page"),