]> www.fi.muni.cz Git - evince.git/commitdiff
Make printing work again
authorMarco Pesenti Gritti <mpg@redhat.com>
Fri, 8 Apr 2005 08:19:25 +0000 (08:19 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Fri, 8 Apr 2005 08:19:25 +0000 (08:19 +0000)
2005-04-08  Marco Pesenti Gritti <mpg@redhat.com>

        * pdf/ev-poppler.cc:
        * shell/ev-print-job.c: (idle_print_handler):

        Make printing work again

ChangeLog
pdf/ev-poppler.cc
shell/ev-print-job.c

index 6f70f3624e59562fd87b7d4bdcdde88ade145fdb..693f80bbe7b1bd77baf492665fe77b9e27c7e35c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-08  Marco Pesenti Gritti <mpg@redhat.com>
+
+       * 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  <jrb@redhat.com>
 
        * shell/ev-page-action.h:
index 4ca7d01798921e3600a00134479ab457d0a2a2d7..ac602b0452a7f3a45f96cdab1d46d3cd3e8070fb 100644 (file)
@@ -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)
index ba283ff77ffa9d36dc1bd0c21800375216b78b8d..ccc07e38541bc1d448146830b810a3b619095190 100644 (file)
@@ -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