- EvPageCache *page_cache;
- EvPageThumbsInfo *thumb_info;
- EvRenderContext *rc = NULL;
- gint i, n_pages;
-
- page_cache = (EvPageCache *) g_object_new (EV_TYPE_PAGE_CACHE, NULL);
- page_cache->document = document;
-
- n_pages = ev_document_get_n_pages (document);
-
- build_height_to_page (page_cache);
-
- if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
- if (n_pages > 0)
- ev_page_cache_set_current_page (page_cache, 0);
- return page_cache;
- }
-
- /* Assume all pages are the same size until proven otherwise */
- page_cache->thumbs_uniform = TRUE;
-
- for (i = 0; i < n_pages; i++) {
- EvPage *page;
- gdouble page_width, page_height;
- gint thumb_width = 0;
- gint thumb_height = 0;
-
- page = ev_document_get_page (document, i);
-
- ev_document_get_page_size (document, i, &page_width, &page_height);
-
- if (!rc) {
- rc = ev_render_context_new (page, 0, (gdouble)THUMBNAIL_WIDTH / page_width);
- } else {
- ev_render_context_set_page (rc, page);
- ev_render_context_set_scale (rc, (gdouble)THUMBNAIL_WIDTH / page_width);
- }
-
- ev_document_thumbnails_get_dimensions (EV_DOCUMENT_THUMBNAILS (document),
- rc, &thumb_width, &thumb_height);
-
- if (thumb_width > page_cache->thumbs_max_width) {
- page_cache->thumbs_max_width = thumb_width;
- }