+ } else {
+ gint i;
+ EvDocumentPrivate *priv = document->priv;
+
+ /* Cache some info about the document to avoid
+ * going to the backends since it requires locks
+ */
+ priv->uri = g_strdup (uri);
+ priv->n_pages = _ev_document_get_n_pages (document);
+
+ for (i = 0; i < priv->n_pages; i++) {
+ EvPage *page = ev_document_get_page (document, i);
+ gdouble page_width = 0;
+ gdouble page_height = 0;
+ EvPageSize *page_size;
+ gchar *page_label;
+
+ _ev_document_get_page_size (document, page, &page_width, &page_height);
+
+ if (i == 0) {
+ priv->uniform_width = page_width;
+ priv->uniform_height = page_height;
+ priv->max_width = priv->uniform_width;
+ priv->max_height = priv->uniform_height;
+ priv->min_width = priv->uniform_width;
+ priv->min_height = priv->uniform_height;
+ } else if (priv->uniform &&
+ (priv->uniform_width != page_width ||
+ priv->uniform_height != page_height)) {
+ /* It's a different page size. Backfill the array. */
+ int j;
+
+ priv->page_sizes = g_new0 (EvPageSize, priv->n_pages);
+
+ for (j = 0; j < i; j++) {
+ page_size = &(priv->page_sizes[j]);
+ page_size->width = priv->uniform_width;
+ page_size->height = priv->uniform_height;
+ }
+ priv->uniform = FALSE;
+ }
+ if (!priv->uniform) {
+ page_size = &(priv->page_sizes[i]);
+
+ page_size->width = page_width;
+ page_size->height = page_height;
+
+ if (page_width > priv->max_width)
+ priv->max_width = page_width;
+ if (page_width < priv->min_width)
+ priv->min_width = page_width;
+
+ if (page_height > priv->max_height)
+ priv->max_height = page_height;
+ if (page_height < priv->min_height)
+ priv->min_height = page_height;
+ }
+
+ page_label = _ev_document_get_page_label (document, page);
+ if (page_label) {
+ if (!priv->page_labels)
+ priv->page_labels = g_new0 (gchar *, priv->n_pages);
+
+ priv->page_labels[i] = page_label;
+ priv->max_label = MAX (priv->max_label,
+ g_utf8_strlen (page_label, 256));
+ }
+
+ g_object_unref (page);
+ }
+
+ priv->info = _ev_document_get_info (document);
+ if (_ev_document_support_synctex (document)) {
+ gchar *filename;
+
+ filename = g_filename_from_uri (uri, NULL, NULL);
+ if (filename != NULL) {
+ priv->synctex_scanner =
+ synctex_scanner_new_with_output_file (filename, NULL, 1);
+ g_free (filename);
+ }
+ }