+ g_object_notify (G_OBJECT (view), "continuous");
+}
+
+void
+ev_view_set_dual_page (EvView *view,
+ gboolean dual_page)
+{
+ g_return_if_fail (EV_IS_VIEW (view));
+
+ dual_page = dual_page != FALSE;
+
+ if (view->dual_page == dual_page)
+ return;
+
+ view->pending_scroll = SCROLL_TO_CURRENT_PAGE;
+ view->dual_page = dual_page;
+ /* FIXME: if we're keeping the pixbuf cache around, we should extend the
+ * preload_cache_size to be 2 if dual_page is set.
+ */
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+
+ g_object_notify (G_OBJECT (view), "dual-page");
+}
+
+void
+ev_view_set_fullscreen (EvView *view,
+ gboolean fullscreen)
+{
+ g_return_if_fail (EV_IS_VIEW (view));
+
+ fullscreen = fullscreen != FALSE;
+
+ if (view->fullscreen != fullscreen) {
+ view->fullscreen = fullscreen;
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+ }
+
+ g_object_notify (G_OBJECT (view), "fullscreen");
+}
+
+gboolean
+ev_view_get_fullscreen (EvView *view)
+{
+ g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
+
+ return view->fullscreen;
+}
+
+void
+ev_view_set_presentation (EvView *view,
+ gboolean presentation)
+{
+ g_return_if_fail (EV_IS_VIEW (view));
+
+ presentation = presentation != FALSE;
+
+ if (view->presentation == presentation)
+ return;
+
+ view->presentation = presentation;
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+ if (GTK_WIDGET_REALIZED (view)) {
+ if (view->presentation)
+ gdk_window_set_background (GTK_WIDGET(view)->window,
+ >K_WIDGET (view)->style->black);
+ else
+ gdk_window_set_background (GTK_WIDGET(view)->window,
+ >K_WIDGET (view)->style->mid [GTK_STATE_NORMAL]);
+ }
+
+
+ g_object_notify (G_OBJECT (view), "presentation");
+}
+
+gboolean
+ev_view_get_presentation (EvView *view)
+{
+ g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
+
+ return view->presentation;
+}
+
+void
+ev_view_set_sizing_mode (EvView *view,
+ EvSizingMode sizing_mode)
+{
+ g_return_if_fail (EV_IS_VIEW (view));
+
+ if (view->sizing_mode == sizing_mode)
+ return;
+
+ view->sizing_mode = sizing_mode;
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+
+ g_object_notify (G_OBJECT (view), "sizing-mode");
+}
+
+EvSizingMode
+ev_view_get_sizing_mode (EvView *view)
+{
+ g_return_val_if_fail (EV_IS_VIEW (view), EV_SIZING_FREE);
+
+ return view->sizing_mode;
+}
+
+gboolean
+ev_view_can_zoom_in (EvView *view)
+{
+ return view->scale * ZOOM_IN_FACTOR <= MAX_SCALE;
+}
+
+gboolean
+ev_view_can_zoom_out (EvView *view)
+{
+ return view->scale * ZOOM_OUT_FACTOR >= MIN_SCALE;
+}
+
+void
+ev_view_zoom_in (EvView *view)
+{
+ g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
+
+ view->pending_scroll = SCROLL_TO_CENTER;
+ ev_view_set_zoom (view, ZOOM_IN_FACTOR, TRUE);
+}
+
+void
+ev_view_zoom_out (EvView *view)
+{
+ g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
+
+ view->pending_scroll = SCROLL_TO_CENTER;
+ ev_view_set_zoom (view, ZOOM_OUT_FACTOR, TRUE);
+}
+
+static void
+ev_view_set_orientation (EvView *view,
+ EvOrientation orientation)
+{
+ ev_document_set_orientation (view->document, orientation);
+
+ clear_caches (view);
+ setup_caches (view);
+
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+}
+
+void
+ev_view_rotate_right (EvView *view)
+{
+ EvOrientation orientation, new_orientation;
+
+ orientation = ev_document_get_orientation (view->document);
+ if (orientation == EV_ORIENTATION_PORTRAIT) {
+ new_orientation = EV_ORIENTATION_LANDSCAPE;
+ } else if (orientation == EV_ORIENTATION_LANDSCAPE) {
+ new_orientation = EV_ORIENTATION_UPSIDEDOWN;
+ } else if (orientation == EV_ORIENTATION_UPSIDEDOWN) {
+ new_orientation = EV_ORIENTATION_SEASCAPE;
+ } else {
+ new_orientation = EV_ORIENTATION_PORTRAIT;
+ }
+ ev_view_set_orientation (view, new_orientation);
+}
+
+void
+ev_view_rotate_left (EvView *view)
+{
+ EvOrientation orientation, new_orientation;
+
+ orientation = ev_document_get_orientation (view->document);
+ if (orientation == EV_ORIENTATION_PORTRAIT) {
+ new_orientation = EV_ORIENTATION_SEASCAPE;
+ } else if (orientation == EV_ORIENTATION_SEASCAPE) {
+ new_orientation = EV_ORIENTATION_UPSIDEDOWN;
+ } else if (orientation == EV_ORIENTATION_UPSIDEDOWN) {
+ new_orientation = EV_ORIENTATION_LANDSCAPE;
+ } else {
+ new_orientation = EV_ORIENTATION_PORTRAIT;
+ }
+ ev_view_set_orientation (view, new_orientation);
+}
+
+static double
+zoom_for_size_fit_width (int doc_width,
+ int doc_height,
+ int target_width,
+ int target_height,
+ int vsb_width)
+{
+ double scale;
+
+ scale = (double)target_width / doc_width;
+
+ if (doc_height * scale > target_height)
+ scale = (double) (target_width - vsb_width) / doc_width;
+
+ return scale;
+}
+
+static double
+zoom_for_size_best_fit (int doc_width,
+ int doc_height,
+ int target_width,
+ int target_height,
+ int vsb_width,
+ int hsb_width)
+{
+ double w_scale;
+ double h_scale;
+
+ w_scale = (double)target_width / doc_width;
+ h_scale = (double)target_height / doc_height;
+
+ if (doc_height * w_scale > target_height)
+ w_scale = (double) (target_width - vsb_width) / doc_width;
+ if (doc_width * h_scale > target_width)
+ h_scale = (double) (target_height - hsb_width) / doc_height;
+
+ return MIN (w_scale, h_scale);
+}
+
+
+static void
+ev_view_zoom_for_size_presentation (EvView *view,
+ int width,
+ int height)
+{
+ int doc_width, doc_height;
+ gdouble scale;
+
+ ev_page_cache_get_size (view->page_cache,
+ view->current_page,
+ 1.0,
+ &doc_width,
+ &doc_height);
+ scale = zoom_for_size_best_fit (doc_width, doc_height, width, height, 0, 0);
+ ev_view_set_zoom (view, scale, FALSE);
+}
+
+static void
+ev_view_zoom_for_size_continuous_and_dual_page (EvView *view,
+ int width,
+ int height,
+ int vsb_width,
+ int hsb_height)
+{
+ int doc_width, doc_height;
+ GtkBorder border;
+ gdouble scale;
+
+ ev_page_cache_get_max_width (view->page_cache,
+ 1.0,
+ &doc_width);
+ ev_page_cache_get_max_height (view->page_cache,
+ 1.0,
+ &doc_height);
+ compute_border (view, doc_width, doc_height, &border);
+
+ doc_width = doc_width * 2;
+ width -= (2 * (border.left + border.right) + 3 * view->spacing);
+ height -= (border.top + border.bottom + 2 * view->spacing - 1);
+
+ /* FIXME: We really need to calculate the overall height here, not the
+ * page height. We assume there's always a vertical scrollbar for
+ * now. We need to fix this. */
+ if (view->sizing_mode == EV_SIZING_FIT_WIDTH)
+ scale = zoom_for_size_fit_width (doc_width, doc_height, width - vsb_width, height, 0);
+ else if (view->sizing_mode == EV_SIZING_BEST_FIT)
+ scale = zoom_for_size_best_fit (doc_width, doc_height, width - vsb_width, height, 0, hsb_height);
+ else
+ g_assert_not_reached ();