+ if (view->sizing_mode == EV_SIZING_FIT_WIDTH ||
+ view->sizing_mode == EV_SIZING_BEST_FIT) {
+ GtkRequisition req;
+
+ ev_view_zoom_for_size (view,
+ allocation->width,
+ allocation->height);
+ view->internal_size_request = TRUE;
+ ev_view_size_request (widget, &req);
+ view->internal_size_request = FALSE;
+ }
+
+ view_set_adjustment_values (view, GTK_ORIENTATION_HORIZONTAL);
+ view_set_adjustment_values (view, GTK_ORIENTATION_VERTICAL);
+
+ if (view->document)
+ view_update_range_and_current_page (view);
+
+ view->pending_scroll = SCROLL_TO_KEEP_POSITION;
+ view->pending_resize = FALSE;
+ view->pending_point.x = 0;
+ view->pending_point.y = 0;
+
+ children = gtk_container_get_children (GTK_CONTAINER (widget));
+ for (l = children; l && l->data; l = g_list_next (l)) {
+ EvFormField *field;
+ GdkRectangle view_area;
+ EvMappingList *form_field_mapping;
+ GtkAllocation child_allocation;
+ GtkRequisition child_requisition;
+ GtkWidget *child = (GtkWidget *)l->data;
+
+ field = g_object_get_data (G_OBJECT (child), "form-field");
+ if (!field)
+ continue;
+
+ form_field_mapping = ev_page_cache_get_form_field_mapping (view->page_cache,
+ field->page->index);
+ 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 ||
+ child_requisition.height != view_area.height)
+ gtk_widget_set_size_request (child, view_area.width, view_area.height);
+
+ gtk_container_child_get (GTK_CONTAINER (widget),
+ child,
+ "x", &child_allocation.x,
+ "y", &child_allocation.y,
+ NULL);
+ if (child_allocation.x != view_area.x ||
+ child_allocation.y != view_area.y) {
+ gtk_layout_move (GTK_LAYOUT (widget), child, view_area.x, view_area.y);
+ }
+ }
+ g_list_free (children);
+
+ if (view->window_children)
+ gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (view)),
+ &root_x, &root_y);
+
+ for (l = view->window_children; l && l->data; l = g_list_next (l)) {
+ EvViewWindowChild *child;
+ EvRectangle doc_rect;
+ GdkRectangle view_rect;
+
+ child = (EvViewWindowChild *)l->data;
+
+ ev_annotation_window_get_rectangle (EV_ANNOTATION_WINDOW (child->window), &doc_rect);
+ if (child->moved) {
+ doc_rect.x1 = child->orig_x;
+ doc_rect.y1 = child->orig_y;
+ }
+ doc_rect_to_view_rect (view, child->page, &doc_rect, &view_rect);
+ view_rect.x -= view->scroll_x;
+ view_rect.y -= view->scroll_y;
+
+ if (view_rect.x != child->orig_x || view_rect.y != child->orig_y) {
+ child->parent_x = root_x;
+ child->parent_y = root_y;
+ ev_view_window_child_move (view, child, view_rect.x + root_x, view_rect.y + root_y);
+ }
+ }
+}
+
+static void
+ev_view_realize (GtkWidget *widget)
+{
+ EvView *view = EV_VIEW (widget);
+ GdkWindow *bin_window;
+ GtkStyle *style;
+
+ if (GTK_WIDGET_CLASS (ev_view_parent_class)->realize)
+ (* GTK_WIDGET_CLASS (ev_view_parent_class)->realize) (widget);
+
+ bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
+ gdk_window_set_events (bin_window,
+ (gdk_window_get_events (bin_window) |
+ GDK_EXPOSURE_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_SCROLL_MASK |
+ GDK_KEY_PRESS_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK));
+
+ style = gtk_widget_get_style (widget);
+ gdk_window_set_background (bin_window, &style->mid[GTK_STATE_NORMAL]);
+
+ on_adjustment_value_changed (NULL, view);
+}
+
+static gboolean
+ev_view_scroll_event (GtkWidget *widget, GdkEventScroll *event)
+{
+ EvView *view = EV_VIEW (widget);
+ guint state;
+
+ state = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ if (state == GDK_CONTROL_MASK) {
+ ev_document_model_set_sizing_mode (view->model, EV_SIZING_FREE);
+ if (event->direction == GDK_SCROLL_UP ||
+ event->direction == GDK_SCROLL_LEFT) {
+ if (ev_view_can_zoom_in (view)) {
+ ev_view_zoom_in (view);
+ }
+ } else {
+ if (ev_view_can_zoom_out (view)) {
+ ev_view_zoom_out (view);
+ }
+ }
+
+ return TRUE;
+ }
+
+ 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;
+ else if (event->direction == GDK_SCROLL_LEFT)
+ event->direction = GDK_SCROLL_UP;
+ else if (event->direction == GDK_SCROLL_DOWN)
+ event->direction = GDK_SCROLL_RIGHT;
+ else if (event->direction == GDK_SCROLL_RIGHT)
+ event->direction = GDK_SCROLL_DOWN;
+
+ event->state &= ~GDK_SHIFT_MASK;
+ state &= ~GDK_SHIFT_MASK;
+ }
+
+ if (state == 0 && view->sizing_mode == EV_SIZING_BEST_FIT && !view->continuous) {
+ switch (event->direction) {
+ case GDK_SCROLL_DOWN:
+ case GDK_SCROLL_RIGHT:
+ ev_view_next_page (view);
+ break;
+ case GDK_SCROLL_UP:
+ case GDK_SCROLL_LEFT:
+ ev_view_previous_page (view);
+ break;
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static EvViewSelection *
+find_selection_for_page (EvView *view,
+ gint page)
+{
+ GList *list;
+
+ for (list = view->selection_info.selections; list != NULL; list = list->next) {
+ EvViewSelection *selection;