+static void
+ev_view_get_offsets (EvView *view, int *x_offset, int *y_offset)
+{
+ EvDocument *document = view->document;
+ GtkWidget *widget = GTK_WIDGET (view);
+ int width, height, target_width, target_height;
+ GtkBorder border;
+
+ g_return_if_fail (EV_IS_DOCUMENT (document));
+
+ ev_document_get_page_size (document, -1, &width, &height);
+ ev_document_misc_get_page_border_size (width, height, &border);
+
+ *x_offset = view->spacing;
+ *y_offset = view->spacing;
+ target_width = width + border.left + border.right + view->spacing * 2;
+ target_height = height + border.top + border.bottom + view->spacing * 2;
+ *x_offset += MAX (0, (widget->allocation.width - target_width) / 2);
+ *y_offset += MAX (0, (widget->allocation.height - target_height) / 2);
+}
+