+2008-04-14 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * libdocument/Makefile.am:
+ * libdocument/ev-page.[ch]:
+ * libdocument/ev-render-context.[ch]: (ev_render_context_dispose),
+ (ev_render_context_new), (ev_render_context_set_page):
+ * libdocument/ev-form-field.[ch]: (ev_form_field_init),
+ (ev_form_field_finalize), (ev_form_field_class_init):
+ * libdocument/ev-document-forms.[ch]:
+ (ev_document_forms_get_form_fields):
+ * libdocument/ev-document.[ch]: (ev_document_get_page),
+ (ev_document_get_page_size), (ev_document_get_page_label):
+ * shell/ev-jobs.[ch]: (ev_job_thumbnail_dispose),
+ (ev_job_render_run), (ev_job_thumbnail_new),
+ (ev_job_thumbnail_run), (ev_job_print_run):
+ * shell/ev-page-cache.c: (ev_page_cache_new):
+ * shell/ev-pixbuf-cache.c: (job_page_ready_cb), (job_finished_cb),
+ (check_job_size_and_unref), (add_job):
+ * shell/ev-sidebar-thumbnails.c: (add_range):
+ * shell/ev-view.c: (ev_view_form_field_get_region),
+ (ev_view_form_field_button_create_widget),
+ (ev_view_form_field_text_save), (ev_view_form_field_choice_save),
+ (ev_view_handle_form_field), (ev_view_size_allocate),
+ (get_selected_text):
+ * shell/ev-window.c: (ev_window_refresh_window_thumbnail):
+ * backend/pdf/ev-poppler.cc: (pdf_document_get_page_size),
+ (pdf_document_get_page), (pdf_document_get_page_label),
+ (pdf_document_render), (pdf_document_get_info),
+ (pdf_document_document_iface_init),
+ (pdf_document_thumbnails_get_thumbnail),
+ (pdf_document_thumbnails_get_dimensions),
+ (pdf_document_file_exporter_do_page),
+ (pdf_selection_render_selection),
+ (pdf_selection_get_selected_text),
+ (pdf_selection_get_selection_region),
+ (pdf_selection_get_selection_map),
+ (pdf_document_forms_get_form_fields),
+ (pdf_document_forms_form_field_text_get_text),
+ (pdf_document_forms_form_field_text_set_text),
+ (pdf_document_forms_form_field_button_set_state),
+ (pdf_document_forms_form_field_button_get_state),
+ (pdf_document_forms_form_field_choice_get_item),
+ (pdf_document_forms_form_field_choice_get_n_items),
+ (pdf_document_forms_form_field_choice_is_item_selected),
+ (pdf_document_forms_form_field_choice_select_item),
+ (pdf_document_forms_form_field_choice_toggle_item),
+ (pdf_document_forms_form_field_choice_unselect_all),
+ (pdf_document_forms_form_field_choice_set_text),
+ (pdf_document_forms_form_field_choice_get_text):
+ * backend/ps/ev-spectre.c: (ps_document_get_page),
+ (ps_document_get_page_size), (ps_document_get_page_label),
+ (ps_document_render), (ps_document_document_iface_init),
+ (ps_document_file_exporter_do_page):
+ * backend/tiff/tiff-document.c: (tiff_document_get_page_size),
+ (tiff_document_render), (tiff_document_render_pixbuf),
+ (tiff_document_file_exporter_do_page):
+ * backend/pixbuf/pixbuf-document.c:
+ (pixbuf_document_get_page_size):
+ * backend/comics/comics-document.c:
+ (comics_document_get_page_size), (comics_document_render_pixbuf):
+ * backend/djvu/djvu-document.c: (djvu_document_get_page_size),
+ (djvu_document_render), (djvu_selection_get_selected_text),
+ (djvu_document_thumbnails_get_thumbnail),
+ (djvu_document_file_exporter_do_page),
+ (djvu_document_find_get_result):
+ * backend/dvi/dvi-document.c: (dvi_document_get_page_size),
+ (dvi_document_render), (dvi_document_thumbnails_get_dimensions),
+ (dvi_document_thumbnails_get_thumbnail),
+ (dvi_document_file_exporter_do_page):
+ * backend/impress/impress-document.c:
+ (impress_document_get_page_size),
+ (impress_document_render_pixbuf):
+ * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get):
+
+ Add EvPage so that we can hold a reference to the backend
+ page. Form fields keep now a reference to the poppler page
+ improving performance since we don't have to create/destroy the
+ poppler field for every form operation. This will be needed for
+ annotations too.
+
2008-04-12 Carlos Garcia Campos <carlosgc@gnome.org>
* data/evince-ui.xml:
static void
comics_document_get_page_size (EvDocument *document,
- int page,
+ EvPage *page,
double *width,
double *height)
{
gint outpipe = -1;
GPid child_pid = -1;
- argv = extract_argv (document, page);
+ argv = extract_argv (document, page->index);
success = g_spawn_async_with_pipes (NULL, argv, NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
NULL, NULL,
gint outpipe = -1;
GPid child_pid = -1;
- argv = extract_argv (document, rc->page);
+ argv = extract_argv (document, rc->page->index);
success = g_spawn_async_with_pipes (NULL, argv, NULL,
G_SPAWN_SEARCH_PATH
| G_SPAWN_STDERR_TO_DEV_NULL,
}
static void
-djvu_document_get_page_size (EvDocument *document,
- int page,
- double *width,
- double *height)
+document_get_page_size (DjvuDocument *djvu_document,
+ gint page,
+ double *width,
+ double *height)
{
- DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
- ddjvu_pageinfo_t info;
+ ddjvu_pageinfo_t info;
ddjvu_status_t r;
- g_return_if_fail (djvu_document->d_document);
-
while ((r = ddjvu_document_get_pageinfo(djvu_document->d_document, page, &info)) < DDJVU_JOB_OK)
djvu_handle_events(djvu_document, TRUE);
*height = info.height * SCALE_FACTOR;
}
+static void
+djvu_document_get_page_size (EvDocument *document,
+ EvPage *page,
+ double *width,
+ double *height)
+{
+ DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
+
+ g_return_if_fail (djvu_document->d_document);
+
+ document_get_page_size (djvu_document, page->index,
+ width, height);
+}
+
static cairo_surface_t *
djvu_document_render (EvDocument *document,
EvRenderContext *rc)
double page_width, page_height, tmp;
static const cairo_user_data_key_t key;
- d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page);
+ d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page->index);
while (!ddjvu_page_decoding_done (d_page))
djvu_handle_events(djvu_document, TRUE);
rectangle.x2 = points->x2 / SCALE_FACTOR;
rectangle.y2 = (height - points->y1) / SCALE_FACTOR;
- text = djvu_text_copy (djvu_document, rc->page, &rectangle);
+ text = djvu_text_copy (djvu_document, rc->page->index, &rectangle);
if (text == NULL)
text = g_strdup ("");
gdk_pixbuf_fill (pixbuf, 0xffffffff);
pixels = gdk_pixbuf_get_pixels (pixbuf);
- while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page, 1) < DDJVU_JOB_OK)
+ while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page->index, 1) < DDJVU_JOB_OK)
djvu_handle_events(djvu_document, TRUE);
- ddjvu_thumbnail_render (djvu_document->d_document, rc->page,
+ ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index,
&thumb_width, &thumb_height,
djvu_document->thumbs_format,
gdk_pixbuf_get_rowstride (pixbuf),
{
DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter);
- g_string_append_printf (djvu_document->opts, "%d,", (rc->page) + 1);
+ g_string_append_printf (djvu_document->opts, "%d,", (rc->page->index) + 1);
}
static void
if (r == NULL)
return FALSE;
- djvu_document_get_page_size (EV_DOCUMENT (djvu_document),
- page, &width, &height);
+ document_get_page_size (djvu_document, page, &width, &height);
rectangle->x1 = r->x1 * SCALE_FACTOR;
rectangle->y1 = height - r->y2 * SCALE_FACTOR;
rectangle->x2 = r->x2 * SCALE_FACTOR;
static void dvi_document_document_iface_init (EvDocumentIface *iface);
static void dvi_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
static void dvi_document_file_exporter_iface_init (EvFileExporterIface *iface);
-static void dvi_document_get_page_size (EvDocument *document,
- int page,
- double *width,
- double *height);
static void dvi_document_do_color_special (DviContext *dvi,
const char *prefix,
const char *arg);
static void
dvi_document_get_page_size (EvDocument *document,
- int page,
+ EvPage *page,
double *width,
double *height)
{
*/
g_mutex_lock (dvi_context_mutex);
- mdvi_setpage (dvi_document->context, rc->page);
+ mdvi_setpage (dvi_document->context, rc->page->index);
mdvi_set_shrink (dvi_document->context,
(int)((dvi_document->params->hshrink - 1) / rc->scale) + 1,
static void
dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
EvRenderContext *rc,
- gint *width,
- gint *height)
+ gint *width,
+ gint *height)
{
DviDocument *dvi_document = DVI_DOCUMENT (document);
gdouble page_width = dvi_document->base_width;
g_mutex_lock (dvi_context_mutex);
- mdvi_setpage (dvi_document->context, rc->page);
+ mdvi_setpage (dvi_document->context, rc->page->index);
mdvi_set_shrink (dvi_document->context,
(int)dvi_document->base_width * dvi_document->params->hshrink / thumb_width,
{
DviDocument *dvi_document = DVI_DOCUMENT(exporter);
- g_string_append_printf (dvi_document->exporter_opts, "%d,", (rc->page) + 1);
+ g_string_append_printf (dvi_document->exporter_opts, "%d,", (rc->page->index) + 1);
}
static void
static void
impress_document_get_page_size (EvDocument *document,
- int page,
- double *width,
- double *height)
+ EvPage *page,
+ double *width,
+ double *height)
{
ImpressDocument *impress_document = IMPRESS_DOCUMENT (document);
g_return_val_if_fail (IMPRESS_IS_DOCUMENT (document), NULL);
g_return_val_if_fail (impress_document->imp != NULL, NULL);
- impress_document->pagenum = rc->page;
+ impress_document->pagenum = rc->page->index;
g_mutex_lock (impress_document->mutex);
impress_document->cond = g_cond_new ();
pdf_document_page_transition_iface_init);
});
-static void
-set_rc_data (PdfDocument *pdf_document,
- EvRenderContext *rc)
-{
- if (rc->data == NULL) {
- rc->data = poppler_document_get_page (pdf_document->document,
- rc->page);
- rc->destroy = g_object_unref;
- } else {
- g_assert (rc->page == poppler_page_get_index (POPPLER_PAGE (rc->data)));
- }
-}
-
static void
pdf_document_search_free (PdfDocumentSearch *search)
{
return poppler_document_get_n_pages (PDF_DOCUMENT (document)->document);
}
-static void
-pdf_document_get_page_size (EvDocument *document,
- int page,
- double *width,
- double *height)
+static EvPage *
+pdf_document_get_page (EvDocument *document,
+ gint index)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerPage *poppler_page;
+ EvPage *page;
- poppler_page = poppler_document_get_page (pdf_document->document, page);
- poppler_page_get_size (poppler_page, width, height);
+ poppler_page = poppler_document_get_page (pdf_document->document, index);
+ page = ev_page_new (index);
+ page->backend_page = (EvBackendPage)g_object_ref (poppler_page);
+ page->backend_destroy_func = (EvBackendPageDestroyFunc)g_object_unref;
g_object_unref (poppler_page);
+
+ return page;
+}
+
+static void
+pdf_document_get_page_size (EvDocument *document,
+ EvPage *page,
+ double *width,
+ double *height)
+{
+ g_return_if_fail (POPPLER_IS_PAGE (page->backend_page));
+
+ poppler_page_get_size (POPPLER_PAGE (page->backend_page), width, height);
}
static char *
pdf_document_get_page_label (EvDocument *document,
- int page)
+ EvPage *page)
{
- PopplerPage *poppler_page;
char *label = NULL;
- poppler_page = poppler_document_get_page (PDF_DOCUMENT (document)->document,
- page);
+ g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
- g_object_get (G_OBJECT (poppler_page),
+ g_object_get (G_OBJECT (page->backend_page),
"label", &label,
NULL);
- g_object_unref (poppler_page);
-
return label;
}
EvRenderContext *rc)
{
PdfDocument *pdf_document;
+ PopplerPage *poppler_page;
double width_points, height_points;
gint width, height;
- pdf_document = PDF_DOCUMENT (document);
-
- set_rc_data (pdf_document, rc);
+ poppler_page = POPPLER_PAGE (rc->page->backend_page);
- poppler_page_get_size (POPPLER_PAGE (rc->data),
+ poppler_page_get_size (poppler_page,
&width_points, &height_points);
if (rc->rotation == 90 || rc->rotation == 270) {
height = (int) ((height_points * rc->scale) + 0.5);
}
- return pdf_page_render (POPPLER_PAGE (rc->data),
+ return pdf_page_render (poppler_page,
width, height, rc);
}
PopplerPageMode mode;
PopplerViewerPreferences view_prefs;
PopplerPermissions permissions;
+ EvPage *page;
info = g_new0 (EvDocumentInfo, 1);
"linearized", &(info->linearized),
NULL);
- pdf_document_get_page_size(document, 0,
+ page = ev_document_get_page (document, 0);
+ ev_document_get_page_size (document, page,
&(info->paper_width),
&(info->paper_height));
+ g_object_unref (page);
// Convert to mm.
info->paper_width = info->paper_width / 72.0f * 25.4f;
iface->save = pdf_document_save;
iface->load = pdf_document_load;
iface->get_n_pages = pdf_document_get_n_pages;
+ iface->get_page = pdf_document_get_page;
iface->get_page_size = pdf_document_get_page_size;
iface->get_page_label = pdf_document_get_page_label;
iface->has_attachments = pdf_document_has_attachments;
EvRenderContext *rc,
gboolean border)
{
- PdfDocument *pdf_document;
+ PdfDocument *pdf_document = PDF_DOCUMENT (document_thumbnails);
PopplerPage *poppler_page;
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *border_pixbuf;
- pdf_document = PDF_DOCUMENT (document_thumbnails);
-
- poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
- g_return_val_if_fail (poppler_page != NULL, NULL);
+ poppler_page = POPPLER_PAGE (rc->page->backend_page);
#ifdef POPPLER_WITH_GDK
pixbuf = poppler_page_get_thumbnail_pixbuf (poppler_page);
}
#endif /* POPPLER_WITH_GDK */
-
if (pixbuf) {
/* Rotate provided thumbnail if needed */
GdkPixbuf *rotated_pixbuf;
pixbuf = border_pixbuf;
}
- g_object_unref (poppler_page);
-
return pixbuf;
}
gint *width,
gint *height)
{
- PdfDocument *pdf_document;
PopplerPage *poppler_page;
gint has_thumb;
- pdf_document = PDF_DOCUMENT (document_thumbnails);
- poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
-
- g_return_if_fail (poppler_page != NULL);
+ poppler_page = POPPLER_PAGE (rc->page->backend_page);
has_thumb = poppler_page_get_thumbnail_size (poppler_page, width, height);
*width = *height;
*height = temp;
}
-
- g_object_unref (poppler_page);
}
static void
g_return_if_fail (pdf_document->print_ctx != NULL);
- poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
+ poppler_page = POPPLER_PAGE (rc->page->backend_page);
#ifdef HAVE_CAIRO_PRINT
x = (ctx->pages_printed % ctx->pages_per_sheet) % ctx->pages_x;
if (ctx->format == EV_FILE_FORMAT_PS)
poppler_page_render_to_ps (poppler_page, ctx->ps_file);
#endif /* HAVE_CAIRO_PRINT */
-
- g_object_unref (poppler_page);
}
static void
GdkColor *text,
GdkColor *base)
{
- PdfDocument *pdf_document;
+ PopplerPage *poppler_page;
double width_points, height_points;
gint width, height;
- pdf_document = PDF_DOCUMENT (selection);
- set_rc_data (pdf_document, rc);
+ poppler_page = POPPLER_PAGE (rc->page->backend_page);
- poppler_page_get_size (POPPLER_PAGE (rc->data),
+ poppler_page_get_size (poppler_page,
&width_points, &height_points);
width = (int) ((width_points * rc->scale) + 0.5);
height = (int) ((height_points * rc->scale) + 0.5);
memset (cairo_image_surface_get_data (*surface), 0x00,
cairo_image_surface_get_height (*surface) *
cairo_image_surface_get_stride (*surface));
- poppler_page_render_selection (POPPLER_PAGE (rc->data),
+ poppler_page_render_selection (poppler_page,
cr,
(PopplerRectangle *)points,
(PopplerRectangle *)old_points,
TRUE, 8,
width, height);
- poppler_page_render_selection_to_pixbuf (POPPLER_PAGE (rc->data),
+ poppler_page_render_selection_to_pixbuf (poppler_page,
rc->scale, rc->rotation, pixbuf,
(PopplerRectangle *)points,
(PopplerRectangle *)old_points,
EvSelectionStyle style,
EvRectangle *points)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (selection);
PopplerPage *poppler_page;
PopplerRectangle r;
double height;
char *retval;
- poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
- g_return_val_if_fail (poppler_page != NULL, NULL);
+ poppler_page = POPPLER_PAGE (rc->page->backend_page);
poppler_page_get_size (poppler_page, NULL, &height);
r.x1 = points->x1;
(PopplerSelectionStyle)style,
&r);
- g_object_unref (poppler_page);
-
return retval;
}
EvSelectionStyle style,
EvRectangle *points)
{
- PdfDocument *pdf_document;
+ PopplerPage *poppler_page;
GdkRegion *retval;
- GList *region;
+ GList *region;
- pdf_document = PDF_DOCUMENT (selection);
-
- set_rc_data (pdf_document, rc);
+ poppler_page = POPPLER_PAGE (rc->page->backend_page);
- region = poppler_page_get_selection_region (POPPLER_PAGE (rc->data),
+ region = poppler_page_get_selection_region (poppler_page,
rc->scale,
(PopplerSelectionStyle)style,
(PopplerRectangle *) points);
pdf_selection_get_selection_map (EvSelection *selection,
EvRenderContext *rc)
{
- PdfDocument *pdf_document;
PopplerPage *poppler_page;
PopplerRectangle points;
GList *region;
GdkRegion *retval;
- pdf_document = PDF_DOCUMENT (selection);
- poppler_page = poppler_document_get_page (pdf_document->document,
- rc->page);
+ poppler_page = POPPLER_PAGE (rc->page->backend_page);
points.x1 = 0.0;
points.y1 = 0.0;
&points);
retval = create_gdk_region_from_poppler_region (region);
g_list_free (region);
- g_object_unref (poppler_page);
return retval;
}
static GList *
pdf_document_forms_get_form_fields (EvDocumentForms *document,
- gint page)
+ EvPage *page)
{
- PdfDocument *pdf_document;
PopplerPage *poppler_page;
GList *retval = NULL;
GList *fields;
GList *list;
double height;
- pdf_document = PDF_DOCUMENT (document);
- poppler_page = poppler_document_get_page (pdf_document->document, page);
+ g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
+
+ poppler_page = POPPLER_PAGE (page->backend_page);
fields = poppler_page_get_form_field_mapping (poppler_page);
poppler_page_get_size (poppler_page, NULL, &height);
field_mapping->y1 = height - mapping->area.y2;
field_mapping->y2 = height - mapping->area.y1;
field_mapping->field = ev_field;
- field_mapping->field->page = page;
+ field_mapping->field->page = EV_PAGE (g_object_ref (page));
+
+ g_object_set_data_full (G_OBJECT (ev_field),
+ "poppler-field",
+ g_object_ref (mapping->field),
+ (GDestroyNotify) g_object_unref);
retval = g_list_prepend (retval, field_mapping);
}
poppler_page_free_form_field_mapping (fields);
- g_object_unref (poppler_page);
return g_list_reverse (retval);
}
EvFormField *field)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
gchar *text;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return NULL;
text = poppler_form_field_text_get_text (poppler_field);
- g_object_unref (poppler_field);
return text;
}
EvFormField *field,
const gchar *text)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return;
poppler_form_field_text_set_text (poppler_field, text);
- g_object_unref (poppler_field);
}
static void
EvFormField *field,
gboolean state)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return;
poppler_form_field_button_set_state (poppler_field, state);
- g_object_unref (poppler_field);
}
static gboolean
pdf_document_forms_form_field_button_get_state (EvDocumentForms *document,
EvFormField *field)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
gboolean state;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return FALSE;
state = poppler_form_field_button_get_state (poppler_field);
- g_object_unref (poppler_field);
return state;
}
EvFormField *field,
gint index)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
gchar *text;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return NULL;
text = poppler_form_field_choice_get_item (poppler_field, index);
- g_object_unref (poppler_field);
return text;
}
pdf_document_forms_form_field_choice_get_n_items (EvDocumentForms *document,
EvFormField *field)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
gint n_items;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return -1;
n_items = poppler_form_field_choice_get_n_items (poppler_field);
- g_object_unref (poppler_field);
return n_items;
}
EvFormField *field,
gint index)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
gboolean selected;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return FALSE;
selected = poppler_form_field_choice_is_item_selected (poppler_field, index);
- g_object_unref (poppler_field);
return selected;
}
EvFormField *field,
gint index)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return;
poppler_form_field_choice_select_item (poppler_field, index);
- g_object_unref (poppler_field);
}
static void
EvFormField *field,
gint index)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return;
poppler_form_field_choice_toggle_item (poppler_field, index);
- g_object_unref (poppler_field);
}
static void
pdf_document_forms_form_field_choice_unselect_all (EvDocumentForms *document,
EvFormField *field)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return;
poppler_form_field_choice_unselect_all (poppler_field);
- g_object_unref (poppler_field);
}
static void
EvFormField *field,
const gchar *text)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return;
poppler_form_field_choice_set_text (poppler_field, text);
- g_object_unref (poppler_field);
}
static gchar *
pdf_document_forms_form_field_choice_get_text (EvDocumentForms *document,
EvFormField *field)
{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerFormField *poppler_field;
gchar *text;
- poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ poppler_field = POPPLER_FORM_FIELD (g_object_get_data (G_OBJECT (field), "poppler-field"));
if (!poppler_field)
return NULL;
text = poppler_form_field_choice_get_text (poppler_field);
- g_object_unref (poppler_field);
return text;
}
static void
pixbuf_document_get_page_size (EvDocument *document,
- int page,
+ EvPage *page,
double *width,
double *height)
{
return spectre_document_get_n_pages (ps->doc);
}
+static EvPage *
+ps_document_get_page (EvDocument *document,
+ gint index)
+{
+ PSDocument *ps = PS_DOCUMENT (document);
+ SpectrePage *ps_page;
+ EvPage *page;
+
+ ps_page = spectre_document_get_page (ps->doc, index);
+ page = ev_page_new (index);
+ page->backend_page = (EvBackendPage)ps_page;
+ page->backend_destroy_func = (EvBackendPageDestroyFunc)spectre_page_free;
+
+ return page;
+}
+
static gint
get_page_rotation (SpectrePage *page)
{
static void
ps_document_get_page_size (EvDocument *document,
- int page,
+ EvPage *page,
double *width,
double *height)
{
- PSDocument *ps = PS_DOCUMENT (document);
SpectrePage *ps_page;
gdouble page_width, page_height;
gint pwidth, pheight;
gint rotate;
- ps_page = spectre_document_get_page (ps->doc, page);
+ ps_page = (SpectrePage *)page->backend_page;
+
spectre_page_get_size (ps_page, &pwidth, &pheight);
rotate = get_page_rotation (ps_page);
page_height = pheight;
}
- spectre_page_free (ps_page);
-
if (width) {
*width = page_width;
}
static char *
ps_document_get_page_label (EvDocument *document,
- int page)
+ EvPage *page)
{
- PSDocument *ps = PS_DOCUMENT (document);
- SpectrePage *ps_page;
- gchar *label;
-
- ps_page = spectre_document_get_page (ps->doc, page);
- label = g_strdup (spectre_page_get_label (ps_page));
- spectre_page_free (ps_page);
-
- return label;
+ return g_strdup (spectre_page_get_label ((SpectrePage *)page->backend_page));
}
static EvDocumentInfo *
ps_document_render (EvDocument *document,
EvRenderContext *rc)
{
- PSDocument *ps = PS_DOCUMENT (document);
SpectrePage *ps_page;
SpectreRenderContext *src;
gint width_points;
cairo_surface_t *surface;
static const cairo_user_data_key_t key;
- ps_page = spectre_document_get_page (ps->doc, rc->page);
+ ps_page = (SpectrePage *)rc->page->backend_page;
+
spectre_page_get_size (ps_page, &width_points, &height_points);
width = (gint) ((width_points * rc->scale) + 0.5);
spectre_render_context_free (src);
if (!data) {
- spectre_page_free (ps_page);
return NULL;
}
if (spectre_page_status (ps_page)) {
g_warning (spectre_status_to_string (spectre_page_status (ps_page)));
g_free (data);
- spectre_page_free (ps_page);
return NULL;
}
- spectre_page_free (ps_page);
-
if (rotation == 90 || rotation == 270) {
swidth = height;
sheight = width;
iface->load = ps_document_load;
iface->save = ps_document_save;
iface->get_n_pages = ps_document_get_n_pages;
+ iface->get_page = ps_document_get_page;
iface->get_page_size = ps_document_get_page_size;
iface->get_page_label = ps_document_get_page_label;
iface->get_info = ps_document_get_info;
{
PSDocument *ps = PS_DOCUMENT (exporter);
- spectre_exporter_do_page (ps->exporter, rc->page);
+ spectre_exporter_do_page (ps->exporter, rc->page->index);
}
static void
}
static void
-tiff_document_get_page_size (EvDocument *document,
- int page,
- double *width,
- double *height)
+tiff_document_get_page_size (EvDocument *document,
+ EvPage *page,
+ double *width,
+ double *height)
{
guint32 w, h;
gfloat x_res, y_res;
g_return_if_fail (tiff_document->tiff != NULL);
push_handlers ();
- if (TIFFSetDirectory (tiff_document->tiff, page) != 1) {
+ if (TIFFSetDirectory (tiff_document->tiff, page->index) != 1) {
pop_handlers ();
return;
}
g_return_val_if_fail (tiff_document->tiff != NULL, NULL);
push_handlers ();
- if (TIFFSetDirectory (tiff_document->tiff, rc->page) != 1) {
+ if (TIFFSetDirectory (tiff_document->tiff, rc->page->index) != 1) {
pop_handlers ();
return NULL;
}
GdkPixbuf *rotated_pixbuf;
push_handlers ();
- if (TIFFSetDirectory (tiff_document->tiff, rc->page) != 1) {
+ if (TIFFSetDirectory (tiff_document->tiff, rc->page->index) != 1) {
pop_handlers ();
return NULL;
}
if (document->ps_export_ctx == NULL)
return;
- if (TIFFSetDirectory (document->tiff, rc->page) != 1)
+ if (TIFFSetDirectory (document->tiff, rc->page->index) != 1)
return;
tiff2ps_process_page (document->ps_export_ctx, document->tiff,
0, 0, 0, 0, 0);
ev-link-action.h \
ev-link-dest.h \
ev-link.h \
+ ev-page.h \
ev-render-context.h \
ev-selection.h \
ev-transition-effect.h
ev-file-exporter.c \
ev-file-helpers.c \
ev-module.c \
+ ev-page.c \
ev-render-context.c \
ev-selection.c \
ev-transition-effect.c \
GList *
ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
- gint page)
+ EvPage *page)
{
EvDocumentFormsIface *iface = EV_DOCUMENT_FORMS_GET_IFACE (document_forms);
/* Methods */
GList *(* get_form_fields) (EvDocumentForms *document_forms,
- gint page);
+ EvPage *page);
gchar *(* form_field_text_get_text) (EvDocumentForms *document_forms,
EvFormField *field);
void (* form_field_text_set_text) (EvDocumentForms *document_forms,
GType ev_document_forms_get_type (void) G_GNUC_CONST;
GList *ev_document_forms_get_form_fields (EvDocumentForms *document_forms,
- gint page);
+ EvPage *page);
gchar *ev_document_forms_form_field_text_get_text (EvDocumentForms *document_forms,
EvFormField *field);
return retval;
}
+EvPage *
+ev_document_get_page (EvDocument *document,
+ gint index)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+ EvPage *retval;
+
+ if (iface->get_page)
+ retval = iface->get_page (document, index);
+ else
+ retval = ev_page_new (index);
+
+ return retval;
+}
+
void
-ev_document_get_page_size (EvDocument *document,
- int page,
- double *width,
- double *height)
+ev_document_get_page_size (EvDocument *document,
+ EvPage *page,
+ double *width,
+ double *height)
{
EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
}
char *
-ev_document_get_page_label(EvDocument *document,
- int page)
+ev_document_get_page_label (EvDocument *document,
+ EvPage *page)
{
EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
g_free (info->linearized);
g_free (info->security);
-
g_free (info);
}
#include <cairo.h>
#include "ev-document-info.h"
+#include "ev-page.h"
#include "ev-render-context.h"
G_BEGIN_DECLS
const char *uri,
GError **error);
int (* get_n_pages) (EvDocument *document);
+ EvPage * (* get_page) (EvDocument *document,
+ gint index);
void (* get_page_size) (EvDocument *document,
- int page,
+ EvPage *page,
double *width,
double *height);
char * (* get_page_label) (EvDocument *document,
- int page);
+ EvPage *page);
gboolean (* has_attachments) (EvDocument *document);
GList * (* get_attachments) (EvDocument *document);
cairo_surface_t * (* render) (EvDocument *document,
const char *uri,
GError **error);
int ev_document_get_n_pages (EvDocument *document);
+EvPage *ev_document_get_page (EvDocument *document,
+ gint index);
void ev_document_get_page_size (EvDocument *document,
- int page,
+ EvPage *page,
double *width,
double *height);
char *ev_document_get_page_label (EvDocument *document,
- int page);
+ EvPage *page);
gboolean ev_document_has_attachments (EvDocument *document);
GList *ev_document_get_attachments (EvDocument *document);
cairo_surface_t *ev_document_render (EvDocument *document,
static void
ev_form_field_init (EvFormField *field)
{
- field->page = -1;
+ field->page = NULL;
field->changed = FALSE;
field->is_read_only = FALSE;
}
+static void
+ev_form_field_finalize (GObject *object)
+{
+ EvFormField *field = EV_FORM_FIELD (object);
+
+ g_object_unref (field->page);
+ field->page = NULL;
+
+ (* G_OBJECT_CLASS (ev_form_field_parent_class)->finalize) (object);
+}
+
static void
ev_form_field_class_init (EvFormFieldClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ev_form_field_finalize;
}
static void
gboolean is_read_only;
gdouble font_size;
- gint page;
+ EvPage *page;
gboolean changed;
};
--- /dev/null
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include "ev-page.h"
+
+G_DEFINE_TYPE (EvPage, ev_page, G_TYPE_OBJECT)
+
+static void
+ev_page_init (EvPage *page)
+{
+}
+
+static void
+ev_page_finalize (GObject *object)
+{
+ EvPage *page = EV_PAGE (object);
+
+ if (page->backend_destroy_func) {
+ page->backend_destroy_func (page->backend_page);
+ page->backend_destroy_func = NULL;
+ }
+ page->backend_page = NULL;
+
+ (* G_OBJECT_CLASS (ev_page_parent_class)->finalize) (object);
+}
+
+static void
+ev_page_class_init (EvPageClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = ev_page_finalize;
+}
+
+EvPage *
+ev_page_new (gint index)
+{
+ EvPage *page;
+
+ page = EV_PAGE (g_object_new (EV_TYPE_PAGE, NULL));
+ page->index = index;
+
+ return page;
+}
--- /dev/null
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef EV_PAGE_H
+#define EV_PAGE_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_PAGE (ev_page_get_type())
+#define EV_PAGE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PAGE, EvPage))
+#define EV_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_PAGE, EvPageClass))
+#define EV_IS_PAGE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PAGE))
+#define EV_IS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_PAGE))
+#define EV_PAGE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_PAGE, EvPageClass))
+
+typedef struct _EvPage EvPage;
+typedef struct _EvPageClass EvPageClass;
+
+typedef gpointer EvBackendPage;
+typedef GDestroyNotify EvBackendPageDestroyFunc;
+
+struct _EvPage {
+ GObject base_instance;
+
+ gint index;
+
+ EvBackendPage backend_page;
+ EvBackendPageDestroyFunc backend_destroy_func;
+};
+
+struct _EvPageClass {
+ GObjectClass base_class;
+};
+
+GType ev_page_get_type (void) G_GNUC_CONST;
+
+EvPage *ev_page_new (gint index);
+
+G_END_DECLS
+
+#endif /* EV_PAGE_H */
rc = (EvRenderContext *) object;
- if (rc->destroy) {
- (*rc->destroy) (rc->data);
- rc->destroy = NULL;
+ if (rc->page) {
+ g_object_unref (rc->page);
+ rc->page = NULL;
}
(* G_OBJECT_CLASS (ev_render_context_parent_class)->dispose) (object);
oclass->dispose = ev_render_context_dispose;
}
-
EvRenderContext *
-ev_render_context_new (int rotation,
- gint page,
- gdouble scale)
+ev_render_context_new (EvPage *page,
+ gint rotation,
+ gdouble scale)
{
EvRenderContext *rc;
rc = (EvRenderContext *) g_object_new (EV_TYPE_RENDER_CONTEXT, NULL);
+ rc->page = page ? g_object_ref (page) : NULL;
rc->rotation = rotation;
- rc->page = page;
rc->scale = scale;
return rc;
void
ev_render_context_set_page (EvRenderContext *rc,
- gint page)
+ EvPage *page)
{
g_return_if_fail (rc != NULL);
+ g_return_if_fail (EV_IS_PAGE (page));
- rc->page = page;
+ if (rc->page)
+ g_object_unref (rc->page);
+ rc->page = g_object_ref (page);
}
void
#include <glib-object.h>
+#include "ev-page.h"
+
G_BEGIN_DECLS
typedef struct _EvRenderContext EvRenderContext;
typedef struct _EvRenderContextClass EvRenderContextClass;
#define EV_TYPE_RENDER_CONTEXT (ev_render_context_get_type())
-#define EV_RENDER_CONTEXT(context) ((EvRenderContext *) (context))
-#define EV_RENDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_RENDER_CONTEXT, EvRenderContext))
+#define EV_RENDER_CONTEXT(context) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_RENDER_CONTEXT, EvRenderContext)
+#define EV_RENDER_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_RENDER_CONTEXT, EvRenderContextClass))
#define EV_IS_RENDER_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_RENDER_CONTEXT))
struct _EvRenderContextClass
struct _EvRenderContext
{
GObject parent;
- int rotation;
- gint page;
+
+ EvPage *page;
+ gint rotation;
gdouble scale;
-
- gpointer data;
- GDestroyNotify destroy;
};
GType ev_render_context_get_type (void) G_GNUC_CONST;
-EvRenderContext *ev_render_context_new (int rotation,
- gint page,
+EvRenderContext *ev_render_context_new (EvPage *page,
+ gint rotation,
gdouble scale);
void ev_render_context_set_page (EvRenderContext *rc,
- gint page);
+ EvPage *page);
void ev_render_context_set_rotation (EvRenderContext *rc,
- int rotation);
+ gint rotation);
void ev_render_context_set_scale (EvRenderContext *rc,
gdouble scale);
job->thumbnail = NULL;
}
- if (job->rc) {
- g_object_unref (job->rc);
- job->rc = NULL;
- }
-
(* G_OBJECT_CLASS (ev_job_thumbnail_parent_class)->dispose) (object);
}
if (EV_JOB (job)->async) {
EvAsyncRenderer *renderer = EV_ASYNC_RENDERER (EV_JOB (job)->document);
- ev_async_renderer_render_pixbuf (renderer, job->rc->page, job->rc->scale,
+ ev_async_renderer_render_pixbuf (renderer, job->rc->page->index, job->rc->scale,
job->rc->rotation);
g_signal_connect (EV_JOB (job)->document, "render_finished",
G_CALLBACK (render_finished_cb), job);
if (job->include_links && EV_IS_DOCUMENT_LINKS (EV_JOB (job)->document))
job->link_mapping =
ev_document_links_get_links (EV_DOCUMENT_LINKS (EV_JOB (job)->document),
- job->rc->page);
+ job->rc->page->index);
if (job->include_forms && EV_IS_DOCUMENT_FORMS (EV_JOB (job)->document))
job->form_field_mapping =
- ev_document_forms_get_form_fields (EV_DOCUMENT_FORMS (EV_JOB(job)->document),
+ ev_document_forms_get_form_fields (EV_DOCUMENT_FORMS (EV_JOB (job)->document),
job->rc->page);
if (job->include_images && EV_IS_DOCUMENT_IMAGES (EV_JOB (job)->document))
job->image_mapping =
ev_document_images_get_image_mapping (EV_DOCUMENT_IMAGES (EV_JOB (job)->document),
- job->rc->page);
+ job->rc->page->index);
EV_JOB (job)->finished = TRUE;
}
}
EvJob *
-ev_job_thumbnail_new (EvDocument *document,
- EvRenderContext *rc)
+ev_job_thumbnail_new (EvDocument *document,
+ gint page,
+ gint rotation,
+ gdouble scale)
{
EvJobThumbnail *job;
job = g_object_new (EV_TYPE_JOB_THUMBNAIL, NULL);
EV_JOB (job)->document = g_object_ref (document);
- job->rc = g_object_ref (rc);
+ job->page = page;
+ job->rotation = rotation;
+ job->scale = scale;
return EV_JOB (job);
}
void
ev_job_thumbnail_run (EvJobThumbnail *job)
{
+ EvRenderContext *rc;
+ EvPage *page;
+
g_return_if_fail (EV_IS_JOB_THUMBNAIL (job));
ev_document_doc_mutex_lock ();
+ page = ev_document_get_page (EV_JOB (job)->document, job->page);
+ rc = ev_render_context_new (page, job->rotation, job->scale);
+ g_object_unref (page);
+
job->thumbnail =
ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (EV_JOB (job)->document),
- job->rc, TRUE);
- EV_JOB (job)->finished = TRUE;
-
+ rc, TRUE);
+ g_object_unref (rc);
ev_document_doc_mutex_unlock ();
+
+ EV_JOB (job)->finished = TRUE;
}
static void ev_job_fonts_init (EvJobFonts *job) { /* Do Nothing */ }
fc.duplex = FALSE;
fc.pages_per_sheet = MAX (1, job->pages_per_sheet);
- rc = ev_render_context_new (0, 0, 1.0);
+ rc = ev_render_context_new (NULL, 0, 1.0);
ev_document_doc_mutex_lock ();
ev_file_exporter_begin (EV_FILE_EXPORTER (document), &fc);
ev_file_exporter_begin_page (EV_FILE_EXPORTER (document));
for (j = 0; j < job->pages_per_sheet; j++) {
+ EvPage *ev_page;
+
gint p = page + j;
if (p < 0 || p >= n_pages)
break;
+
+ ev_page = ev_document_get_page (document, page_list[p]);
+ ev_render_context_set_page (rc, ev_page);
+ g_object_unref (ev_page);
- ev_render_context_set_page (rc, page_list[p]);
ev_file_exporter_do_page (EV_FILE_EXPORTER (document), rc);
}
{
EvJob parent;
- EvRenderContext *rc;
+ gint page;
+ gint rotation;
+ gdouble scale;
+
GdkPixbuf *thumbnail;
};
/* EvJobThumbnail */
GType ev_job_thumbnail_get_type (void) G_GNUC_CONST;
EvJob *ev_job_thumbnail_new (EvDocument *document,
- EvRenderContext *rc);
+ gint page,
+ gint rotation,
+ gdouble scale);
void ev_job_thumbnail_run (EvJobThumbnail *thumbnail);
/* EvJobFonts */
#include "ev-page-cache.h"
#include "ev-job-queue.h"
#include "ev-document-thumbnails.h"
+#include "ev-page.h"
#include <stdlib.h>
#include <string.h>
has_thumbs = EV_IS_DOCUMENT_THUMBNAILS (document);
for (i = 0; i < page_cache->n_pages; i++) {
- double page_width = 0;
- double page_height = 0;
- gint thumb_width = 0;
- gint thumb_height = 0;
+ EvPage *page;
+ double page_width = 0;
+ double page_height = 0;
+ gint thumb_width = 0;
+ gint thumb_height = 0;
- ev_document_get_page_size (document, i, &page_width, &page_height);
+ page = ev_document_get_page (document, i);
+
+ ev_document_get_page_size (document, page, &page_width, &page_height);
- page_cache->page_labels[i] = ev_document_get_page_label (document, i);
+ page_cache->page_labels[i] = ev_document_get_page_label (document, page);
if (page_cache->page_labels[i] != NULL) {
- page_cache->max_label_chars = MAX(page_cache->max_label_chars,
- g_utf8_strlen (page_cache->page_labels[i], 256));
+ page_cache->max_label_chars = MAX (page_cache->max_label_chars,
+ g_utf8_strlen (page_cache->page_labels[i], 256));
if (!page_cache->has_labels) {
gchar *expected_label;
info->height = page_height;
}
- if (!has_thumbs)
+ if (!has_thumbs) {
+ g_object_unref (page);
continue;
+ }
if (!rc) {
- rc = ev_render_context_new (0, i, (gdouble)THUMBNAIL_WIDTH / page_width);
+ rc = ev_render_context_new (page, 0, (gdouble)THUMBNAIL_WIDTH / page_width);
} else {
- ev_render_context_set_page (rc, i);
+ ev_render_context_set_page (rc, page);
ev_render_context_set_scale (rc, (gdouble)THUMBNAIL_WIDTH / page_width);
}
thumb_info->width = thumb_width;
thumb_info->height = thumb_height;
}
+
+ g_object_unref (page);
}
if (rc) {
EvJobRender *job_render = EV_JOB_RENDER (job);
/* If the job is outside of our interest, we silently discard it */
- if ((job_render->rc->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
- (job_render->rc->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
+ if ((job_render->rc->page->index < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
+ (job_render->rc->page->index > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
g_object_unref (job);
return;
}
- job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
+ job_info = find_job_cache (pixbuf_cache, job_render->rc->page->index);
copy_job_page_and_selection_to_job_info (job_render, job_info, pixbuf_cache);
g_signal_emit (pixbuf_cache, signals[JOB_FINISHED], 0, job_info->region);
EvJobRender *job_render = EV_JOB_RENDER (job);
/* If the job is outside of our interest, we silently discard it */
- if ((job_render->rc->page < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
- (job_render->rc->page > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
+ if ((job_render->rc->page->index < (pixbuf_cache->start_page - pixbuf_cache->preload_cache_size)) ||
+ (job_render->rc->page->index > (pixbuf_cache->end_page + pixbuf_cache->preload_cache_size))) {
g_object_unref (job);
return;
}
- job_info = find_job_cache (pixbuf_cache, job_render->rc->page);
+ job_info = find_job_cache (pixbuf_cache, job_render->rc->page->index);
copy_job_to_job_info (job_render, job_info, pixbuf_cache);
}
return;
ev_page_cache_get_size (page_cache,
- EV_JOB_RENDER (job_info->job)->rc->page,
+ EV_JOB_RENDER (job_info->job)->rc->page->index,
EV_JOB_RENDER (job_info->job)->rc->rotation,
scale,
&width, &height);
gfloat scale,
EvJobPriority priority)
{
+ EvPage *ev_page;
gboolean include_links = FALSE;
gboolean include_text = FALSE;
gboolean include_selection = FALSE;
job_info->page_ready = FALSE;
+ /* FIXME: we shouldn't lock here */
+ ev_document_doc_mutex_lock ();
+ ev_page = ev_document_get_page (pixbuf_cache->document, page);
+ ev_document_doc_mutex_unlock ();
+
if (job_info->rc == NULL) {
- job_info->rc = ev_render_context_new (rotation, page, scale);
+ job_info->rc = ev_render_context_new (ev_page, rotation, scale);
} else {
+ ev_render_context_set_page (job_info->rc, ev_page);
ev_render_context_set_rotation (job_info->rc, rotation);
- ev_render_context_set_page (job_info->rc, page);
ev_render_context_set_scale (job_info->rc, scale);
}
+ g_object_unref (ev_page);
+
if (job_info->region)
gdk_region_destroy (job_info->region);
job_info->region = region ? gdk_region_copy (region) : NULL;
-1);
if (job == NULL && !thumbnail_set) {
- EvRenderContext *rc;
-
- rc = ev_render_context_new (priv->rotation, page,
+ job = ev_job_thumbnail_new (priv->document,
+ page, priv->rotation,
get_scale_for_page (sidebar_thumbnails, page));
- job = ev_job_thumbnail_new (priv->document, rc);
ev_job_queue_add_job (EV_JOB (job), EV_JOB_PRIORITY_HIGH);
- g_object_unref (rc);
g_object_set_data_full (G_OBJECT (job), "tree_iter",
gtk_tree_iter_copy (&iter),
GList *forms_mapping;
forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache,
- field->page);
+ field->page->index);
ev_form_field_mapping_get_area (forms_mapping, field, &field_area);
- doc_rect_to_view_rect (view, field->page, &field_area, &view_area);
+ doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area);
view_area.x -= view->scroll_x;
view_area.y -= view->scroll_y;
* we need to update also the region for the current selected item
*/
forms_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache,
- field->page);
+ field->page->index);
for (l = forms_mapping; l; l = g_list_next (l)) {
EvFormField *button = ((EvFormFieldMapping *)(l->data))->field;
GdkRegion *button_region;
ev_pixbuf_cache_reload_page (view->pixbuf_cache,
field_region,
- field->page,
+ field->page->index,
view->rotation,
view->scale);
gdk_region_destroy (field_region);
field->changed = FALSE;
ev_pixbuf_cache_reload_page (view->pixbuf_cache,
field_region,
- field->page,
+ field->page->index,
view->rotation,
view->scale);
gdk_region_destroy (field_region);
field->changed = FALSE;
ev_pixbuf_cache_reload_page (view->pixbuf_cache,
field_region,
- field->page,
+ field->page->index,
view->rotation,
view->scale);
gdk_region_destroy (field_region);
g_object_ref (field),
(GDestroyNotify)g_object_unref);
- form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page);
+ form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache, field->page->index);
ev_form_field_mapping_get_area (form_field_mapping, field, &field_area);
- doc_rect_to_view_rect (view, field->page, &field_area, &view_area);
+ doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area);
view_area.x -= view->scroll_x;
view_area.y -= view->scroll_y;
continue;
form_field_mapping = ev_pixbuf_cache_get_form_field_mapping (view->pixbuf_cache,
- field->page);
+ field->page->index);
ev_form_field_mapping_get_area (form_field_mapping, field, &field_area);
- doc_rect_to_view_rect (view, field->page, &field_area, &view_area);
+ doc_rect_to_view_rect (view, field->page->index, &field_area, &view_area);
view_area.x -= view->scroll_x;
view_area.y -= view->scroll_y;
EvRenderContext *rc;
text = g_string_new (NULL);
- rc = ev_render_context_new (view->rotation, 1, view->scale);
+ rc = ev_render_context_new (NULL, view->rotation, view->scale);
ev_document_doc_mutex_lock ();
for (l = view->selection_info.selections; l != NULL; l = l->next) {
EvViewSelection *selection = (EvViewSelection *)l->data;
+ EvPage *page;
gchar *tmp;
- ev_render_context_set_page (rc, selection->page);
+ page = ev_document_get_page (view->document, selection->page);
+ ev_render_context_set_page (rc, page);
+ g_object_unref (page);
+
tmp = ev_selection_get_selected_text (EV_SELECTION (view->document),
rc, selection->style,
&(selection->rect));
g_free (tmp);
}
- ev_document_doc_mutex_unlock ();
-
g_object_unref (rc);
+ ev_document_doc_mutex_unlock ();
+
normalized_text = g_utf8_normalize (text->str, text->len, G_NORMALIZE_NFKC);
g_string_free (text, TRUE);
return normalized_text;
static void
ev_window_refresh_window_thumbnail (EvWindow *ev_window, int rotation)
{
-
- EvRenderContext *rc;
gint page_width, page_height;
gdouble scale;
EvDocument *document = ev_window->priv->document;
&page_width, &page_height);
scale = (gdouble)128 / (gdouble)page_width;
- rc = ev_render_context_new (rotation, 0, scale);
-
- ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, rc);
+ ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, rotation, scale);
g_signal_connect (ev_window->priv->thumbnail_job, "finished",
G_CALLBACK (ev_window_set_icon_from_thumbnail),
ev_window);
ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
- g_object_unref (rc);
}
static gboolean
EvRenderContext *rc;
double width, height;
GdkPixbuf *pixbuf;
+ EvPage *page;
- ev_document_get_page_size (document, 0, &width, &height);
+ page = ev_document_get_page (document, 0);
+
+ ev_document_get_page_size (document, page, &width, &height);
- rc = ev_render_context_new (0, 0, size / width);
+ rc = ev_render_context_new (page, 0, size / width);
pixbuf = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (document),
rc, FALSE);
g_object_unref (rc);
+ g_object_unref (page);
if (pixbuf != NULL) {
const char *overlaid_icon_name = NULL;