From cf6c30c93ee2c79e90200b2316587aeb12dc2ee2 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 8 Apr 2005 08:19:25 +0000 Subject: [PATCH] Make printing work again 2005-04-08 Marco Pesenti Gritti * pdf/ev-poppler.cc: * shell/ev-print-job.c: (idle_print_handler): Make printing work again --- ChangeLog | 7 +++++++ pdf/ev-poppler.cc | 47 ++++++++++++++++++++++++++++++++++++++------ shell/ev-print-job.c | 4 ++-- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f70f362..693f80bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-04-08 Marco Pesenti Gritti + + * pdf/ev-poppler.cc: + * shell/ev-print-job.c: (idle_print_handler): + + Make printing work again + Fri Apr 8 01:12:24 2005 Jonathan Blandford * shell/ev-page-action.h: diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 4ca7d017..ac602b04 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -58,6 +58,7 @@ struct _PdfDocument GObject parent_instance; PopplerDocument *document; + PopplerPSFile *ps_file; gchar *password; PdfDocumentSearch *search; @@ -68,6 +69,7 @@ static void pdf_document_security_iface_init (EvDocumentSecurityIface static void pdf_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface); static void pdf_document_document_links_iface_init (EvDocumentLinksIface *iface); static void pdf_document_find_iface_init (EvDocumentFindIface *iface); +static void pdf_document_ps_exporter_iface_init (EvPSExporterIface *iface); static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails, gint page, gint size, @@ -88,17 +90,11 @@ G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT, pdf_document_document_links_iface_init); G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FIND, pdf_document_find_iface_init); -#if 0 G_IMPLEMENT_INTERFACE (EV_TYPE_PS_EXPORTER, pdf_document_ps_exporter_iface_init); -#endif }); - - - - static void pdf_document_get_property (GObject *object, guint prop_id, @@ -801,6 +797,45 @@ pdf_document_find_iface_init (EvDocumentFindIface *iface) iface->cancel = pdf_document_find_cancel; } +static void +pdf_document_ps_exporter_begin (EvPSExporter *exporter, const char *filename) +{ + PdfDocument *pdf_document = PDF_DOCUMENT (exporter); + int n_pages; + + n_pages = pdf_document_get_n_pages (EV_DOCUMENT (exporter)); + pdf_document->ps_file = poppler_ps_file_new (pdf_document->document, + filename, n_pages); +} + +static void +pdf_document_ps_exporter_do_page (EvPSExporter *exporter, int page) +{ + PdfDocument *pdf_document = PDF_DOCUMENT (exporter); + PopplerPage *poppler_page; + + g_return_if_fail (pdf_document->ps_file != NULL); + + poppler_page = poppler_document_get_page (pdf_document->document, page); + poppler_page_render_to_ps (poppler_page, pdf_document->ps_file); +} + +static void +pdf_document_ps_exporter_end (EvPSExporter *exporter) +{ + PdfDocument *pdf_document = PDF_DOCUMENT (exporter); + + poppler_ps_file_free (pdf_document->ps_file); + pdf_document->ps_file = NULL; +} + +static void +pdf_document_ps_exporter_iface_init (EvPSExporterIface *iface) +{ + iface->begin = pdf_document_ps_exporter_begin; + iface->do_page = pdf_document_ps_exporter_do_page; + iface->end = pdf_document_ps_exporter_end; +} PdfDocument * pdf_document_new (void) diff --git a/shell/ev-print-job.c b/shell/ev-print-job.c index ba283ff7..ccc07e38 100644 --- a/shell/ev-print-job.c +++ b/shell/ev-print-job.c @@ -238,13 +238,13 @@ idle_print_handler (EvPrintJob *job) ev_ps_exporter_begin (EV_PS_EXPORTER (job->document), job->temp_file); g_mutex_unlock (EV_DOC_MUTEX); - job->next_page = 1; /* FIXME use 0-based page numbering? */ + job->next_page = 0; job->printing = TRUE; return TRUE; } page_cache = ev_document_get_page_cache (job->document); - if (job->next_page <= ev_page_cache_get_n_pages (page_cache)) { + if (job->next_page < ev_page_cache_get_n_pages (page_cache)) { #if 0 g_printerr ("Printing page %d\n", job->next_page); #endif -- 2.43.5