+ /* Zoom */
+ if (ev_document_model_get_sizing_mode (window->priv->model) == EV_SIZING_FREE &&
+ ev_metadata_get_double (window->priv->metadata, "zoom", &zoom)) {
+ zoom *= get_screen_dpi (window) / 72.0;
+ ev_document_model_set_scale (window->priv->model, zoom);
+ }
+
+ /* Rotation */
+ if (ev_metadata_get_int (window->priv->metadata, "rotation", &rotation)) {
+ switch (rotation) {
+ case 90:
+ rotation = 90;
+ break;
+ case 180:
+ rotation = 180;
+ break;
+ case 270:
+ rotation = 270;
+ break;
+ default:
+ rotation = 0;
+ break;
+ }
+ ev_document_model_set_rotation (window->priv->model, rotation);
+ }
+
+ /* Inverted Colors */
+ if (ev_metadata_get_boolean (window->priv->metadata, "inverted-colors", &inverted_colors))
+ ev_document_model_set_inverted_colors (window->priv->model, inverted_colors);
+
+ /* Continuous */
+ if (ev_metadata_get_boolean (window->priv->metadata, "continuous", &continuous)) {
+ ev_document_model_set_continuous (window->priv->model, continuous);
+ }
+
+ /* Dual page */
+ if (ev_metadata_get_boolean (window->priv->metadata, "dual-page", &dual_page)) {
+ ev_document_model_set_dual_page (window->priv->model, dual_page);
+ }
+
+ /* Fullscreen */
+ if (ev_metadata_get_boolean (window->priv->metadata, "fullscreen", &fullscreen)) {
+ if (fullscreen) {
+ ev_window_run_fullscreen (window);
+ }
+ }
+}
+
+static void
+setup_document_from_metadata (EvWindow *window)
+{
+ gint page, n_pages;
+ gint width;
+ gint height;
+ gdouble width_ratio;
+ gdouble height_ratio;
+
+ if (window->priv->metadata) {
+ /* Make sure to not open a document on the last page,
+ * since closing it on the last page most likely means the
+ * user was finished reading the document. In that case, reopening should
+ * show the first page. */
+ page = ev_document_model_get_page (window->priv->model);
+ n_pages = ev_document_get_n_pages (window->priv->document);
+ if (page == n_pages - 1)
+ ev_document_model_set_page (window->priv->model, 0);
+
+ setup_sidebar_from_metadata (window);
+
+ if (ev_metadata_get_int (window->priv->metadata, "window_width", &width) &&
+ ev_metadata_get_int (window->priv->metadata, "window_height", &height))
+ return; /* size was already set in setup_size_from_metadata */
+ }
+
+ g_settings_get (window->priv->last_settings, "window-ratio", "(dd)", &width_ratio, &height_ratio);
+ if (width_ratio > 0. && height_ratio > 0.) {
+ gdouble document_width;
+ gdouble document_height;